Module: GraphQL::Dig

Included in:
Execution::Interpreter::Arguments, Query::Arguments, Schema::InputObject
Defined in:
lib/graphql/dig.rb

Instance Method Summary collapse

Instance Method Details

#dig(own_key, *rest_keys) ⇒ Object

implemented using the old activesupport #dig instead of the ruby built-in so we can use some of the magic in Schema::InputObject and Query::Arguments to handle stringified/symbolized keys.

Parameters:

  • args (Array<[String, Symbol>] Retrieves the value object corresponding to the each key objects repeatedly)

    rgs [Array<[String, Symbol>] Retrieves the value object corresponding to the each key objects repeatedly

Returns:

  • (Object)

10
11
12
13
14
15
16
17
# File 'lib/graphql/dig.rb', line 10

def dig(own_key, *rest_keys)
  val = self[own_key]
  if val.nil? || rest_keys.empty?
    val
  else
    val.dig(*rest_keys)
  end
end