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
: GraphQL::StaticValidation::ValidationContext.
Class Method Summary collapse
-
.including_rules(rules) ⇒ Object
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
: (GraphQL::Language::Nodes::Document document, GraphQL::StaticValidation::ValidationContext context) -> void.
-
#path ⇒ Object
Returns.
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
: (GraphQL::Language::Nodes::Document document, GraphQL::StaticValidation::ValidationContext context) -> void
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/graphql/static_validation/base_visitor.rb', line 8 def initialize(document, context) @path = [] #: Array[String | Integer] @path_depth = 0 #: Integer @current_object_type = nil #: GraphQL::Schema::Member::type_definition? @parent_object_type = nil #: GraphQL::Schema::Member::type_definition? @current_field_definition = nil #: GraphQL::Schema::Field? @current_argument_definition = nil #: GraphQL::Schema::Argument? @parent_argument_definition = nil #: GraphQL::Schema::Argument? @current_directive_definition = nil #: singleton(GraphQL::Schema::Directive)? @context = context #: GraphQL::StaticValidation::ValidationContext @types = context.types #: GraphQL::Schema::Visibility::Profile | GraphQL::Schema::Warden::VisibilityProfile @schema = context.schema #: singleton(GraphQL::Schema) @inline_fragment_paths = {} #: Hash[String, String] @field_unwrapped_types = {}.compare_by_identity #: Hash[GraphQL::Schema::Field, GraphQL::Schema::Member::type_definition] @child_positions = {}.compare_by_identity #: Hash[GraphQL::Language::Nodes::AbstractNode, Hash[GraphQL::Language::Nodes::AbstractNode, Integer]] super(document) end |
Instance Attribute Details
#context ⇒ Object (readonly)
: GraphQL::StaticValidation::ValidationContext
27 28 29 |
# File 'lib/graphql/static_validation/base_visitor.rb', line 27 def context @context end |
Class Method Details
.including_rules(rules) ⇒ Object
Build a class to visit the AST and perform validation,
or use a pre-built class if rules is ALL_RULES or empty.
Parameters
rules(Array<Module, Class>)
Returns
Class— A class for validatingrulesduring visitation
:call-seq:
including_rules(Array[Module | Class] rules) -> Class
: (Array[Module[untyped]]) -> singleton(GraphQL::StaticValidation::BaseVisitor)
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/graphql/static_validation/base_visitor.rb', line 54 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 ⇒ Object
Returns
Array<String>— The nesting of the current position in the AST
:call-seq:
path() -> Array[String]
: () -> Array[String | Integer]
36 37 38 |
# File 'lib/graphql/static_validation/base_visitor.rb', line 36 def path @path[0, @path_depth] #: as !nil end |