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