apollo-federation 1.1.2 → 1.1.3
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 +7 -0
- data/bin/prepare.rb +1 -1
- data/bin/rspec +29 -0
- data/lib/apollo-federation/entities_field.rb +8 -3
- data/lib/apollo-federation/tracing.rb +2 -0
- data/lib/apollo-federation/tracing/tracer.rb +14 -4
- data/lib/apollo-federation/version.rb +1 -1
- metadata +45 -3
- data/lib/apollo-federation/entity_type_resolution_extension.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8eef314d1457da9e7bd70ac5fe92c3d1168dfe340a3ba43a9d0e96475e44f027
|
4
|
+
data.tar.gz: 675b88c92096f8d73e240b8c8ab8dc2a5429b0c5d3249c50c74f98f50839a9bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5fb6b967baeeb09c89f60d52e7d25bff87966c20abb6f2577487316b3edd96afae6d400de968ecb92a3fd97ae0f06c057c1985e9f8d9a83fadc99392a0c8cc4
|
7
|
+
data.tar.gz: 6b4574b0c718229d0b7ae717bddffdc1347d1d678e63ac3afdae54f58c1d4d5973ac76641c22129cb2ec5d661ce902f56bc43f06baf433739ac364303c816876
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [1.1.3](https://github.com/Gusto/apollo-federation-ruby/compare/v1.1.2...v1.1.3) (2020-07-16)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* **tracing:** Properly handle tracing fields that resolve an array of lazy values ([#87](https://github.com/Gusto/apollo-federation-ruby/issues/87)) ([a9eed77](https://github.com/Gusto/apollo-federation-ruby/commit/a9eed77bbe5859456f93be00fbcafa02142ad5ed))
|
7
|
+
|
1
8
|
## [1.1.2](https://github.com/Gusto/apollo-federation-ruby/compare/v1.1.1...v1.1.2) (2020-06-09)
|
2
9
|
|
3
10
|
|
data/bin/prepare.rb
CHANGED
data/bin/rspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require 'pathname'
|
12
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
13
|
+
Pathname.new(__FILE__).realpath,)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path('bundle', __dir__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'rubygems'
|
27
|
+
require 'bundler/setup'
|
28
|
+
|
29
|
+
load Gem.bin_path('rspec-core', 'rspec')
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'graphql'
|
4
4
|
require 'apollo-federation/any'
|
5
|
-
require 'apollo-federation/entity_type_resolution_extension'
|
6
5
|
|
7
6
|
module ApolloFederation
|
8
7
|
module EntitiesField
|
@@ -23,7 +22,6 @@ module ApolloFederation
|
|
23
22
|
|
24
23
|
field(:_entities, [entity_type, null: true], null: false) do
|
25
24
|
argument :representations, [Any], required: true
|
26
|
-
extension(EntityTypeResolutionExtension)
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
@@ -47,7 +45,14 @@ module ApolloFederation
|
|
47
45
|
result = reference
|
48
46
|
end
|
49
47
|
|
50
|
-
|
48
|
+
context.schema.after_lazy(result) do |resolved_value|
|
49
|
+
# TODO: This isn't 100% correct: if (for some reason) 2 different resolve_reference calls
|
50
|
+
# return the same object, it might not have the right type
|
51
|
+
# Right now, apollo-federation just adds a __typename property to the result,
|
52
|
+
# but I don't really like the idea of modifying the resolved object
|
53
|
+
context[resolved_value] = type
|
54
|
+
resolved_value
|
55
|
+
end
|
51
56
|
end
|
52
57
|
end
|
53
58
|
end
|
@@ -27,6 +27,8 @@ Add `use ApolloFederation::Tracing` to your schema.'
|
|
27
27
|
return result unless result.context[:tracing_enabled]
|
28
28
|
|
29
29
|
trace = result.context.namespace(KEY)
|
30
|
+
# TODO: If there are errors during query validation, that could also cause a missing
|
31
|
+
# start_time
|
30
32
|
raise NotInstalledError unless trace[:start_time]
|
31
33
|
|
32
34
|
result['errors']&.each do |error|
|
@@ -159,17 +159,27 @@ module ApolloFederation
|
|
159
159
|
|
160
160
|
end_time_nanos = Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond)
|
161
161
|
|
162
|
-
#
|
162
|
+
# legacy runtime
|
163
163
|
if data.include?(:context)
|
164
|
-
context = data.fetch(:context)
|
165
164
|
path = context.path
|
166
|
-
|
167
|
-
|
165
|
+
field = context.field
|
166
|
+
else # interpreter runtime
|
168
167
|
path = data.fetch(:path)
|
168
|
+
field = data.fetch(:field)
|
169
169
|
end
|
170
170
|
|
171
171
|
trace = context.namespace(ApolloFederation::Tracing::KEY)
|
172
172
|
|
173
|
+
# When a field is resolved with an array of lazy values, the interpreter fires an
|
174
|
+
# `execute_field` for the resolution of the field and then a `execute_field_lazy` event for
|
175
|
+
# each lazy value in the array. Since the path here will contain an index (indicating which
|
176
|
+
# lazy value we're executing: e.g. ['arrayOfLazies', 0]), we won't have a node for the path.
|
177
|
+
# We only care about the end of the parent field (e.g. ['arrayOfLazies']), so we get the
|
178
|
+
# node for that path. What ends up happening is we update the end_time for the parent node
|
179
|
+
# for each of the lazy values. The last one that's executed becomes the final end time.
|
180
|
+
if field.type.list? && path.last.is_a?(Integer)
|
181
|
+
path = path[0...-1]
|
182
|
+
end
|
173
183
|
node = trace[:node_map].node_for_path(path)
|
174
184
|
node.end_time = end_time_nanos - trace[:start_time_nanos]
|
175
185
|
|
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: 1.1.
|
4
|
+
version: 1.1.3
|
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: 2020-
|
12
|
+
date: 2020-07-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: graphql
|
@@ -53,6 +53,34 @@ dependencies:
|
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: appraisal
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: debase
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
56
84
|
- !ruby/object:Gem::Dependency
|
57
85
|
name: pry-byebug
|
58
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,6 +165,20 @@ dependencies:
|
|
137
165
|
- - ">="
|
138
166
|
- !ruby/object:Gem::Version
|
139
167
|
version: '0'
|
168
|
+
- !ruby/object:Gem::Dependency
|
169
|
+
name: ruby-debug-ide
|
170
|
+
requirement: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
type: :development
|
176
|
+
prerelease: false
|
177
|
+
version_requirements: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
140
182
|
description: A Ruby implementation of Apollo Federation
|
141
183
|
email:
|
142
184
|
- noa.elad@gusto.com
|
@@ -151,11 +193,11 @@ files:
|
|
151
193
|
- bin/generate-protos.sh
|
152
194
|
- bin/prepare.rb
|
153
195
|
- bin/publish.rb
|
196
|
+
- bin/rspec
|
154
197
|
- lib/apollo-federation.rb
|
155
198
|
- lib/apollo-federation/any.rb
|
156
199
|
- lib/apollo-federation/entities_field.rb
|
157
200
|
- lib/apollo-federation/entity.rb
|
158
|
-
- lib/apollo-federation/entity_type_resolution_extension.rb
|
159
201
|
- lib/apollo-federation/federated_document_from_schema_definition.rb
|
160
202
|
- lib/apollo-federation/field.rb
|
161
203
|
- lib/apollo-federation/has_directives.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class EntityTypeResolutionExtension < GraphQL::Schema::FieldExtension
|
4
|
-
def after_resolve(value:, context:, **_rest)
|
5
|
-
value.map do |type, result|
|
6
|
-
context.schema.after_lazy(result) do |resolved_value|
|
7
|
-
# TODO: This isn't 100% correct: if (for some reason) 2 different resolve_reference calls
|
8
|
-
# return the same object, it might not have the right type
|
9
|
-
# Right now, apollo-federation just adds a __typename property to the result,
|
10
|
-
# but I don't really like the idea of modifying the resolved object
|
11
|
-
context[resolved_value] = type
|
12
|
-
resolved_value
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|