apollo-federation 2.0.0 → 2.1.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 +28 -0
- data/README.md +31 -3
- data/lib/apollo-federation/field.rb +3 -2
- data/lib/apollo-federation/field_set_serializer.rb +34 -0
- data/lib/apollo-federation/interface.rb +2 -1
- data/lib/apollo-federation/object.rb +2 -1
- data/lib/apollo-federation/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c2b2d12a9e6be8b64cbd27aa7f0188975a49398538acab0bbb2881e9919651c
|
4
|
+
data.tar.gz: 614b16aed66cfdb99ee667647f020a33a537517cd4a9691e873b449b31aea57d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c0f879370628f7377b1b9646536c945974e494eb6602eb0f1adbc7d9471cd69641430b682f7892da330d32ec9d5a9e984518be5c7830ee0d4ae2c8e97cc94e8
|
7
|
+
data.tar.gz: bcbae55863980b44a39a8ba62d0eee3ead96052a2245a5a6c28105754b18e7c55e45deb6e04e1907fdd58bd00c6612eb9176b40ffd0ad883295076533facf084
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,31 @@
|
|
1
|
+
# [2.1.0](https://github.com/Gusto/apollo-federation-ruby/compare/v2.0.3...v2.1.0) (2022-02-02)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* snake case field references ([f5506ae](https://github.com/Gusto/apollo-federation-ruby/commit/f5506aecd10ea0c4a72744be07e0a9ad5cd45b16))
|
7
|
+
|
8
|
+
## [2.0.3](https://github.com/Gusto/apollo-federation-ruby/compare/v2.0.2...v2.0.3) (2022-02-02)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* Attempt to remove platform specific lock on google-protobuf ([#171](https://github.com/Gusto/apollo-federation-ruby/issues/171)) ([7898c28](https://github.com/Gusto/apollo-federation-ruby/commit/7898c2851aca06f08fa2559652375769bb98dfd8))
|
14
|
+
|
15
|
+
## [2.0.2](https://github.com/Gusto/apollo-federation-ruby/compare/v2.0.1...v2.0.2) (2022-01-31)
|
16
|
+
|
17
|
+
|
18
|
+
### Bug Fixes
|
19
|
+
|
20
|
+
* Use `bundle install` to avoid `bundle check` that changes our lockfiles ([#170](https://github.com/Gusto/apollo-federation-ruby/issues/170)) ([5c89ff1](https://github.com/Gusto/apollo-federation-ruby/commit/5c89ff1545dd1e6668fcdcf5b6fa89188cbb3ab4))
|
21
|
+
|
22
|
+
## [2.0.1](https://github.com/Gusto/apollo-federation-ruby/compare/v2.0.0...v2.0.1) (2022-01-27)
|
23
|
+
|
24
|
+
|
25
|
+
### Bug Fixes
|
26
|
+
|
27
|
+
* Update to latest Ruby 2.6 image ([#167](https://github.com/Gusto/apollo-federation-ruby/issues/167)) ([f57d523](https://github.com/Gusto/apollo-federation-ruby/commit/f57d523c36274d5f729bc724ab0f86474f7c0f73))
|
28
|
+
|
1
29
|
# [2.0.0](https://github.com/Gusto/apollo-federation-ruby/compare/v1.1.5...v2.0.0) (2022-01-27)
|
2
30
|
|
3
31
|
|
data/README.md
CHANGED
@@ -105,10 +105,20 @@ Call `key` within your class definition:
|
|
105
105
|
|
106
106
|
```ruby
|
107
107
|
class User < BaseObject
|
108
|
-
key fields:
|
108
|
+
key fields: :id
|
109
109
|
end
|
110
110
|
```
|
111
111
|
|
112
|
+
Compound keys are also supported:
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
class User < BaseObject
|
116
|
+
key fields: [:id, { organization: :id }]
|
117
|
+
end
|
118
|
+
```
|
119
|
+
|
120
|
+
See [field set syntax](#field-set-syntax) for more details on the format of the `fields` option.
|
121
|
+
|
112
122
|
### The `@external` directive
|
113
123
|
|
114
124
|
[Apollo documentation](https://www.apollographql.com/docs/apollo-server/federation/core-concepts/#referencing-external-types)
|
@@ -131,10 +141,12 @@ Pass the `requires:` option to your field definition:
|
|
131
141
|
class Product < BaseObject
|
132
142
|
field :price, Int, null: true, external: true
|
133
143
|
field :weight, Int, null: true, external: true
|
134
|
-
field :shipping_estimate, Int, null: true, requires: { fields:
|
144
|
+
field :shipping_estimate, Int, null: true, requires: { fields: [:price, :weight] }
|
135
145
|
end
|
136
146
|
```
|
137
147
|
|
148
|
+
See [field set syntax](#field-set-syntax) for more details on the format of the `fields` option.
|
149
|
+
|
138
150
|
### The `@provides` directive
|
139
151
|
|
140
152
|
[Apollo documentation](https://www.apollographql.com/docs/apollo-server/federation/advanced-features/#using-denormalized-data)
|
@@ -143,9 +155,25 @@ Pass the `provides:` option to your field definition:
|
|
143
155
|
|
144
156
|
```ruby
|
145
157
|
class Review < BaseObject
|
146
|
-
field :author, 'User', null: true, provides: { fields:
|
158
|
+
field :author, 'User', null: true, provides: { fields: :username }
|
147
159
|
end
|
148
160
|
```
|
161
|
+
See [field set syntax](#field-set-syntax) for more details on the format of the `fields` option.
|
162
|
+
|
163
|
+
### Field set syntax
|
164
|
+
|
165
|
+
Field sets can be either strings encoded with the Apollo Field Set [syntax]((https://www.apollographql.com/docs/apollo-server/federation/federation-spec/#scalar-_fieldset)) or arrays, hashes and snake case symbols that follow the graphql-ruby conventions:
|
166
|
+
|
167
|
+
```ruby
|
168
|
+
# Equivalent to the "organizationId" field set
|
169
|
+
:organization_id
|
170
|
+
|
171
|
+
# Equivalent to the "price weight" field set
|
172
|
+
[:price, :weight]
|
173
|
+
|
174
|
+
# Equivalent to the "id organization { id }" field set
|
175
|
+
[:id, { organization: :id }]
|
176
|
+
```
|
149
177
|
|
150
178
|
### Reference resolvers
|
151
179
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'apollo-federation/field_set_serializer'
|
3
4
|
require 'apollo-federation/has_directives'
|
4
5
|
|
5
6
|
module ApolloFederation
|
@@ -15,7 +16,7 @@ module ApolloFederation
|
|
15
16
|
name: 'requires',
|
16
17
|
arguments: [
|
17
18
|
name: 'fields',
|
18
|
-
values: requires[:fields],
|
19
|
+
values: ApolloFederation::FieldSetSerializer.serialize(requires[:fields]),
|
19
20
|
],
|
20
21
|
)
|
21
22
|
end
|
@@ -24,7 +25,7 @@ module ApolloFederation
|
|
24
25
|
name: 'provides',
|
25
26
|
arguments: [
|
26
27
|
name: 'fields',
|
27
|
-
values: provides[:fields],
|
28
|
+
values: ApolloFederation::FieldSetSerializer.serialize(provides[:fields]),
|
28
29
|
],
|
29
30
|
)
|
30
31
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'graphql'
|
4
|
+
|
5
|
+
module ApolloFederation
|
6
|
+
module FieldSetSerializer
|
7
|
+
extend self
|
8
|
+
|
9
|
+
def serialize(fields)
|
10
|
+
case fields
|
11
|
+
when Hash
|
12
|
+
fields.map do |field, nested_selections|
|
13
|
+
"#{camelize(field)} { #{serialize(nested_selections)} }"
|
14
|
+
end.join(' ')
|
15
|
+
when Array
|
16
|
+
fields.map do |field|
|
17
|
+
serialize(field)
|
18
|
+
end.join(' ')
|
19
|
+
when String
|
20
|
+
fields
|
21
|
+
when Symbol
|
22
|
+
camelize(fields)
|
23
|
+
else
|
24
|
+
raise ArgumentError, "Unexpected field set type: #{fields.class}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def camelize(field)
|
31
|
+
GraphQL::Schema::Member::BuildType.camelize(field.to_s)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'apollo-federation/field_set_serializer'
|
3
4
|
require 'apollo-federation/has_directives'
|
4
5
|
|
5
6
|
module ApolloFederation
|
@@ -22,7 +23,7 @@ module ApolloFederation
|
|
22
23
|
name: 'key',
|
23
24
|
arguments: [
|
24
25
|
name: 'fields',
|
25
|
-
values: fields,
|
26
|
+
values: ApolloFederation::FieldSetSerializer.serialize(fields),
|
26
27
|
],
|
27
28
|
)
|
28
29
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'apollo-federation/field_set_serializer'
|
3
4
|
require 'apollo-federation/has_directives'
|
4
5
|
|
5
6
|
module ApolloFederation
|
@@ -20,7 +21,7 @@ module ApolloFederation
|
|
20
21
|
name: 'key',
|
21
22
|
arguments: [
|
22
23
|
name: 'fields',
|
23
|
-
values: fields,
|
24
|
+
values: ApolloFederation::FieldSetSerializer.serialize(fields),
|
24
25
|
],
|
25
26
|
)
|
26
27
|
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: 2.
|
4
|
+
version: 2.1.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-
|
12
|
+
date: 2022-02-02 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.
|
34
|
+
version: '3.19'
|
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.
|
41
|
+
version: '3.19'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: actionpack
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,6 +198,7 @@ files:
|
|
198
198
|
- lib/apollo-federation/entity.rb
|
199
199
|
- lib/apollo-federation/federated_document_from_schema_definition.rb
|
200
200
|
- lib/apollo-federation/field.rb
|
201
|
+
- lib/apollo-federation/field_set_serializer.rb
|
201
202
|
- lib/apollo-federation/has_directives.rb
|
202
203
|
- lib/apollo-federation/interface.rb
|
203
204
|
- lib/apollo-federation/object.rb
|
@@ -234,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
234
235
|
- !ruby/object:Gem::Version
|
235
236
|
version: '0'
|
236
237
|
requirements: []
|
237
|
-
rubygems_version: 3.
|
238
|
+
rubygems_version: 3.2.32
|
238
239
|
signing_key:
|
239
240
|
specification_version: 4
|
240
241
|
summary: A Ruby implementation of Apollo Federation
|