Class: GraphQL::Language::OperationDefinition

Inherits:
Struct
  • Object
show all
Defined in:
lib/graphql/language/operation_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#directivesObject

Returns the value of attribute directives

Returns:

  • (Object)

    the current value of directives



3
4
5
# File 'lib/graphql/language/operation_definition.rb', line 3

def directives
  @directives
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



3
4
5
# File 'lib/graphql/language/operation_definition.rb', line 3

def name
  @name
end

#selection_setObject

Returns the value of attribute selection_set

Returns:

  • (Object)

    the current value of selection_set



3
4
5
# File 'lib/graphql/language/operation_definition.rb', line 3

def selection_set
  @selection_set
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



3
4
5
# File 'lib/graphql/language/operation_definition.rb', line 3

def type
  @type
end

#variable_definitionsObject

Returns the value of attribute variable_definitions

Returns:

  • (Object)

    the current value of variable_definitions



3
4
5
# File 'lib/graphql/language/operation_definition.rb', line 3

def variable_definitions
  @variable_definitions
end

Instance Method Details

#evaluate(context) ⇒ Object



6
7
8
9
# File 'lib/graphql/language/operation_definition.rb', line 6

def evaluate(context)
  context[:variables] = materialize_variables(context[:schema], context[:params])
  type == 'mutation' ? execute_serially(context) : execute(context)
end

#execute(context) ⇒ Object



12
13
14
# File 'lib/graphql/language/operation_definition.rb', line 12

def execute(context)
  selection_set.evaluate(context, context[:schema].query_type, context[:root])
end

#execute_serially(context) ⇒ Object



17
18
19
# File 'lib/graphql/language/operation_definition.rb', line 17

def execute_serially(context)
  raise "Not implemented. Yet."
end

#materialize_variables(schema, params) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/graphql/language/operation_definition.rb', line 22

def materialize_variables(schema, params)
  variable_definitions.reduce({}) do |memo, variable_definition|
    name = variable_definition.variable.name.to_sym
    memo[name] = variable_definition.materialize(schema, params[name])
    memo
  end
end