feat(graphql): add mutation flag to lograge

This commit is contained in:
Paul Chavard 2023-08-02 10:54:03 +02:00
parent bb100c610f
commit b404064d3b
2 changed files with 8 additions and 0 deletions

View file

@ -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?

View file

@ -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],