Class: GraphQL::StaticValidation::TypeStack::FieldStrategy

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

Instance Method Summary collapse

Instance Method Details

#pop(stack, node) ⇒ Object



121
122
123
124
125
# File 'lib/graphql/static_validation/type_stack.rb', line 121

def pop(stack, node)
  stack.field_definitions.pop
  stack.object_types.pop
  stack.path.pop
end

#push(stack, node) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/graphql/static_validation/type_stack.rb', line 106

def push(stack, node)
  parent_type = stack.object_types.last
  parent_type = parent_type.unwrap

  field_definition = stack.schema.get_field(parent_type, node.name)
  stack.field_definitions.push(field_definition)
  if !field_definition.nil?
    next_object_type = field_definition.type
    stack.object_types.push(next_object_type)
  else
    stack.object_types.push(nil)
  end
  stack.path.push(node.alias || node.name)
end