class GraphQL::Analysis::AST::Analyzer
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.
@param [GraphQL::Query, GraphQL::Execution::Multiplex] The query or multiplex to analyze
Attributes
@return [GraphQL::Execution::Multiplex, nil] `nil` if this analyzer is visiting a query
@return [GraphQL::Query, nil] `nil` if this analyzer is visiting a multiplex
(When this is `nil`, use `visitor.query` inside visit methods to get the current query)
@return [GraphQL::Query, GraphQL::Execution::Multiplex] Whatever this analyzer is analyzing
Public Class Methods
# 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
Private Class Methods
# File lib/graphql/analysis/ast/analyzer.rb, line 42 def build_visitor_hooks(member_name) class_eval(<<-EOS, __FILE__, __LINE__ + 1) def on_enter_#{member_name}(node, parent, visitor) end def on_leave_#{member_name}(node, parent, visitor) end EOS end
Public Instance Methods
Analyzer
hook to decide at analysis time whether a query should be analyzed or not. @return [Boolean] If the query should be analyzed or not
# File lib/graphql/analysis/ast/analyzer.rb, line 28 def analyze? true end
The result for this analyzer. Returning {GraphQL::AnalysisError} results in a query error. @return [Any] The analyzer result
# File lib/graphql/analysis/ast/analyzer.rb, line 35 def result raise GraphQL::RequiredImplementationMissingError end