Class: GraphQL::StaticValidation::TypeStack
- Inherits:
-
Object
- Object
- GraphQL::StaticValidation::TypeStack
- Defined in:
- lib/graphql/static_validation/type_stack.rb
Overview
- Ride along with
GraphQL::Language::Visitor
- Track type info, expose it to validators
Defined Under Namespace
Modules: ArgumentStrategy, DirectiveStrategy, FieldStrategy, FragmentDefinitionStrategy, FragmentSpreadStrategy, FragmentWithTypeStrategy, InlineFragmentStrategy, OperationDefinitionStrategy Classes: EnterWithStrategy, LeaveWithStrategy
Constant Summary collapse
- TYPE_INFERRENCE_ROOTS =
These are jumping-off points for infering types down the tree
[ GraphQL::Language::Nodes::OperationDefinition, GraphQL::Language::Nodes::FragmentDefinition, ]
Instance Attribute Summary collapse
-
#argument_definitions ⇒ Array<GraphQL::Node::Argument>
readonly
Arguments which have been entered.
-
#directive_definitions ⇒ Array<GraphQL::Node::Directive>
readonly
Directives are pushed on, then popped off while traversing the tree.
-
#field_definitions ⇒ Array<GraphQL::Field>
readonly
When it enters a field, it’s pushed on this stack (useful for nested fields, args).
-
#object_types ⇒ Array<GraphQL::ObjectType, GraphQL::Union, GraphQL::Interface>
readonly
When it enters an object (starting with query or mutation root), it’s pushed on this stack.
-
#path ⇒ Array<String>
readonly
Fields which have been entered (by their AST name).
-
#schema ⇒ GraphQL::Schema
readonly
The schema whose types are present in this document.
Instance Method Summary collapse
-
#initialize(schema, visitor) ⇒ TypeStack
constructor
A new instance of TypeStack.
Constructor Details
#initialize(schema, visitor) ⇒ TypeStack
Returns a new instance of TypeStack
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/graphql/static_validation/type_stack.rb', line 38 def initialize(schema, visitor) @schema = schema @object_types = [] @field_definitions = [] @directive_definitions = [] @argument_definitions = [] @path = [] PUSH_STRATEGIES.each do |node_class, strategy| visitor[node_class].enter << EnterWithStrategy.new(self, strategy) visitor[node_class].leave << LeaveWithStrategy.new(self, strategy) end end |
Instance Attribute Details
#argument_definitions ⇒ Array<GraphQL::Node::Argument> (readonly)
Returns arguments which have been entered
31 32 33 |
# File 'lib/graphql/static_validation/type_stack.rb', line 31 def argument_definitions @argument_definitions end |
#directive_definitions ⇒ Array<GraphQL::Node::Directive> (readonly)
Directives are pushed on, then popped off while traversing the tree
28 29 30 |
# File 'lib/graphql/static_validation/type_stack.rb', line 28 def directive_definitions @directive_definitions end |
#field_definitions ⇒ Array<GraphQL::Field> (readonly)
When it enters a field, it’s pushed on this stack (useful for nested fields, args). When it exits, it’s popped off.
24 25 26 |
# File 'lib/graphql/static_validation/type_stack.rb', line 24 def field_definitions @field_definitions end |
#object_types ⇒ Array<GraphQL::ObjectType, GraphQL::Union, GraphQL::Interface> (readonly)
When it enters an object (starting with query or mutation root), it’s pushed on this stack. When it exits, it’s popped off.
19 20 21 |
# File 'lib/graphql/static_validation/type_stack.rb', line 19 def object_types @object_types end |
#path ⇒ Array<String> (readonly)
Returns fields which have been entered (by their AST name)
34 35 36 |
# File 'lib/graphql/static_validation/type_stack.rb', line 34 def path @path end |
#schema ⇒ GraphQL::Schema (readonly)
Returns the schema whose types are present in this document
14 15 16 |
# File 'lib/graphql/static_validation/type_stack.rb', line 14 def schema @schema end |