Class: GraphQL::Stitching::Planner

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

Constant Summary collapse

SUPERGRAPH_LOCATIONS =
[Supergraph::LOCATION].freeze
TYPENAME_NODE =
GraphQL::Language::Nodes::Field.new(alias: "_STITCH_typename", name: "__typename")
ROOT_ORDER =
0

Instance Method Summary collapse

Constructor Details

#initialize(supergraph:, request:) ⇒ Planner

Returns a new instance of Planner.



10
11
12
13
14
15
# File 'lib/graphql/stitching/planner.rb', line 10

def initialize(supergraph:, request:)
  @supergraph = supergraph
  @request = request
  @planning_order = ROOT_ORDER
  @operations_by_entrypoint = {}
end

Instance Method Details

#operationsObject



23
24
25
# File 'lib/graphql/stitching/planner.rb', line 23

def operations
  @operations_by_entrypoint.values.sort_by!(&:order)
end

#performObject



17
18
19
20
21
# File 'lib/graphql/stitching/planner.rb', line 17

def perform
  build_root_entrypoints
  expand_abstract_boundaries
  self
end

#to_hObject



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

def to_h
  { "ops" => operations.map!(&:to_h) }
end