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:, document:) ⇒ Planner

Returns a new instance of Planner.



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

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

Instance Method Details

#operationsObject



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

def operations
  ops = @operations_by_grouping.values
  ops.sort_by!(&:key)
  ops
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



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

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