Class: GraphQL::StaticValidation::TypeStack

Inherits:
Object
  • Object
show all
Defined in:
lib/graph_ql/static_validation/type_stack.rb

Overview

  • Ride along with ‘GraphQL::Visitor`

  • Track type info, expose it to validators

Defined Under Namespace

Classes: DirectiveStrategy, FieldStrategy, FragmentDefinitionStrategy, FragmentWithTypeStrategy, InlineFragmentStrategy, NullStrategy, OperationDefinitionStrategy

Constant Summary collapse

TYPE_INFERRENCE_ROOTS =

These are jumping-off points for infering types down the tree

[
  GraphQL::Nodes::OperationDefinition,
  GraphQL::Nodes::FragmentDefinition,
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema, visitor) ⇒ TypeStack

Returns a new instance of TypeStack.



11
12
13
14
15
16
17
18
# File 'lib/graph_ql/static_validation/type_stack.rb', line 11

def initialize(schema, visitor)
  @schema = schema
  @object_types = []
  @field_definitions = []
  @directive_definitions = []
  visitor.enter << -> (node, parent) { PUSH_STRATEGIES[node.class].push(self, node) }
  visitor.leave << -> (node, parent) { PUSH_STRATEGIES[node.class].pop(self, node) }
end

Instance Attribute Details

#directive_definitionsObject (readonly)

Returns the value of attribute directive_definitions.



10
11
12
# File 'lib/graph_ql/static_validation/type_stack.rb', line 10

def directive_definitions
  @directive_definitions
end

#field_definitionsObject (readonly)

Returns the value of attribute field_definitions.



10
11
12
# File 'lib/graph_ql/static_validation/type_stack.rb', line 10

def field_definitions
  @field_definitions
end

#object_typesObject (readonly)

Returns the value of attribute object_types.



10
11
12
# File 'lib/graph_ql/static_validation/type_stack.rb', line 10

def object_types
  @object_types
end

#schemaObject (readonly)

Returns the value of attribute schema.



10
11
12
# File 'lib/graph_ql/static_validation/type_stack.rb', line 10

def schema
  @schema
end