Class: GraphQL::Query::SerialExecution::SelectionResolution

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, type, irep_node, execution_context) ⇒ SelectionResolution

Returns a new instance of SelectionResolution


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

def initialize(target, type, irep_node, execution_context)
  @target = target
  @type = type
  @irep_node = irep_node
  @execution_context = execution_context
end

Instance Attribute Details

#execution_contextObject (readonly)

Returns the value of attribute execution_context


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

def execution_context
  @execution_context
end

#irep_nodeObject (readonly)

Returns the value of attribute irep_node


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

def irep_node
  @irep_node
end

#targetObject (readonly)

Returns the value of attribute target


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

def target
  @target
end

#typeObject (readonly)

Returns the value of attribute type


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

def type
  @type
end

Instance Method Details

#resultObject


14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/graphql/query/serial_execution/selection_resolution.rb', line 14

def result
  irep_node.children.each_with_object({}) do |(name, irep_node), memo|
    if irep_node.included? && applies_to_type?(irep_node, type)
      field_result = execution_context.strategy.field_resolution.new(
        irep_node,
        type,
        target,
        execution_context
      ).result
      memo.merge!(field_result)
    end
  end
end