Class: GraphQL::Analysis::AST::MaxQueryDepth

Inherits:
QueryDepth show all
Defined in:
lib/graphql/analysis/ast/max_query_depth.rb

Instance Method Summary collapse

Methods inherited from QueryDepth

#initialize, #on_enter_field, #on_leave_field

Methods inherited from Analyzer

#analyze?, #initialize, #visit?

Constructor Details

This class inherits a constructor from GraphQL::Analysis::AST::QueryDepth

Instance Method Details

#resultObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/graphql/analysis/ast/max_query_depth.rb', line 6

def result
  configured_max_depth = if query
    query.max_depth
  else
    multiplex.schema.max_depth
  end

  if configured_max_depth && @max_depth > configured_max_depth
    GraphQL::AnalysisError.new("Query has depth of #{@max_depth}, which exceeds max depth of #{configured_max_depth}")
  else
    nil
  end
end