apollo-federation 3.2.0 → 3.3.1

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: 7fae5c467c54e48866d1700c3ac557045efc4d6e7a0977917827d6f0a37b0870
4
+ data.tar.gz: 524ef930053f086182567648fffa099902e69ecfeb759d2958df0e557644caef
5
5
  SHA512:
6
- metadata.gz: d3aaba325f9d53ceef358dc287963afe2374ca75d9a6cd3e2b988c9e008e47496238b81eb59c538d4bbb2693a967a52ce72c8efb8c643321480692b3b7666d6c
7
- data.tar.gz: 8ed45a0a43cf239ddbb6dbdd8f4375f209efec48f5d9f17282b83b564e9d98c6b41bab51bbaf622b57265ed2d1a93bacacf9e71da54b1205b07c9a3fa762f56a
6
+ metadata.gz: c47a2a35d1308e9c9f4f7c7839f620f556c771230ee36ea189a93b0bd7b35def410887c3d0d1da5f01d691fbe5cda45a43938dad53e7ab5d5f6be52014909a37
7
+ data.tar.gz: '099a8b6aa26465eb88a9654649f37deb76e8ab554b8c2ca9c3665ed4c2d7f2286187eb306bf070544e81e93fa09de98f274bde07e9e7c9aa2b4f2c912b113fab'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [3.3.1](https://github.com/Gusto/apollo-federation-ruby/compare/v3.3.0...v3.3.1) (2023-01-05)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * address SNYK-RUBY-GOOGLEPROTOBUF-3167775 ([#212](https://github.com/Gusto/apollo-federation-ruby/issues/212)) ([c36b51e](https://github.com/Gusto/apollo-federation-ruby/commit/c36b51e521a60e8186100405cf81bba1a37f5978))
7
+
8
+ # [3.3.0](https://github.com/Gusto/apollo-federation-ruby/compare/v3.2.0...v3.3.0) (2022-08-24)
9
+
10
+
11
+ ### Features
12
+
13
+ * 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))
14
+
1
15
  # [3.2.0](https://github.com/Gusto/apollo-federation-ruby/compare/v3.1.0...v3.2.0) (2022-08-15)
2
16
 
3
17
 
@@ -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.1'
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.1
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: 2023-01-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: graphql
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '3.19'
34
+ version: 3.21.7
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '3.19'
41
+ version: 3.21.7
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: actionpack
44
44
  requirement: !ruby/object:Gem::Requirement