Class: GraphQL::Analysis::AST::Analyzer
- Inherits:
-
Object
- Object
- GraphQL::Analysis::AST::Analyzer
- Defined in:
- lib/graphql/analysis/ast/analyzer.rb
Overview
Query analyzer for query ASTs. Query analyzers respond to visitor style methods
but are prefixed by enter
and leave
.
When an analyzer is initialized with a Multiplex, you can always get the current query from
visitor.query
in the visit methods.
Direct Known Subclasses
FieldUsage, QueryComplexity, QueryDepth, Subscriptions::BroadcastAnalyzer
Instance Method Summary collapse
-
#analyze? ⇒ Boolean
Analyzer hook to decide at analysis time whether a query should be analyzed or not.
-
#initialize(subject) ⇒ Analyzer
constructor
A new instance of Analyzer.
-
#result ⇒ Any
The result for this analyzer.
-
#visit? ⇒ Boolean
Analyzer hook to decide at analysis time whether analysis requires a visitor pass; can be disabled for precomputed results.
Constructor Details
#initialize(subject) ⇒ Analyzer
Returns a new instance of Analyzer.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/graphql/analysis/ast/analyzer.rb', line 13 def initialize(subject) @subject = subject if subject.is_a?(GraphQL::Query) @query = subject @multiplex = nil else @multiplex = subject @query = nil end end |
Instance Method Details
#analyze? ⇒ Boolean
Analyzer hook to decide at analysis time whether a query should be analyzed or not.
28 29 30 |
# File 'lib/graphql/analysis/ast/analyzer.rb', line 28 def analyze? true end |
#result ⇒ Any
The result for this analyzer. Returning GraphQL::AnalysisError results in a query error.
42 43 44 |
# File 'lib/graphql/analysis/ast/analyzer.rb', line 42 def result raise GraphQL::RequiredImplementationMissingError end |
#visit? ⇒ Boolean
Analyzer hook to decide at analysis time whether analysis requires a visitor pass; can be disabled for precomputed results.
35 36 37 |
# File 'lib/graphql/analysis/ast/analyzer.rb', line 35 def visit? true end |