apollo-federation 3.2.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe0ae888b83a68558821badedaaacc8c2e175dbf1aff918f347ec7ca797d8c0a
4
- data.tar.gz: ceae483d68658009536a64de692473cebad87d0810027c7c80219df52b7d8cfc
3
+ metadata.gz: 3133ca250d8e6ed9689a172c2fdaf373ae0ee0fcb371848cffeb75938f97be62
4
+ data.tar.gz: 5467c27805efb85724124ede7c1014abfffbd679aba915e188ec74edfc8a8051
5
5
  SHA512:
6
- metadata.gz: d3aaba325f9d53ceef358dc287963afe2374ca75d9a6cd3e2b988c9e008e47496238b81eb59c538d4bbb2693a967a52ce72c8efb8c643321480692b3b7666d6c
7
- data.tar.gz: 8ed45a0a43cf239ddbb6dbdd8f4375f209efec48f5d9f17282b83b564e9d98c6b41bab51bbaf622b57265ed2d1a93bacacf9e71da54b1205b07c9a3fa762f56a
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.map do |reference|
31
- typename = reference[:__typename]
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?(:resolve_reference)
44
- result = type_class.resolve_reference(reference, context)
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
- result = reference
50
+ results = references
47
51
  end
48
52
 
49
- context.schema.after_lazy(result) do |resolved_value|
50
- # TODO: This isn't 100% correct: if (for some reason) 2 different resolve_reference calls
51
- # return the same object, it might not have the right type
52
- # Right now, apollo-federation just adds a __typename property to the result,
53
- # but I don't really like the idea of modifying the resolved object
54
- context[resolved_value] = type
55
- resolved_value
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ApolloFederation
4
- VERSION = '3.2.0'
4
+ VERSION = '3.3.0'
5
5
  end
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.2.0
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-15 00:00:00.000000000 Z
12
+ date: 2022-08-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: graphql