Class: GraphQL::Query::Variables

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/query/variables.rb

Overview

Read-only access to query variables, applying default values if needed.

Instance Method Summary collapse

Constructor Details

#initialize(schema, ast_variables, provided_variables) ⇒ Variables

Returns a new instance of Variables.



5
6
7
8
9
10
11
12
# File 'lib/graphql/query/variables.rb', line 5

def initialize(schema, ast_variables, provided_variables)
  @schema = schema
  @provided_variables = provided_variables
  @storage = ast_variables.each_with_object({}) do |ast_variable, memo|
    variable_name = ast_variable.name
    memo[variable_name] = get_graphql_value(ast_variable)
  end
end

Instance Method Details

#[](key) ⇒ Object



14
15
16
# File 'lib/graphql/query/variables.rb', line 14

def [](key)
  @storage.fetch(key)
end