Class: GraphQL::Query::SerialExecution::ExecutionContext

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query, strategy) ⇒ ExecutionContext

Returns a new instance of ExecutionContext


7
8
9
10
11
# File 'lib/graphql/query/serial_execution/execution_context.rb', line 7

def initialize(query, strategy)
  @query = query
  @schema = query.schema
  @strategy = strategy
end

Instance Attribute Details

#queryObject (readonly)

Returns the value of attribute query


5
6
7
# File 'lib/graphql/query/serial_execution/execution_context.rb', line 5

def query
  @query
end

#schemaObject (readonly)

Returns the value of attribute schema


5
6
7
# File 'lib/graphql/query/serial_execution/execution_context.rb', line 5

def schema
  @schema
end

#strategyObject (readonly)

Returns the value of attribute strategy


5
6
7
# File 'lib/graphql/query/serial_execution/execution_context.rb', line 5

def strategy
  @strategy
end

Instance Method Details

#add_error(err) ⇒ Object


26
27
28
# File 'lib/graphql/query/serial_execution/execution_context.rb', line 26

def add_error(err)
  @query.context.errors << err
end

#get_field(type, irep_node) ⇒ Object


21
22
23
24
# File 'lib/graphql/query/serial_execution/execution_context.rb', line 21

def get_field(type, irep_node)
  # fall back for dynamic fields (eg __typename)
  irep_node.definitions[type] || @schema.get_field(type, irep_node.definition_name) || raise("No field found on #{type.name} for '#{irep_node.definition_name}' (#{irep_node.ast_node.name})")
end

#get_fragment(name) ⇒ Object


17
18
19
# File 'lib/graphql/query/serial_execution/execution_context.rb', line 17

def get_fragment(name)
  @query.fragments[name]
end

#get_type(type) ⇒ Object


13
14
15
# File 'lib/graphql/query/serial_execution/execution_context.rb', line 13

def get_type(type)
  @schema.types[type]
end