graphql-stitching 1.4.2 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b81b29cdab4287ba09d6081595b83b4edcc96f0921790483f44d53ff946fb441
4
- data.tar.gz: 39c3351dbb4a712aa4f43006017660a961a2056b82b96a5a14b3110b1ecfad44
3
+ metadata.gz: a72adc399f618790fc1aefe1b6dca07709d45f10cc2936f5c3978d75b5d3f8c2
4
+ data.tar.gz: d45d7b73045755a750d6d4334e00e30f33c5124f83c849c24669c98f7912ca92
5
5
  SHA512:
6
- metadata.gz: d376c15fa17088797be0b2f7ab42a94cf24050f68b37640aac88cc13a526d56f0ee366290b246e4cc6838a60050b9d9073610366cb7ad5bdb0a9a3435e688dd4
7
- data.tar.gz: 6a4fda5651bdd8794f59497e32bb9421c1d3f931a706483b55088597efdc9fe0bb1166dca16a66832c4ded42a21c89de2a7a8f2dc36cfb51bc44cfd40df9c4da
6
+ metadata.gz: 5302083cb9047ad77aa5e6276d02e3bdac8256ef328edb8c72b9248efbb279c48bb3e34b8e220f131d3efa541fdaa1b682fe4622501900defe797217cbc365c8
7
+ data.tar.gz: 4e238de4607764406ac52634daafc293c1b5fe672457106ff1070e77bc4d52cdc1ace02ce46ca4cacbcde7648d8a4f2bb8cc0321157dfb3c85c3ec40d5f82e43
@@ -1,8 +1,8 @@
1
1
  # typed: false
2
2
  # frozen_string_literal: true
3
3
 
4
- module GraphQL
5
- module Stitching
4
+ module GraphQL::Stitching
5
+ class Executor
6
6
  # Shapes the final results payload to the request selection and schema definition.
7
7
  # This eliminates unrequested export selections and applies null bubbling.
8
8
  # @api private
@@ -3,6 +3,7 @@
3
3
  require "json"
4
4
  require_relative "./executor/resolver_source"
5
5
  require_relative "./executor/root_source"
6
+ require_relative "./executor/shaper"
6
7
 
7
8
  module GraphQL
8
9
  module Stitching
@@ -33,7 +34,7 @@ module GraphQL
33
34
  result = {}
34
35
 
35
36
  if @data && @data.length > 0
36
- result["data"] = raw ? @data : GraphQL::Stitching::Shaper.new(@request).perform!(@data)
37
+ result["data"] = raw ? @data : Shaper.new(@request).perform!(@data)
37
38
  end
38
39
 
39
40
  if @errors.length > 0
@@ -2,7 +2,7 @@
2
2
 
3
3
  module GraphQL
4
4
  module Stitching
5
- # Immutable structures representing a query plan.
5
+ # Immutable (in theory) structures representing a query plan.
6
6
  # May serialize to/from JSON.
7
7
  class Plan
