Class: GraphQL::Execution::Interpreter::Arguments

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Dig
Defined in:
lib/graphql/execution/interpreter/arguments.rb

Overview

A wrapper for argument hashes in GraphQL queries.

Instance Method Summary collapse

Methods included from Dig

#dig

Constructor Details

#initialize(argument_values:) ⇒ Arguments

Returns a new instance of Arguments.

Parameters:



28
29
30
31
# File 'lib/graphql/execution/interpreter/arguments.rb', line 28

def initialize(argument_values:)
  @argument_values = argument_values
  @empty = argument_values.nil? || argument_values.empty?
end

Instance Method Details

#argument_valuesHash{Symbol => ArgumentValue}

Returns:



34
35
36
# File 'lib/graphql/execution/interpreter/arguments.rb', line 34

def argument_values
  @argument_values ||= {}
end

#empty?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/graphql/execution/interpreter/arguments.rb', line 38

def empty?
  @empty
end

#inspectObject



45
46
47
# File 'lib/graphql/execution/interpreter/arguments.rb', line 45

def inspect
  "#<#{self.class} @keyword_arguments=#{keyword_arguments.inspect}>"
end

#keyword_argumentsHash<Symbol, Object>

The Ruby-style arguments hash, ready for a resolver. This hash is the one used at runtime.

Returns:

  • (Hash<Symbol, Object>)


17
18
19
20
21
22
23
24
25
# File 'lib/graphql/execution/interpreter/arguments.rb', line 17

def keyword_arguments
  @keyword_arguments ||= begin
    kwargs = {}
    argument_values.each do |name, arg_val|
      kwargs[name] = arg_val.value
    end
    kwargs
  end
end