class GraphQL::Execution::Interpreter::Arguments
A wrapper for argument hashes in GraphQL queries.
This object is immutable so that the runtime code can be sure that modifications don’t leak from one use to another
See GraphQL::Query#arguments_for to get access to these objects.
Constants
- EMPTY
- NO_ARGS
Attributes
Returns
-
Hash{Symbol => ArgumentValue}
The Ruby-style arguments hash, ready for a resolver. This hash is the one used at runtime.
Returns
-
Hash<Symbol, Object>
Public Class Methods
# File lib/graphql/execution/interpreter/arguments.rb, line 32 def initialize(keyword_arguments: nil, argument_values:) @empty = argument_values.nil? || argument_values.empty? # This is only present when `extras` have been merged in: if keyword_arguments # This is a little crazy. We expect the `:argument_details` extra to _include extras_, # but the object isn't created until _after_ extras are put together. # So, we have to use a special flag here to say, "at the last minute, add yourself to the keyword args." # # Otherwise: # - We can't access the final Arguments instance _while_ we're preparing extras # - After we _can_ access it, it's frozen, so we can't add anything. # # So, this flag gives us a chance to sneak it in before freezing, _and_ while we have access # to the new Arguments instance itself. if keyword_arguments[:argument_details] == :__arguments_add_self keyword_arguments[:argument_details] = self end @keyword_arguments = keyword_arguments.freeze elsif !@empty @keyword_arguments = {} argument_values.each do |name, arg_val| @keyword_arguments[name] = arg_val.value end @keyword_arguments.freeze else @keyword_arguments = NO_ARGS end @argument_values = argument_values ? argument_values.freeze : NO_ARGS freeze end
Parameters
-
argument_values(nil, Hash{Symbol => ArgumentValue}) -
keyword_arguments(nil, Hash{Symbol => Object})
Public Instance Methods
Source
# File lib/graphql/execution/interpreter/arguments.rb, line 68 def empty? @empty end
Source
# File lib/graphql/execution/interpreter/arguments.rb, line 75 def inspect "#<#{self.class} @keyword_arguments=#{keyword_arguments.inspect}>" end