Class: Graphql::LogHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/log_helper.rb,
lib/graphql/log_helper/version.rb

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.log_details(request_params) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/graphql/log_helper.rb', line 9

def log_details(request_params)
  selections = parse_query(request_params[:query])&.definitions&.first&.selections
  return {} if selections.blank?

  query_params =
    if request_params[:variables].present?
      query_params_given_variables(selections, request_params[:variables])
    else
      query_params_given_no_variables(selections)
    end

  {
    params: to_deep_a(query_params),
    resolvers: resolver_names(selections)
  }
end