Class: GraphQL::Execution::Batching::SelectionsStep

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/execution/batching/selections_step.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent_type:, selections:, objects:, results:, runner:, query:, path:) ⇒ SelectionsStep

Returns a new instance of SelectionsStep.



6
7
8
9
10
11
12
13
14
15
# File 'lib/graphql/execution/batching/selections_step.rb', line 6

def initialize(parent_type:, selections:, objects:, results:, runner:, query:, path:)
  @path = path
  @parent_type = parent_type
  @selections = selections
  @runner = runner
  @objects = objects
  @results = results
  @query = query
  @graphql_objects = nil
end

Instance Attribute Details

#objectsObject (readonly)

Returns the value of attribute objects.



17
18
19
# File 'lib/graphql/execution/batching/selections_step.rb', line 17

def objects
  @objects
end

#pathObject (readonly)

Returns the value of attribute path.



17
18
19
# File 'lib/graphql/execution/batching/selections_step.rb', line 17

def path
  @path
end

#queryObject (readonly)

Returns the value of attribute query.



17
18
19
# File 'lib/graphql/execution/batching/selections_step.rb', line 17

def query
  @query
end

#resultsObject (readonly)

Returns the value of attribute results.



17
18
19
# File 'lib/graphql/execution/batching/selections_step.rb', line 17

def results
  @results
end

Instance Method Details

#callObject



25
26
27
28
29
30
31
32
33
# File 'lib/graphql/execution/batching/selections_step.rb', line 25

def call
  grouped_selections = {}
  prototype_result = @results.first
  @runner.gather_selections(@parent_type, @selections, self, self.query, prototype_result, into: grouped_selections)
  @results.each { |r| r.replace(prototype_result) }
  grouped_selections.each_value do |frs|
    @runner.add_step(frs)
  end
end

#graphql_objectsObject



19
20
21
22
23
# File 'lib/graphql/execution/batching/selections_step.rb', line 19

def graphql_objects
  @graphql_objects ||= @objects.map do |obj|
    @parent_type.scoped_new(obj, @query.context)
  end
end