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