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, selections, 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, selections, execution_context)
  @target = target
  @type = type
  @selections = selections
  @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

#selectionsObject (readonly)

Returns the value of attribute selections.



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

def selections
  @selections
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
# File 'lib/graphql/query/serial_execution/selection_resolution.rb', line 14

def result
  flatten_and_merge_selections(selections)
    .values
    .reduce({}) { |result, ast_node|
      result.merge(resolve_field(ast_node))
    }
rescue GraphQL::InvalidNullError => err
  err.parent_error? || execution_context.add_error(err)
  nil
end