apollo-federation 3.2.0 → 3.3.0
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 +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/apollo-federation/entities_field.rb +20 -12
- data/lib/apollo-federation/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3133ca250d8e6ed9689a172c2fdaf373ae0ee0fcb371848cffeb75938f97be62
|
4
|
+
data.tar.gz: 5467c27805efb85724124ede7c1014abfffbd679aba915e188ec74edfc8a8051
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 446e436bbc11437122d01ba8c49097919b0c1d281ab40427ea330d3494d05dc21d10e3795394ef41bea9b24d5d33eb9c7ba854116f96cb32cc88318c51cde0ac
|
7
|
+
data.tar.gz: b22c3f55c0fb6114f68aefcedd08ed5f8acaebda5699f26be21e4cc9ad61c3d225aa6beb1f1253e64533dae56da6d869c8962a4b6aa75d548a9e032e01d3a8dc
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# [3.3.0](https://github.com/Gusto/apollo-federation-ruby/compare/v3.2.0...v3.3.0) (2022-08-24)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* introduce optional `resolve_references` method ([#206](https://github.com/Gusto/apollo-federation-ruby/issues/206)) ([1e3b631](https://github.com/Gusto/apollo-federation-ruby/commit/1e3b631609e1dfec8c3f126cd9dc8e0a2b3a0a57))
|
7
|
+
|
1
8
|
# [3.2.0](https://github.com/Gusto/apollo-federation-ruby/compare/v3.1.0...v3.2.0) (2022-08-15)
|
2
9
|
|
3
10
|
|
@@ -27,8 +27,10 @@ module ApolloFederation
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def _entities(representations:)
|
30
|
-
representations.
|
31
|
-
|
30
|
+
grouped_references = representations.group_by { |r| r[:__typename] }
|
31
|
+
|
32
|
+
final_results = []
|
33
|
+
grouped_references.each do |typename, references|
|
32
34
|
# TODO: Use warden or schema?
|
33
35
|
type = context.warden.get_type(typename)
|
34
36
|
if type.nil? || type.kind != GraphQL::TypeKinds::OBJECT
|
@@ -40,21 +42,27 @@ module ApolloFederation
|
|
40
42
|
# TODO: What if the type is an interface?
|
41
43
|
type_class = class_of_type(type)
|
42
44
|
|
43
|
-
if type_class.respond_to?(:
|
44
|
-
|
45
|
+
if type_class.respond_to?(:resolve_references)
|
46
|
+
results = type_class.resolve_references(references, context)
|
47
|
+
elsif type_class.respond_to?(:resolve_reference)
|
48
|
+
results = references.map { |reference| type_class.resolve_reference(reference, context) }
|
45
49
|
else
|
46
|
-
|
50
|
+
results = references
|
47
51
|
end
|
48
52
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
results = results.map do |result|
|
54
|
+
context.schema.after_lazy(result) do |resolved_value|
|
55
|
+
# TODO: This isn't 100% correct: if (for some reason) 2 different resolve_reference
|
56
|
+
# calls return the same object, it might not have the right type
|
57
|
+
# Right now, apollo-federation just adds a __typename property to the result,
|
58
|
+
# but I don't really like the idea of modifying the resolved object
|
59
|
+
context[resolved_value] = type
|
60
|
+
resolved_value
|
61
|
+
end
|
56
62
|
end
|
63
|
+
final_results = final_results.concat(results)
|
57
64
|
end
|
65
|
+
final_results
|
58
66
|
end
|
59
67
|
|
60
68
|
private
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apollo-federation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noa Elad
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-08-
|
12
|
+
date: 2022-08-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: graphql
|