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
12
# File 'lib/graphql/query/serial_execution/execution_context.rb', line 7

def initialize(query, strategy)
  @query = query
  @schema = query.schema
  @strategy = strategy
  @warden = query.warden
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



31
32
33
# File 'lib/graphql/query/serial_execution/execution_context.rb', line 31

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

#get_field(type, irep_node) ⇒ Object



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

def get_field(type, irep_node)
  # fall back for dynamic fields (eg __typename)
  irep_node.definitions[type] || @warden.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



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

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

#get_type(type_name) ⇒ Object



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

def get_type(type_name)
  @warden.get_type(type_name)
end

#possible_types(type) ⇒ Object



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

def possible_types(type)
  @warden.possible_types(type)
end