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



96
97
98
99
# File 'lib/graphql/static_validation/type_stack.rb', line 96

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

#push(stack, node) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/graphql/static_validation/type_stack.rb', line 78

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 = stack.schema.get_field(parent_type, 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