class GraphQL::Language::Nodes::InputObject

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

Attributes

arguments[RW]
children[RW]

Public Instance Methods

initialize_node(arguments: []) click to toggle source

@!attribute arguments

@return [Array<Nodes::Argument>] A list of key-value pairs inside this input object
# File lib/graphql/language/nodes.rb, line 284
def initialize_node(arguments: [])
  @arguments = arguments
end
to_h(options={}) click to toggle source

@return [Hash<String, Any>] Recursively turn this input object into a Ruby Hash

# File lib/graphql/language/nodes.rb, line 289
def to_h(options={})
  arguments.inject({}) do |memo, pair|
    v = pair.value
    memo[pair.name] = serialize_value_for_hash v
    memo
  end
end

Private Instance Methods

serialize_value_for_hash(value) click to toggle source
# File lib/graphql/language/nodes.rb, line 299
def serialize_value_for_hash(value)
  case value
  when InputObject
    value.to_h
  when Array
    value.map do |v|
      serialize_value_for_hash v
    end
  when Enum
    value.name
  when NullValue
    nil
  else
    value
  end
end