Class: GraphQL::Stitching::Planner

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/stitching/planner.rb,
lib/graphql/stitching/planner/step.rb

Overview

Planner partitions request selections by best-fit graph locations, and provides a query plan with sequential execution steps.

Defined Under Namespace

Classes: ScopePartition, Step

Constant Summary collapse

SUPERGRAPH_LOCATIONS =
[Supergraph::SUPERGRAPH_LOCATION].freeze
ROOT_INDEX =
0

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ Planner

Returns a new instance of Planner.



13
14
15
16
17
18
# File 'lib/graphql/stitching/planner.rb', line 13

def initialize(request)
  @request = request
  @supergraph = request.supergraph
  @planning_index = ROOT_INDEX
  @steps_by_entrypoint = {}
end

Instance Method Details

#performObject



20
21
22
23
24
# File 'lib/graphql/stitching/planner.rb', line 20

def perform
  build_root_entrypoints
  expand_abstract_resolvers
  Plan.new(ops: steps.map(&:to_plan_op))
end

#stepsObject



26
27
28
# File 'lib/graphql/stitching/planner.rb', line 26

def steps
  @steps_by_entrypoint.values.sort_by!(&:index)
end