Class: GraphQL::Language::Nodes::InputObject

Inherits:
AbstractNode show all
Defined in:
lib/graphql/language/nodes.rb

Overview

A collection of key-value inputs which may be a field argument

Instance Attribute Summary collapse

Attributes inherited from AbstractNode

#col, #line

Instance Method Summary collapse

Methods inherited from AbstractNode

child_attributes, #children, #eql?, inherited, #initialize, #position, scalar_attributes, #scalars, #to_query_string

Constructor Details

This class inherits a constructor from GraphQL::Language::Nodes::AbstractNode

Instance Attribute Details

#argumentsArray<Nodes::Argument>

Returns A list of key-value pairs inside this input object

Returns:

  • (Array<Nodes::Argument>)

    A list of key-value pairs inside this input object


262
263
264
# File 'lib/graphql/language/nodes.rb', line 262

def arguments
  @arguments
end

Instance Method Details

#initialize_node(arguments: []) ⇒ Object


262
263
264
# File 'lib/graphql/language/nodes.rb', line 262

def initialize_node(arguments: [])
  @arguments = arguments
end

#to_h(options = {}) ⇒ Hash<String, Any>

Returns Recursively turn this input object into a Ruby Hash

Returns:

  • (Hash<String, Any>)

    Recursively turn this input object into a Ruby Hash


267
268
269
270
271
272
273
# File 'lib/graphql/language/nodes.rb', line 267

def to_h(options={})
  arguments.inject({}) do |memo, pair|
    v = pair.value
    memo[pair.name] = v.is_a?(InputObject) ? v.to_h : v
    memo
  end
end