Method: GraphQL::Analysis::QueryComplexity#initial_value

Defined in:
lib/graphql/analysis/query_complexity.rb

#initial_value(query) ⇒ Object

State for the query complexity calcuation:

  • query is needed for variables, then passed to handler

  • complexities_on_type holds complexity scores for each type in an IRep node

  • skip_depth increments for each skipped node, then decrements on the way out. While it’s greater than 0, we’re visiting a skipped part of the query.



23
24
25
26
27
28
29
# File 'lib/graphql/analysis/query_complexity.rb', line 23

def initial_value(query)
  {
    query: query,
    complexities_on_type: [TypeComplexity.new],
    skip_depth: 0,
  }
end