Class: GraphQL::Execution::Batching::SelectionsStep
- Inherits:
-
Object
- Object
- GraphQL::Execution::Batching::SelectionsStep
- Defined in:
- lib/graphql/execution/batching/selections_step.rb
Instance Attribute Summary collapse
-
#objects ⇒ Object
readonly
Returns the value of attribute objects.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
-
#call ⇒ Object
-
#graphql_objects ⇒ Object
-
#initialize(parent_type:, selections:, objects:, results:, runner:, query:, path:) ⇒ SelectionsStep
constructor
A new instance of SelectionsStep.
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
#objects ⇒ Object (readonly)
Returns the value of attribute objects.
17 18 19 |
# File 'lib/graphql/execution/batching/selections_step.rb', line 17 def objects @objects end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
17 18 19 |
# File 'lib/graphql/execution/batching/selections_step.rb', line 17 def path @path end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
17 18 19 |
# File 'lib/graphql/execution/batching/selections_step.rb', line 17 def query @query end |
#results ⇒ Object (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
#call ⇒ Object
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_objects ⇒ Object
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 |