Class: GraphQL::Analysis::MaxQueryDepth
- Inherits:
-
QueryDepth
- Object
- QueryDepth
- GraphQL::Analysis::MaxQueryDepth
- Defined in:
- lib/graphql/analysis/max_query_depth.rb
Overview
Used under the hood to implement depth validation, see Schema#max_depth and Query#max_depth
Instance Method Summary collapse
-
#initialize(max_depth) ⇒ MaxQueryDepth
constructor
A new instance of MaxQueryDepth.
Methods inherited from QueryDepth
#call, #final_value, #initial_value
Constructor Details
#initialize(max_depth) ⇒ MaxQueryDepth
Returns a new instance of MaxQueryDepth
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/graphql/analysis/max_query_depth.rb', line 14 def initialize(max_depth) disallow_excessive_depth = ->(query, depth) { if depth > max_depth GraphQL::AnalysisError.new("Query has depth of #{depth}, which exceeds max depth of #{max_depth}") else nil end } super(&disallow_excessive_depth) end |