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

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

Instance Method Summary collapse

Instance Method Details

#pop(stack, node) ⇒ Object



77
78
79
80
# File 'lib/graph_ql/static_validation/type_stack.rb', line 77

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

#push(stack, node) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/graph_ql/static_validation/type_stack.rb', line 59

def push(stack, node)
  parent_type = stack.object_types.last
  parent_type = parent_type.kind.unwrap(parent_type)
  if parent_type.kind.fields?
    field_class = parent_type.fields[node.name]
    stack.field_definitions.push(field_class)
    if !field_class.nil?
      next_object_type = field_class.type
      stack.object_types.push(next_object_type)
    else
      stack.object_types.push(nil)
    end
  else
    stack.field_definitions.push(nil)
    stack.object_types.push(parent_type)
  end
end