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

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

Constant Summary collapse

RESOLUTION_STRATEGIES =
{
  GraphQL::Language::Nodes::Field =>          :field_resolution,
  GraphQL::Language::Nodes::FragmentSpread => :fragment_spread_resolution,
  GraphQL::Language::Nodes::InlineFragment => :inline_fragment_resolution,
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, type, selections, query, execution_strategy) ⇒ SelectionResolution

Returns a new instance of SelectionResolution.



13
14
15
16
17
18
19
# File 'lib/graphql/query/serial_execution/selection_resolution.rb', line 13

def initialize(target, type, selections, query, execution_strategy)
  @target = target
  @type = type
  @selections = selections
  @query = query
  @execution_strategy = execution_strategy
end

Instance Attribute Details

#execution_strategyObject (readonly)

Returns the value of attribute execution_strategy.



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

def execution_strategy
  @execution_strategy
end

#queryObject (readonly)

Returns the value of attribute query.



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

def query
  @query
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



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

def result
  selections.reduce({}) do |memo, ast_field|
    field_value = resolve_field(ast_field)
    deep_merge memo, field_value
  end
end