apollo-federation 3.10.3 → 3.10.6

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: 799ff7dcaaf88157b7d98afb7928b2a269005d446b278090acd4f23085f86632
4
- data.tar.gz: c42b4221e12c9ac01751a342ea077fba533d8859167518d09805239e83f6935f
3
+ metadata.gz: 8e6a977f5cc4101104ede33393bbd9ccb545a7143b4bab5c950ef0b09a5dce63
4
+ data.tar.gz: 4c1a52043c9dbe9c21b398ac7cfbffe5caad8c5d32a6a63508c7008a01638705
5
5
  SHA512:
6
- metadata.gz: 272e6b2fa822f86c18dac2d9b2b0caf3e8ab6c297d9b277851848df3afcff9aba6d97dafd1c40cf334cd9c4c80c7ac230d4eafb21da6a574e973f6727631728f
7
- data.tar.gz: 26de2d9c4c18f072dd9ccc11359081673288971c87ade3d9808e0e6976c8f93436016a81fdb43338e63406d7d0eacc590ca97289c7efd9ec5872ebf182d2879c
6
+ metadata.gz: a8c863e767998dcfd111eaec0e226c03fa8e795224ea034faa78df3b9aa06a31b21009e9a319b7a45bf4bb0b63445e33723042b799f75f20b24d724b997b0c02
7
+ data.tar.gz: 0c3b8c59e4e5e94d59020738832b2352716f0ba9ff6189d98dfeb3a63187f12873f4dbbfd30f83ff768f92a7eb7a4f7133377a9a6d5135b254bb2293b4c9d9bf
data/CHANGELOG.md CHANGED
@@ -10,6 +10,30 @@
10
10
 
