log(graphql): log deprecated order argument usage

This commit is contained in:
Paul Chavard 2023-11-02 10:36:03 +00:00
parent a26c82cde7
commit 99e22a8cbe
3 changed files with 18 additions and 1 deletions

View file

@ -40,6 +40,7 @@ class API::V2::BaseController < ApplicationController
if @api_token.present?
@api_token.touch(:last_v2_authenticated_at)
@current_user = @api_token.administrateur.user
Current.user = @current_user
end
end
end

View file

@ -79,9 +79,16 @@ module Connections
end
def load_nodes_deprecated_order(limit, inverted)
payload = {
message: "CursorConnection: using deprecated order [#{Current.user.email}]",
user_id: Current.user.id
}
logger = Lograge.logger || Rails.logger
logger.info payload.to_json
expected_size = limit - 1
if @deprecated_order == :desc && before.nil?
if before.nil?
inverted = !inverted
end

View file

@ -201,6 +201,9 @@ describe API::V2::GraphqlController do
let(:end_cursor) { cursor_for(dossier2, order_column) }
it {
allow(Rails.logger).to receive(:info)
expect(Rails.logger).to receive(:info).with("{\"message\":\"CursorConnection: using deprecated order [#{admin.email}]\",\"user_id\":#{admin.user.id}}")
expect(gql_errors).to be_nil
expect(gql_data[:demarche][:dossiers][:nodes].size).to eq(2)
expect(gql_data[:demarche][:dossiers][:pageInfo][:hasNextPage]).to be_truthy
@ -216,6 +219,9 @@ describe API::V2::GraphqlController do
let(:end_cursor) { cursor_for(dossier, order_column) }
it {
allow(Rails.logger).to receive(:info)
expect(Rails.logger).to receive(:info).with("{\"message\":\"CursorConnection: using deprecated order [#{admin.email}]\",\"user_id\":#{admin.user.id}}")
expect(gql_errors).to be_nil
expect(gql_data[:demarche][:dossiers][:nodes].size).to eq(2)
expect(gql_data[:demarche][:dossiers][:pageInfo][:hasNextPage]).to be_falsey
@ -232,6 +238,9 @@ describe API::V2::GraphqlController do
let(:end_cursor) { cursor_for(dossier2, order_column) }
it {
allow(Rails.logger).to receive(:info)
expect(Rails.logger).to receive(:info).with("{\"message\":\"CursorConnection: using deprecated order [#{admin.email}]\",\"user_id\":#{admin.user.id}}")
expect(gql_errors).to be_nil
expect(gql_data[:demarche][:dossiers][:nodes].size).to eq(2)
expect(gql_data[:demarche][:dossiers][:pageInfo][:hasNextPage]).to be_truthy