Class: GraphQL::Query::SerialExecution::FragmentSpreadResolution

Inherits:
BaseExecution::SelectedObjectResolution show all
Defined in:
lib/graphql/query/serial_execution/fragment_spread_resolution.rb

Instance Attribute Summary collapse

Attributes inherited from BaseExecution::SelectedObjectResolution

#ast_node, #execution_strategy, #parent_type, #query, #target

Instance Method Summary collapse

Constructor Details

#initialize(ast_node, type, target, query, execution_strategy) ⇒ FragmentSpreadResolution

Returns a new instance of FragmentSpreadResolution.



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

def initialize(ast_node, type, target, query, execution_strategy)
  super
  @ast_fragment = query.fragments[ast_node.name]
  child_type = query.schema.types[ast_fragment.type]
  @resolved_type = GraphQL::Query::TypeResolver.new(target, child_type, type).type
end

Instance Attribute Details

#ast_fragmentObject (readonly)

Returns the value of attribute ast_fragment.



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

def ast_fragment
  @ast_fragment
end

#resolved_typeObject (readonly)

Returns the value of attribute resolved_type.



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

def resolved_type
  @resolved_type
end

Instance Method Details

#resultObject



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

def result
  return {} if resolved_type.nil?
  selections = ast_fragment.selections
  resolver = execution_strategy.selection_resolution.new(target, resolved_type, selections, query, execution_strategy)
  resolver.result
end