diff --git a/app/graphql/api/v2/context.rb b/app/graphql/api/v2/context.rb index 29613314f..e83a3c8ff 100644 --- a/app/graphql/api/v2/context.rb +++ b/app/graphql/api/v2/context.rb @@ -59,6 +59,7 @@ class API::V2::Context < GraphQL::Query::Context { graphql_query: query.query_string, graphql_variables: query.provided_variables&.to_json, + graphql_mutation: mutation?, graphql_null_error: errors.any? { _1.is_a? GraphQL::InvalidNullError }.presence, graphql_timeout_error: errors.any? { _1.is_a? GraphQL::Schema::Timeout::TimeoutError }.presence }.compact @@ -66,6 +67,12 @@ class API::V2::Context < GraphQL::Query::Context private + def mutation? + query.lookahead.selections.any? { _1.field.type.respond_to?(:mutation) }.presence + rescue + false + end + def compute_demarche_authorization(demarche) # procedure_ids and token are passed from graphql controller if self[:procedure_ids].present? diff --git a/config/initializers/lograge.rb b/config/initializers/lograge.rb index 40cd8c01a..b5795fde2 100644 --- a/config/initializers/lograge.rb +++ b/config/initializers/lograge.rb @@ -18,6 +18,7 @@ Rails.application.configure do graphql_variables: event.payload[:graphql_variables], graphql_null_error: event.payload[:graphql_null_error], graphql_timeout_error: event.payload[:graphql_timeout_error], + graphql_mutation: event.payload[:graphql_mutation], ds_procedure_id: event.payload[:ds_procedure_id], ds_dossier_id: event.payload[:ds_dossier_id], browser: event.payload[:browser],