8
8
  Op = Struct.new(
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module GraphQL
4
- module Stitching
3
+ module GraphQL::Stitching
4
+ class Planner
5
5
  # A planned step in the sequence of stitching entrypoints together.
6
6
  # This is a mutable object that may change throughout the planning process.
7
7
  # It ultimately builds an immutable Plan::Op at the end of planning.
8
- class PlannerStep
8
+ class Step
9
9
  GRAPHQL_PRINTER = GraphQL::Language::Printer.new
10
10
 
11
11
  attr_reader :index, :location, :parent_type, :operation_type, :path
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "./planner/step"
4
+
3
5
  module GraphQL
4
6
  module Stitching
5
7
  class Planner
@@ -85,7 +87,7 @@ module GraphQL
85
87
  end
86
88
 
87
89
  if step.nil?
88
- @steps_by_entrypoint[entrypoint] = PlannerStep.new(
90
+ @steps_by_entrypoint[entrypoint] = Step.new(
89
91
  index: next_index,
90
92
  after: parent_index,
91
93
  location: location,
@@ -261,7 +263,7 @@ module GraphQL
261
263
 
262
264
  # B.4) Add a `__typename` export to abstracts and types that implement
263
265
  # fragments so that resolved type information is available during execution.
264
- if requires_typename
266
+ if requires_typename && !locale_selections.include?(Resolver::TYPENAME_EXPORT_NODE)
265
267
  locale_selections << Resolver::TYPENAME_EXPORT_NODE
266
268
  end
267
269
 
@@ -277,6 +279,10 @@ module GraphQL
277
279
  route.reduce(locale_selections) do |parent_selections, resolver|
278
280
  # E.1) Add the key of each resolver query into the prior location's selection set.
279
281
  parent_selections.push(*resolver.key.export_nodes) if resolver.key
282
+ parent_selections.uniq! do |node|
283
+ export_node = node.is_a?(GraphQL::Language::Nodes::Field) && Resolver.export_key?(node.alias)
284
+ export_node ? node.alias : node
285
+ end
280
286
 
281
287
  # E.2) Add a planner step for each new entrypoint location.
282
288
  add_step(
@@ -289,8 +295,6 @@ module GraphQL
289
295
  ).selections
290
296
  end
291
297
  end
292
-
293
- locale_selections.uniq! { _1.alias || _1.name }
294
298
  end
295
299
 
296
300
  locale_selections
@@ -47,7 +47,7 @@ module GraphQL
47
47
  end
48
48
 
49
49
  def version
50
- @version ||= Digest::SHA2.hexdigest(as_json.to_json)
50
+ @version ||= Digest::SHA2.hexdigest("#{Stitching::VERSION}/#{as_json.to_json}")
51
51
  end
52
52
 
53
53
  def ==(other)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module Stitching
5
- VERSION = "1.4.2"
5
+ VERSION = "1.4.3"
6
6
  end
7
7
  end
@@ -26,16 +26,14 @@ module GraphQL
26
26
  end
27
27
 
28
28
  require_relative "stitching/supergraph"
29
- require_relative "stitching/resolver"
30
29
  require_relative "stitching/client"
31
30
  require_relative "stitching/composer"
32
31
  require_relative "stitching/executor"
33
32
  require_relative "stitching/http_executable"
34
33
  require_relative "stitching/plan"
35
- require_relative "stitching/planner_step"
36
34
  require_relative "stitching/planner"
37
35
  require_relative "stitching/request"
38
- require_relative "stitching/shaper"
36
+ require_relative "stitching/resolver"
39
37
  require_relative "stitching/skip_include"
40
38
  require_relative "stitching/util"
41
39
  require_relative "stitching/version"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-stitching
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg MacWilliam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-03 00:00:00.000000000 Z
11
+ date: 2024-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -120,15 +120,15 @@ files:
120
120
  - lib/graphql/stitching/executor.rb
121
121
  - lib/graphql/stitching/executor/resolver_source.rb
122
122
  - lib/graphql/stitching/executor/root_source.rb
123
+ - lib/graphql/stitching/executor/shaper.rb
123
124
  - lib/graphql/stitching/http_executable.rb
124
125
  - lib/graphql/stitching/plan.rb
125
126
  - lib/graphql/stitching/planner.rb
126
- - lib/graphql/stitching/planner_step.rb
127
+ - lib/graphql/stitching/planner/step.rb
127
128
  - lib/graphql/stitching/request.rb
128
129
  - lib/graphql/stitching/resolver.rb
129
130
  - lib/graphql/stitching/resolver/arguments.rb
130
131
  - lib/graphql/stitching/resolver/keys.rb
131
- - lib/graphql/stitching/shaper.rb
132
132
  - lib/graphql/stitching/skip_include.rb
133
133
  - lib/graphql/stitching/supergraph.rb
134
134
  - lib/graphql/stitching/supergraph/key_directive.rb