Class: GraphQL::StaticValidation::BaseVisitor
- Inherits:
-
Language::StaticVisitor
- Object
- Language::StaticVisitor
- GraphQL::StaticValidation::BaseVisitor
- Defined in:
- lib/graphql/static_validation/base_visitor.rb
Direct Known Subclasses
Defined Under Namespace
Modules: ContextMethods
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Class Method Summary collapse
-
.including_rules(rules) ⇒ Class
Build a class to visit the AST and perform validation, or use a pre-built class if rules is
ALL_RULESor empty.
Instance Method Summary collapse
-
#initialize(document, context) ⇒ BaseVisitor
constructor
A new instance of BaseVisitor.
-
#path ⇒ Array<String>
The nesting of the current position in the AST.
Methods inherited from Language::StaticVisitor
make_visit_methods, #on_argument_children, #on_document_children, #on_field_children, #on_fragment_definition_children, #on_operation_definition_children, #visit, #visit_directives, #visit_selections
Constructor Details
#initialize(document, context) ⇒ BaseVisitor
Returns a new instance of BaseVisitor.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/graphql/static_validation/base_visitor.rb', line 5 def initialize(document, context) @path = [] @path_depth = 0 @current_object_type = nil @parent_object_type = nil @current_field_definition = nil @current_argument_definition = nil @parent_argument_definition = nil @current_directive_definition = nil @context = context @types = context.query.types @schema = context.schema @inline_fragment_paths = {} @field_unwrapped_types = {}.compare_by_identity super(document) end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
22 23 24 |
# File 'lib/graphql/static_validation/base_visitor.rb', line 22 def context @context end |
Class Method Details
.including_rules(rules) ⇒ Class
Build a class to visit the AST and perform validation,
or use a pre-built class if rules is ALL_RULES or empty.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/graphql/static_validation/base_visitor.rb', line 33 def self.including_rules(rules) if rules.empty? # It's not doing _anything?!?_ BaseVisitor elsif rules == ALL_RULES InterpreterVisitor else visitor_class = Class.new(self) do include(GraphQL::StaticValidation::DefinitionDependencies) end rules.reverse_each do |r| # If it's a class, it gets attached later. if !r.is_a?(Class) visitor_class.include(r) end end visitor_class.include(ContextMethods) visitor_class end end |
Instance Method Details
#path ⇒ Array<String>
Returns The nesting of the current position in the AST.
25 26 27 |
# File 'lib/graphql/static_validation/base_visitor.rb', line 25 def path @path[0, @path_depth] end |