Class: GraphQL::Analysis::Analyzer
- Inherits:
-
Object
- Object
- GraphQL::Analysis::Analyzer
- Defined in:
- lib/graphql/analysis/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.
Parameters
The(GraphQL::Query, GraphQL::Execution::Multiplex) — query or multiplex to analyze
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 ⇒ Object
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.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/graphql/analysis/analyzer.rb', line 16 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.
Returns
Boolean— If the query should be analyzed or not
:call-seq:
analyze?() -> bool
37 38 39 |
# File 'lib/graphql/analysis/analyzer.rb', line 37 def analyze? true end |
#result ⇒ Object
The result for this analyzer. Returning GraphQL::AnalysisError results in a query error.
Returns
Any— The analyzer result
:call-seq:
result() -> Any
63 64 65 |
# File 'lib/graphql/analysis/analyzer.rb', line 63 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.
Returns
Boolean— If analysis requires visitation or not
:call-seq:
visit?() -> bool
50 51 52 |
# File 'lib/graphql/analysis/analyzer.rb', line 50 def visit? true end |