11
11
  * Revert "chore(release): 3.10.2 [skip ci]" (#309) ([a3937c6](https://github.com/Gusto/apollo-federation-ruby/commit/a3937c64f0ce9648edc10f74a80a4e825e01b4d4)), closes [#309](https://github.com/Gusto/apollo-federation-ruby/issues/309)
12
12
 
13
+ ## [3.10.6](https://github.com/Gusto/apollo-federation-ruby/compare/v3.10.5...v3.10.6) (2026-11-16)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * drop unused HasFields extend from federation ClassMethods ([#326](https://github.com/Gusto/apollo-federation-ruby/issues/326)) ([c1ad7f7](https://github.com/Gusto/apollo-federation-ruby/commit/c1ad7f7e3a6e0f782d97ae2bd34626f32fcf5fd1))
19
+
20
+ ## [3.10.5](https://github.com/Gusto/apollo-federation-ruby/compare/v3.10.4...v3.10.5) (2026-10-01)
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * add environment: release to the Publish Gem job ([#323](https://github.com/Gusto/apollo-federation-ruby/issues/323)) ([abbe9c6](https://github.com/Gusto/apollo-federation-ruby/commit/abbe9c652bf4fcfd5a23c238981a91bc5ad47da1))
26
+
27
+ ## [3.10.4](https://github.com/Gusto/apollo-federation-ruby/compare/v3.10.3...v3.10.4) (2026-09-30)
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * authenticate release-please-action with a GitHub App token, not GITHUB_TOKEN ([#320](https://github.com/Gusto/apollo-federation-ruby/issues/320)) ([0231a15](https://github.com/Gusto/apollo-federation-ruby/commit/0231a1573253739573fa2a8b17aeb9a124e73728))
33
+ * Query._entities crashing under GraphQL::Execution::Next ([#317](https://github.com/Gusto/apollo-federation-ruby/issues/317)) ([4b869ba](https://github.com/Gusto/apollo-federation-ruby/commit/4b869ba7b4e5377cef0a08c8967386f38b6b7b97))
34
+ * regenerate Gemfile.lock on the release PR after version bumps ([#322](https://github.com/Gusto/apollo-federation-ruby/issues/322)) ([c6122dc](https://github.com/Gusto/apollo-federation-ruby/commit/c6122dcccb8d246642bc799f5b4e7fb8b749b84c))
35
+ * restore environment: release on the release-please job ([#321](https://github.com/Gusto/apollo-federation-ruby/issues/321)) ([61904d8](https://github.com/Gusto/apollo-federation-ruby/commit/61904d86023f14f6fbd661417e60ecc7ce166ec4))
36
+
13
37
  ## [3.10.1](https://github.com/Gusto/apollo-federation-ruby/compare/v3.10.0...v3.10.1) (2025-04-02)
14
38
 
15
39
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'graphql'
4
4
  require 'apollo-federation/any'
5
+ require 'apollo-federation/next_execution_support'
5
6
 
6
7
  module ApolloFederation
7
8
  module EntitiesField
@@ -10,8 +11,6 @@ module ApolloFederation
10
11
  end
11
12
 
12
13
  module ClassMethods
13
- extend GraphQL::Schema::Member::HasFields
14
-
15
14
  def define_entities_field(possible_entities)
16
15
  # If there are any "entities", define the Entity union and and the Query._entities field
17
16
  return if possible_entities.empty?
@@ -20,80 +19,102 @@ module ApolloFederation
20
19
  possible_types(*possible_entities)
21
20
  end
22
21
 
23
- field(:_entities, [entity_type, null: true], null: false) do
22
+ # resolve_static so Next dispatches to resolve_entities_for_next, not root_value; a
23
+ # separate method from _entities since Next needs a fully-synced Array, not a Lazy.
24
+ if ApolloFederation::RESOLVE_STATIC_SUPPORTED
25
+ entities_field_options = { resolve_static: :resolve_entities_for_next }
26
+ else
27
+ entities_field_options = {}
28
+ end
29
+ field(:_entities, [entity_type, null: true], null: false, **entities_field_options) do
24
30
  argument :representations, [Any], required: true
25
31
  end
26
32
  end
27
- end
28
33
 
29
- def _entities(representations:)
30
- final_result = Array.new(representations.size)
31
- grouped_references_with_indices =
32
- representations
33
- .map
34
- .with_index { |r, i| [r, i] }
35
- .group_by { |(r, _i)| r[:__typename] }
36
-
37
- maybe_lazies = grouped_references_with_indices.map do |typename, references_with_indices|
38
- references = references_with_indices.map(&:first)
39
- indices = references_with_indices.map(&:last)
40
-
41
- # TODO: Use warden or schema?
42
- type = context.warden.get_type(typename)
43
- if type.nil? || type.kind != GraphQL::TypeKinds::OBJECT
44
- # TODO: Raise a specific error class?
45
- raise "The _entities resolver tried to load an entity for type \"#{typename}\"," \
46
- ' but no object type of that name was found in the schema'
47
- end
34
+ def _entities(context, representations:)
35
+ build_entities(context, representations)
36
+ end
37
+
38
+ def resolve_entities_for_next(context, representations:)
39
+ final_result = build_entities(context, representations).value
40
+ # Resolving the outer Lazy doesn't resolve each entry: a per-reference resolve_reference
41
+ # lazy value comes back wrapped in its own Lazy from the after_lazy call in build_entities.
42
+ final_result.map { |entry| entry.is_a?(GraphQL::Execution::Lazy) ? entry.value : entry }
43
+ end
44
+
45
+ private
46
+
47
+ def build_entities(context, representations)
48
+ final_result = Array.new(representations.size)
49
+ grouped_references_with_indices =
50
+ representations
51
+ .map
52
+ .with_index { |r, i| [r, i] }
53
+ .group_by { |(r, _i)| r[:__typename] }
54
+
55
+ maybe_lazies = grouped_references_with_indices.map do |typename, references_with_indices|
56
+ references = references_with_indices.map(&:first)
57
+ indices = references_with_indices.map(&:last)
58
+
59
+ # TODO: Use warden or schema?
60
+ type = context.warden.get_type(typename)
61
+ if type.nil? || type.kind != GraphQL::TypeKinds::OBJECT
62
+ # TODO: Raise a specific error class?
63
+ raise "The _entities resolver tried to load an entity for type \"#{typename}\"," \
64
+ ' but no object type of that name was found in the schema'
65
+ end
48
66
 
49
- # TODO: What if the type is an interface?
50
- type_class = class_of_type(type)
67
+ # TODO: What if the type is an interface?
68
+ type_class = class_of_type(type)
51
69
 
52
- if type_class.underscore_reference_keys
53
- references.map! do |reference|
54
- reference.transform_keys do |key|
55
- GraphQL::Schema::Member::BuildType.underscore(key.to_s).to_sym
70
+ if type_class.underscore_reference_keys
71
+ references.map! do |reference|
72
+ reference.transform_keys do |key|
73
+ GraphQL::Schema::Member::BuildType.underscore(key.to_s).to_sym
74
+ end
56
75
  end
57
76
  end
58
- end
59
77
 
60
- if type_class.respond_to?(:resolve_references)
61
- results = type_class.resolve_references(references, context)
62
- elsif type_class.respond_to?(:resolve_reference)
63
- results = references.map { |reference| type_class.resolve_reference(reference, context) }
64
- else
65
- results = references
66
- end
78
+ if type_class.respond_to?(:resolve_references)
79
+ results = type_class.resolve_references(references, context)
80
+ elsif type_class.respond_to?(:resolve_reference)
81
+ results = references.map { |reference| type_class.resolve_reference(reference, context) }
82
+ else
83
+ results = references
84
+ end
67
85
 
68
- context.schema.after_lazy(results) do |resolved_results|
69
- resolved_results.zip(indices).each do |result, i|
70
- final_result[i] = context.schema.after_lazy(result) do |resolved_value|
71
- # TODO: This isn't 100% correct: if (for some reason) 2 different resolve_reference
72
- # calls return the same object, it might not have the right type
73
- # Right now, apollo-federation just adds a __typename property to the result,
74
- # but I don't really like the idea of modifying the resolved object
75
- context[resolved_value] = type
76
- resolved_value
86
+ context.schema.after_lazy(results) do |resolved_results|
87
+ resolved_results.zip(indices).each do |result, i|
88
+ final_result[i] = context.schema.after_lazy(result) do |resolved_value|
89
+ # TODO: This isn't 100% correct: if (for some reason) 2 different resolve_reference
90
+ # calls return the same object, it might not have the right type
91
+ # Right now, apollo-federation just adds a __typename property to the result,
92
+ # but I don't really like the idea of modifying the resolved object
93
+ context[resolved_value] = type
94
+ resolved_value
95
+ end
77
96
  end
78
97
  end
79
98
  end
99
+
100
+ # Make sure we've resolved the outer level of lazies so we can return an array with a possibly lazy
101
+ # entry for each requested entity
102
+ GraphQL::Execution::Lazy.all(maybe_lazies).then do
103
+ final_result
104
+ end
80
105
  end
81
106
 
82
- # Make sure we've resolved the outer level of lazies so we can return an array with a possibly lazy
83
- # entry for each requested entity
84
- GraphQL::Execution::Lazy.all(maybe_lazies).then do
85
- final_result
107
+ def class_of_type(type)
108
+ if defined?(GraphQL::ObjectType) && type.is_a?(GraphQL::ObjectType)
109
+ type.metadata[:type_class]
110
+ else
111
+ type
112
+ end
86
113
  end
87
114
  end
88
115
 
89
- private
90
-
91
- def class_of_type(type)
92
- if defined?(GraphQL::ObjectType) && type.is_a?(GraphQL::ObjectType)
93
- type.metadata[:type_class]
94
- else
95
- type
96
- end
116
+ def _entities(representations:)
117
+ self.class._entities(context, representations: representations)
97
118
  end
98
119
  end
99
120
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'graphql'
4
+
5
+ module ApolloFederation
6
+ # `resolve_static:` (and GraphQL::Execution::Next generally) doesn't exist on every
7
+ # graphql-ruby version this gem supports, so detect it via a capability the Next-era
8
+ # GraphQL::Schema::Field always defines, rather than assuming a minimum graphql-ruby version.
9
+ # Checking Field#initialize's own parameter list (an earlier version of this check) breaks
10
+ # under graphql-pro, which prepends a `(*args, streamable:, **kwargs)`-shaped `initialize` onto
11
+ # Field -- `instance_method(:initialize)` then reports *that* signature, not the one
12
+ # underneath, so the check silently reads as unsupported. `execution_mode` is a plain
13
+ # `attr_reader`, untouched by that prepend either way. Shared by any field this gem defines
14
+ # directly on the Query type (currently _entities and _service), since those are resolved
15
+ # against the wrapped Query object under classic but the (nil, by default) Query root_value
16
+ # under Next's default :direct_send -- resolve_static is what makes them agree.
17
+ RESOLVE_STATIC_SUPPORTED = GraphQL::Schema::Field.method_defined?(:execution_mode)
18
+ end
@@ -9,6 +9,7 @@ module ApolloFederation
9
9
  'directives, removes federation types, and includes rest of full schema after schema ' \
10
10
  'directives have been applied'
11
11
 
12
- field(:sdl, String, null: true)
12
+ # hash_key: so Next reads the { sdl: ... } Hash (see ServiceField#_service) directly.
13
+ field(:sdl, String, null: true, hash_key: :sdl)
13
14
  end
14
15
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'graphql'
4
4
  require 'apollo-federation/service'
5
+ require 'apollo-federation/next_execution_support'
5
6
 
6
7
  module ApolloFederation
7
8
  module ServiceField
@@ -10,16 +11,20 @@ module ApolloFederation
10
11
  end
11
12
 
12
13
  module ClassMethods
13
- extend GraphQL::Schema::Member::HasFields
14
-
15
14
  def define_service_field
16
- field(:_service, Service, null: false)
15
+ # resolve_static so Next dispatches to the class method below, not root_value.
16
+ service_field_options = ApolloFederation::RESOLVE_STATIC_SUPPORTED ? { resolve_static: true } : {}
17
+ field(:_service, Service, null: false, **service_field_options)
18
+ end
19
+
20
+ def _service(context)
21
+ schema_class = context.schema.is_a?(GraphQL::Schema) ? context.schema.class : context.schema
22
+ { sdl: schema_class.federation_sdl(context: context.to_h) }
17
23
  end
18
24
  end
19
25
 
20
26
  def _service
21
- schema_class = context.schema.is_a?(GraphQL::Schema) ? context.schema.class : context.schema
22
- { sdl: schema_class.federation_sdl(context: context.to_h) }
27
+ self.class._service(context)
23
28
  end
24
29
  end
25
30
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ApolloFederation
4
- VERSION = '3.10.3'
4
+ VERSION = '3.10.6'
5
5
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apollo-federation
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.3
4
+ version: 3.10.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noa Elad
8
8
  - Rylan Collins
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2025-10-20 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: graphql
@@ -233,6 +232,7 @@ files:
233
232
  - lib/apollo-federation/has_directives.rb
234
233
  - lib/apollo-federation/input_object.rb
235
234
  - lib/apollo-federation/interface.rb
235
+ - lib/apollo-federation/next_execution_support.rb
236
236
  - lib/apollo-federation/object.rb
237
237
  - lib/apollo-federation/scalar.rb
238
238
  - lib/apollo-federation/schema.rb
@@ -254,7 +254,6 @@ metadata:
254
254
  changelog_uri: https://github.com/Gusto/apollo-federation-ruby/releases
255
255
  source_code_uri: https://github.com/Gusto/apollo-federation-ruby
256
256
  bug_tracker_uri: https://github.com/Gusto/apollo-federation-ruby/issues
257
- post_install_message:
258
257
  rdoc_options: []
259
258
  require_paths:
260
259
  - lib
@@ -269,8 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
269
268
  - !ruby/object:Gem::Version
270
269
  version: '0'
271
270
  requirements: []
272
- rubygems_version: 3.5.22
273
- signing_key:
271
+ rubygems_version: 3.6.9
274
272
  specification_version: 4
275
273
  summary: A Ruby implementation of Apollo Federation
276
274
  test_files: []