apollo-federation 3.4.0 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/README.md +20 -0
- data/lib/apollo-federation/argument.rb +37 -0
- data/lib/apollo-federation/enum.rb +19 -0
- data/lib/apollo-federation/enum_value.rb +37 -0
- data/lib/apollo-federation/federated_document_from_schema_definition.rb +33 -3
- data/lib/apollo-federation/field.rb +12 -2
- data/lib/apollo-federation/input_object.rb +19 -0
- data/lib/apollo-federation/interface.rb +4 -0
- data/lib/apollo-federation/object.rb +4 -0
- data/lib/apollo-federation/scalar.rb +19 -0
- data/lib/apollo-federation/schema.rb +3 -1
- data/lib/apollo-federation/union.rb +19 -0
- data/lib/apollo-federation/version.rb +1 -1
- data/lib/apollo-federation.rb +6 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93e41c85366169cb54514dc0803b1a92c26ad684520ba328ff108ab67d20474c
|
4
|
+
data.tar.gz: 53b7ef86f0cf1e65849aed13cd4bfd625647eba6607efa08f2a566d450e5afd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24e88953a0bbdc57273f82d05def242266e7368acd8962fb2648ef954c4379fc431b680fba853ee0ddca668fc8f39400e609d3fca8e9bf9248ed8dbf7e2971dd
|
7
|
+
data.tar.gz: ffd6c899084c8d26d30602ab34e80bfe343c2c6f847daa339130ab4272ccd04aa028b24e41725e1d1acbb00d132f9b81d9129ee8a9a79f0351e037dcb1a9ffc6
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
# [3.5.0](https://github.com/Gusto/apollo-federation-ruby/compare/v3.4.1...v3.5.0) (2023-03-08)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* add tag directive from federation v2 ([#210](https://github.com/Gusto/apollo-federation-ruby/issues/210)) ([8c6e112](https://github.com/Gusto/apollo-federation-ruby/commit/8c6e11251b7bc7d6888a7a2b6e0feeea70171cb0))
|
7
|
+
|
8
|
+
## [3.4.1](https://github.com/Gusto/apollo-federation-ruby/compare/v3.4.0...v3.4.1) (2023-02-21)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* import [@inaccessible](https://github.com/inaccessible) directive in Fed v2.3 ([#220](https://github.com/Gusto/apollo-federation-ruby/issues/220)) ([5d4d86e](https://github.com/Gusto/apollo-federation-ruby/commit/5d4d86e8155efe83470c58012454c79c910219ff))
|
14
|
+
|
1
15
|
# [3.4.0](https://github.com/Gusto/apollo-federation-ruby/compare/v3.3.1...v3.4.0) (2023-02-21)
|
2
16
|
|
3
17
|
|
data/README.md
CHANGED
@@ -222,6 +222,26 @@ class Product < BaseObject
|
|
222
222
|
end
|
223
223
|
```
|
224
224
|
|
225
|
+
### The `@tag` directive (Apollo Federation v2)
|
226
|
+
|
227
|
+
[Apollo documentation](https://www.apollographql.com/docs/federation/federated-types/federated-directives/#tag)
|
228
|
+
|
229
|
+
Call `tag` within your class definition:
|
230
|
+
|
231
|
+
```ruby
|
232
|
+
class User < BaseObject
|
233
|
+
tag name: 'private'
|
234
|
+
end
|
235
|
+
```
|
236
|
+
|
237
|
+
Pass the `tags:` option to your field definition:
|
238
|
+
|
239
|
+
```ruby
|
240
|
+
class User < BaseObject
|
241
|
+
field :id, ID, null: false, tags: [{ name: 'private' }]
|
242
|
+
end
|
243
|
+
```
|
244
|
+
|
225
245
|
### Field set syntax
|
226
246
|
|
227
247
|
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:
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'apollo-federation/has_directives'
|
4
|
+
|
5
|
+
module ApolloFederation
|
6
|
+
module Argument
|
7
|
+
include HasDirectives
|
8
|
+
|
9
|
+
VERSION_2_DIRECTIVES = %i[tags].freeze
|
10
|
+
|
11
|
+
def initialize(*args, **kwargs, &block)
|
12
|
+
add_v2_directives(**kwargs)
|
13
|
+
|
14
|
+
# Remove the custom kwargs
|
15
|
+
kwargs = kwargs.delete_if do |k, _|
|
16
|
+
VERSION_2_DIRECTIVES.include?(k)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Pass on the default args:
|
20
|
+
super(*args, **kwargs, &block)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def add_v2_directives(tags: [], **_kwargs)
|
26
|
+
tags.each do |tag|
|
27
|
+
add_directive(
|
28
|
+
name: 'tag',
|
29
|
+
arguments: [
|
30
|
+
name: 'name',
|
31
|
+
values: tag[:name],
|
32
|
+
],
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'apollo-federation/has_directives'
|
4
|
+
|
5
|
+
module ApolloFederation
|
6
|
+
module Enum
|
7
|
+
def self.included(klass)
|
8
|
+
klass.extend(ClassMethods)
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
include HasDirectives
|
13
|
+
|
14
|
+
def tag(name:)
|
15
|
+
add_directive(name: 'tag', arguments: [name: 'name', values: name])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'apollo-federation/has_directives'
|
4
|
+
|
5
|
+
module ApolloFederation
|
6
|
+
module EnumValue
|
7
|
+
include HasDirectives
|
8
|
+
|
9
|
+
VERSION_2_DIRECTIVES = %i[tags].freeze
|
10
|
+
|
11
|
+
def initialize(*args, **kwargs, &block)
|
12
|
+
add_v2_directives(**kwargs)
|
13
|
+
|
14
|
+
# Remove the custom kwargs
|
15
|
+
kwargs = kwargs.delete_if do |k, _|
|
16
|
+
VERSION_2_DIRECTIVES.include?(k)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Pass on the default args:
|
20
|
+
super(*args, **kwargs, &block)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def add_v2_directives(tags: [], **_kwargs)
|
26
|
+
tags.each do |tag|
|
27
|
+
add_directive(
|
28
|
+
name: 'tag',
|
29
|
+
arguments: [
|
30
|
+
name: 'name',
|
31
|
+
values: tag[:name],
|
32
|
+
],
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -27,8 +27,38 @@ module ApolloFederation
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def build_interface_type_node(interface_type)
|
30
|
-
|
31
|
-
merge_directives(
|
30
|
+
interface_node = super
|
31
|
+
merge_directives(interface_node, interface_type)
|
32
|
+
end
|
33
|
+
|
34
|
+
def build_union_type_node(union_type)
|
35
|
+
union_node = super
|
36
|
+
merge_directives(union_node, union_type)
|
37
|
+
end
|
38
|
+
|
39
|
+
def build_enum_type_node(enum_type)
|
40
|
+
enum_node = super
|
41
|
+
merge_directives(enum_node, enum_type)
|
42
|
+
end
|
43
|
+
|
44
|
+
def build_enum_value_node(enum_value_type)
|
45
|
+
enum_value_node = super
|
46
|
+
merge_directives(enum_value_node, enum_value_type)
|
47
|
+
end
|
48
|
+
|
49
|
+
def build_scalar_type_node(scalar_type)
|
50
|
+
scalar_node = super
|
51
|
+
merge_directives(scalar_node, scalar_type)
|
52
|
+
end
|
53
|
+
|
54
|
+
def build_input_object_node(input_object_type)
|
55
|
+
input_object_node = super
|
56
|
+
merge_directives(input_object_node, input_object_type)
|
57
|
+
end
|
58
|
+
|
59
|
+
def build_argument_node(argument_type)
|
60
|
+
argument_node = super
|
61
|
+
merge_directives(argument_node, argument_type)
|
32
62
|
end
|
33
63
|
|
34
64
|
def build_field_node(field_type)
|
@@ -70,7 +100,7 @@ module ApolloFederation
|
|
70
100
|
end
|
71
101
|
|
72
102
|
def directive_name(directive)
|
73
|
-
if schema.federation_2?
|
103
|
+
if schema.federation_2? && !Schema::IMPORTED_DIRECTIVES.include?(directive[:name])
|
74
104
|
"#{schema.link_namespace}__#{directive[:name]}"
|
75
105
|
else
|
76
106
|
directive[:name]
|
@@ -8,7 +8,7 @@ module ApolloFederation
|
|
8
8
|
include HasDirectives
|
9
9
|
|
10
10
|
VERSION_1_DIRECTIVES = %i[external requires provides].freeze
|
11
|
-
VERSION_2_DIRECTIVES = %i[shareable inaccessible override].freeze
|
11
|
+
VERSION_2_DIRECTIVES = %i[shareable inaccessible override tags].freeze
|
12
12
|
|
13
13
|
def initialize(*args, **kwargs, &block)
|
14
14
|
add_v1_directives(**kwargs)
|
@@ -59,7 +59,7 @@ module ApolloFederation
|
|
59
59
|
nil
|
60
60
|
end
|
61
61
|
|
62
|
-
def add_v2_directives(shareable: nil, inaccessible: nil, override: nil, **_kwargs)
|
62
|
+
def add_v2_directives(shareable: nil, inaccessible: nil, override: nil, tags: [], **_kwargs)
|
63
63
|
if shareable
|
64
64
|
add_directive(name: 'shareable')
|
65
65
|
end
|
@@ -78,6 +78,16 @@ module ApolloFederation
|
|
78
78
|
)
|
79
79
|
end
|
80
80
|
|
81
|
+
tags.each do |tag|
|
82
|
+
add_directive(
|
83
|
+
name: 'tag',
|
84
|
+
arguments: [
|
85
|
+
name: 'name',
|
86
|
+
values: tag[:name],
|
87
|
+
],
|
88
|
+
)
|
89
|
+
end
|
90
|
+
|
81
91
|
nil
|
82
92
|
end
|
83
93
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'apollo-federation/has_directives'
|
4
|
+
|
5
|
+
module ApolloFederation
|
6
|
+
module InputObject
|
7
|
+
def self.included(klass)
|
8
|
+
klass.extend(ClassMethods)
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
include HasDirectives
|
13
|
+
|
14
|
+
def tag(name:)
|
15
|
+
add_directive(name: 'tag', arguments: [name: 'name', values: name])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'apollo-federation/has_directives'
|
4
|
+
|
5
|
+
module ApolloFederation
|
6
|
+
module Scalar
|
7
|
+
def self.included(klass)
|
8
|
+
klass.extend(ClassMethods)
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
include HasDirectives
|
13
|
+
|
14
|
+
def tag(name:)
|
15
|
+
add_directive(name: 'tag', arguments: [name: 'name', values: name])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -7,6 +7,8 @@ require 'apollo-federation/federated_document_from_schema_definition.rb'
|
|
7
7
|
|
8
8
|
module ApolloFederation
|
9
9
|
module Schema
|
10
|
+
IMPORTED_DIRECTIVES = ['inaccessible', 'tag'].freeze
|
11
|
+
|
10
12
|
def self.included(klass)
|
11
13
|
klass.extend(CommonMethods)
|
12
14
|
end
|
@@ -61,7 +63,7 @@ module ApolloFederation
|
|
61
63
|
|
62
64
|
<<~SCHEMA
|
63
65
|
extend schema
|
64
|
-
@link(url: "https://specs.apollo.dev/federation/v2.3"#{federation_namespace})
|
66
|
+
@link(url: "https://specs.apollo.dev/federation/v2.3"#{federation_namespace}, import: [#{(IMPORTED_DIRECTIVES.map { |directive| "\"@#{directive}\"" }).join(', ')}])
|
65
67
|
|
66
68
|
SCHEMA
|
67
69
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'apollo-federation/has_directives'
|
4
|
+
|
5
|
+
module ApolloFederation
|
6
|
+
module Union
|
7
|
+
def self.included(klass)
|
8
|
+
klass.extend(ClassMethods)
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
include HasDirectives
|
13
|
+
|
14
|
+
def tag(name:)
|
15
|
+
add_directive(name: 'tag', arguments: [name: 'name', values: name])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/apollo-federation.rb
CHANGED
@@ -4,7 +4,13 @@ require 'apollo-federation/version'
|
|
4
4
|
require 'apollo-federation/schema'
|
5
5
|
require 'apollo-federation/object'
|
6
6
|
require 'apollo-federation/interface'
|
7
|
+
require 'apollo-federation/union'
|
8
|
+
require 'apollo-federation/enum'
|
9
|
+
require 'apollo-federation/enum_value'
|
7
10
|
require 'apollo-federation/field'
|
11
|
+
require 'apollo-federation/scalar'
|
12
|
+
require 'apollo-federation/input_object'
|
13
|
+
require 'apollo-federation/argument'
|
8
14
|
require 'apollo-federation/tracing/proto'
|
9
15
|
require 'apollo-federation/tracing/node_map'
|
10
16
|
require 'apollo-federation/tracing/tracer'
|
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.5.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: 2023-
|
12
|
+
date: 2023-03-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: graphql
|
@@ -194,14 +194,19 @@ files:
|
|
194
194
|
- bin/rspec
|
195
195
|
- lib/apollo-federation.rb
|
196
196
|
- lib/apollo-federation/any.rb
|
197
|
+
- lib/apollo-federation/argument.rb
|
197
198
|
- lib/apollo-federation/entities_field.rb
|
198
199
|
- lib/apollo-federation/entity.rb
|
200
|
+
- lib/apollo-federation/enum.rb
|
201
|
+
- lib/apollo-federation/enum_value.rb
|
199
202
|
- lib/apollo-federation/federated_document_from_schema_definition.rb
|
200
203
|
- lib/apollo-federation/field.rb
|
201
204
|
- lib/apollo-federation/field_set_serializer.rb
|
202
205
|
- lib/apollo-federation/has_directives.rb
|
206
|
+
- lib/apollo-federation/input_object.rb
|
203
207
|
- lib/apollo-federation/interface.rb
|
204
208
|
- lib/apollo-federation/object.rb
|
209
|
+
- lib/apollo-federation/scalar.rb
|
205
210
|
- lib/apollo-federation/schema.rb
|
206
211
|
- lib/apollo-federation/service.rb
|
207
212
|
- lib/apollo-federation/service_field.rb
|
@@ -211,6 +216,7 @@ files:
|
|
211
216
|
- lib/apollo-federation/tracing/proto/apollo.proto
|
212
217
|
- lib/apollo-federation/tracing/proto/apollo_pb.rb
|
213
218
|
- lib/apollo-federation/tracing/tracer.rb
|
219
|
+
- lib/apollo-federation/union.rb
|
214
220
|
- lib/apollo-federation/version.rb
|
215
221
|
homepage: https://github.com/Gusto/apollo-federation-ruby
|
216
222
|
licenses:
|