Class: GraphQL::Analysis::AST::MaxQueryComplexity
- Inherits:
-
QueryComplexity
- Object
- Analyzer
- QueryComplexity
- GraphQL::Analysis::AST::MaxQueryComplexity
- Defined in:
- lib/graphql/analysis/ast/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
Methods inherited from QueryComplexity
#initialize, #on_enter_field, #on_enter_fragment_spread, #on_leave_field, #on_leave_fragment_spread
Methods inherited from Analyzer
#analyze?, build_visitor_hooks, #initialize
Constructor Details
This class inherits a constructor from GraphQL::Analysis::AST::QueryComplexity
Instance Method Details
#result ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/graphql/analysis/ast/max_query_complexity.rb', line 9 def result return if query.max_complexity.nil? total_complexity = super if total_complexity > query.max_complexity GraphQL::AnalysisError.new("Query has complexity of #{total_complexity}, which exceeds max complexity of #{query.max_complexity}") else nil end end |