Class: GraphQL::StaticValidation::BaseVisitor
- Inherits:
- 
      Language::Visitor
      
        - Object
- Language::Visitor
- GraphQL::StaticValidation::BaseVisitor
 
- Defined in:
- lib/graphql/static_validation/base_visitor.rb
Direct Known Subclasses
Defined Under Namespace
Modules: ContextMethods
Constant Summary
Constants inherited from Language::Visitor
Language::Visitor::DELETE_NODE, Language::Visitor::SKIP
Instance Attribute Summary collapse
- 
  
    
      #context  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute context. 
- 
  
    
      #object_types  ⇒ Array<GraphQL::ObjectType> 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Types whose scope we’ve entered. 
Attributes inherited from Language::Visitor
Class Method Summary collapse
- 
  
    
      .including_rules(rules, rewrite: true)  ⇒ 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. 
- 
  
    
      #rewrite_document  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    This will be overwritten by InternalRepresentation::Rewrite if it’s included. 
Methods inherited from Language::Visitor
#[], make_visit_method, #on_abstract_node, #visit, #visit_node
Constructor Details
#initialize(document, context) ⇒ BaseVisitor
Returns a new instance of BaseVisitor.
| 5 6 7 8 9 10 11 12 13 14 15 | # File 'lib/graphql/static_validation/base_visitor.rb', line 5 def initialize(document, context) @path = [] @object_types = [] @directives = [] @field_definitions = [] @argument_definitions = [] @directive_definitions = [] @context = context @schema = context.schema 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 | 
#object_types ⇒ Array<GraphQL::ObjectType> (readonly)
Returns Types whose scope we’ve entered.
| 25 26 27 | # File 'lib/graphql/static_validation/base_visitor.rb', line 25 def object_types @object_types end | 
Class Method Details
.including_rules(rules, rewrite: true) ⇒ Class
Build a class to visit the AST and perform validation,
or use a pre-built class if rules is ALL_RULES or empty.
| 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | # File 'lib/graphql/static_validation/base_visitor.rb', line 37 def self.including_rules(rules, rewrite: true) if rules.empty? if rewrite NoValidateVisitor else # It's not doing _anything?!?_ BaseVisitor end elsif rules == ALL_RULES if rewrite DefaultVisitor else InterpreterVisitor end 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 if rewrite visitor_class.include(GraphQL::InternalRepresentation::Rewrite) 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.
| 28 29 30 | # File 'lib/graphql/static_validation/base_visitor.rb', line 28 def path @path.dup end | 
#rewrite_document ⇒ Object
This will be overwritten by InternalRepresentation::Rewrite if it’s included
| 18 19 20 | # File 'lib/graphql/static_validation/base_visitor.rb', line 18 def rewrite_document nil end |