apollo-federation 0.4.0 → 0.4.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92f976bf624ea2dc6d01ddc126f2fd83d8e6f4f4ff8100aaa8d19f7121b55ac8
|
4
|
+
data.tar.gz: e6a6b9db376504172050286130adf835276021fadfd74801f69cde81717d8c1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7457cd2e513cbfb792a484e6bba2aace79aef7c79d0aebdb1f5323fa37e99ea7ba7ad3a1be42702bc5058713fd468dbd3c57b0891e27dbc4d5690b20fb6dce5d
|
7
|
+
data.tar.gz: 64f79b2ee040273c0304886f3ed025485db08c33077d101bbcb721a36f6ea71b51e255cfdd8422720a1370046100c358eefe1d5c2424c7332ba69c23a76a8f45
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [0.4.1](https://github.com/Gusto/apollo-federation-ruby/compare/v0.4.0...v0.4.1) (2019-10-12)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* Support lazy objects ([#17](https://github.com/Gusto/apollo-federation-ruby/issues/17)) ([68b0b9a](https://github.com/Gusto/apollo-federation-ruby/commit/68b0b9a))
|
7
|
+
|
1
8
|
# [0.4.0](https://github.com/Gusto/apollo-federation-ruby/compare/v0.3.2...v0.4.0) (2019-09-10)
|
2
9
|
|
3
10
|
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'graphql'
|
4
4
|
require 'apollo-federation/any'
|
5
|
+
require 'apollo-federation/entity_type_resolution_extension'
|
5
6
|
|
6
7
|
module ApolloFederation
|
7
8
|
module EntitiesField
|
@@ -15,6 +16,7 @@ module ApolloFederation
|
|
15
16
|
def define_entities_field(entity_type)
|
16
17
|
field(:_entities, [entity_type, null: true], null: false) do
|
17
18
|
argument :representations, [Any], required: true
|
19
|
+
extension(EntityTypeResolutionExtension)
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
@@ -38,13 +40,7 @@ module ApolloFederation
|
|
38
40
|
result = reference
|
39
41
|
end
|
40
42
|
|
41
|
-
|
42
|
-
# return the same object, it might not have the right type
|
43
|
-
# Right now, apollo-federation just adds a __typename property to the result,
|
44
|
-
# but I don't really like the idea of modifying the resolved object
|
45
|
-
context[result] = type
|
46
|
-
# TODO: Handle lazy objects?
|
47
|
-
result
|
43
|
+
[type, result]
|
48
44
|
end
|
49
45
|
end
|
50
46
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class EntityTypeResolutionExtension < GraphQL::Schema::FieldExtension
|
4
|
+
def after_resolve(value:, context:, **_rest)
|
5
|
+
synced_value =
|
6
|
+
value.map do |type, result|
|
7
|
+
[type, context.query.schema.sync_lazy(result)]
|
8
|
+
end
|
9
|
+
|
10
|
+
# TODO: This isn't 100% correct: if (for some reason) 2 different resolve_reference calls
|
11
|
+
# return the same object, it might not have the right type
|
12
|
+
# Right now, apollo-federation just adds a __typename property to the result,
|
13
|
+
# but I don't really like the idea of modifying the resolved object
|
14
|
+
synced_value.each { |type, result| context[result] = type }
|
15
|
+
|
16
|
+
synced_value.map { |_, result| result }
|
17
|
+
end
|
18
|
+
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: 0.4.
|
4
|
+
version: 0.4.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: 2019-
|
12
|
+
date: 2019-10-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: graphql
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- lib/apollo-federation/any.rb
|
156
156
|
- lib/apollo-federation/entities_field.rb
|
157
157
|
- lib/apollo-federation/entity.rb
|
158
|
+
- lib/apollo-federation/entity_type_resolution_extension.rb
|
158
159
|
- lib/apollo-federation/federated_document_from_schema_definition.rb
|
159
160
|
- lib/apollo-federation/field.rb
|
160
161
|
- lib/apollo-federation/has_directives.rb
|