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")

Instance Method Summary collapse

Constructor Details

#initialize(supergraph:, request:) ⇒ Planner

Returns a new instance of Planner.



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

def initialize(supergraph:, request:)
  @supergraph = supergraph
  @request = request
  @sequence_key = 0
  @operations_by_grouping = {}
end

Instance Method Details

#operationsObject



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

def operations
  @operations_by_grouping.values.sort_by!(&:key)
end

#performObject



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

def perform
  build_root_operations
  expand_abstract_boundaries
  self
end

#to_hObject



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

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