graphql-stitching 1.4.3 → 1.5.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 +4 -4
- data/.gitignore +4 -0
- data/README.md +10 -7
- data/docs/README.md +1 -0
- data/docs/client.md +6 -0
- data/docs/composer.md +1 -1
- data/docs/subscriptions.md +208 -0
- data/docs/{resolver.md → type_resolver.md} +3 -3
- data/examples/subscriptions/.gitattributes +9 -0
- data/examples/subscriptions/.gitignore +35 -0
- data/examples/subscriptions/Gemfile +65 -0
- data/examples/subscriptions/README.md +38 -0
- data/examples/subscriptions/Rakefile +6 -0
- data/examples/subscriptions/app/channels/graphql_channel.rb +50 -0
- data/examples/subscriptions/app/controllers/graphql_controller.rb +44 -0
- data/examples/subscriptions/app/graphql/entities_schema.rb +42 -0
- data/examples/subscriptions/app/graphql/stitched_schema.rb +10 -0
- data/examples/subscriptions/app/graphql/subscriptions_schema.rb +54 -0
- data/examples/subscriptions/app/models/repository.rb +39 -0
- data/examples/subscriptions/app/views/graphql/client.html.erb +159 -0
- data/examples/subscriptions/bin/bundle +109 -0
- data/examples/subscriptions/bin/docker-entrypoint +8 -0
- data/examples/subscriptions/bin/importmap +4 -0
- data/examples/subscriptions/bin/rails +4 -0
- data/examples/subscriptions/bin/rake +4 -0
- data/examples/subscriptions/bin/setup +33 -0
- data/examples/subscriptions/config/application.rb +14 -0
- data/examples/subscriptions/config/boot.rb +4 -0
- data/examples/subscriptions/config/cable.yml +10 -0
- data/examples/subscriptions/config/credentials.yml.enc +1 -0
- data/examples/subscriptions/config/database.yml +25 -0
- data/examples/subscriptions/config/environment.rb +5 -0
- data/examples/subscriptions/config/environments/development.rb +74 -0
- data/examples/subscriptions/config/environments/production.rb +91 -0
- data/examples/subscriptions/config/environments/test.rb +64 -0
- data/examples/subscriptions/config/initializers/content_security_policy.rb +25 -0
- data/examples/subscriptions/config/initializers/filter_parameter_logging.rb +8 -0
- data/examples/subscriptions/config/initializers/inflections.rb +16 -0
- data/examples/subscriptions/config/initializers/permissions_policy.rb +13 -0
- data/examples/subscriptions/config/locales/en.yml +31 -0
- data/examples/subscriptions/config/master.key +1 -0
- data/examples/subscriptions/config/puma.rb +35 -0
- data/examples/subscriptions/config/routes.rb +8 -0
- data/examples/subscriptions/config/storage.yml +34 -0
- data/examples/subscriptions/config.ru +6 -0
- data/examples/subscriptions/db/seeds.rb +9 -0
- data/examples/subscriptions/public/404.html +17 -0
- data/examples/subscriptions/public/422.html +17 -0
- data/examples/subscriptions/public/500.html +16 -0
- data/examples/subscriptions/public/apple-touch-icon-precomposed.png +0 -0
- data/examples/subscriptions/public/apple-touch-icon.png +0 -0
- data/examples/subscriptions/public/favicon.ico +0 -0
- data/examples/subscriptions/public/robots.txt +1 -0
- data/lib/graphql/stitching/client.rb +18 -11
- data/lib/graphql/stitching/composer/{resolver_config.rb → type_resolver_config.rb} +3 -3
- data/lib/graphql/stitching/composer/{validate_resolvers.rb → validate_type_resolvers.rb} +8 -2
- data/lib/graphql/stitching/composer.rb +48 -42
- data/lib/graphql/stitching/executor/shaper.rb +3 -3
- data/lib/graphql/stitching/executor/{resolver_source.rb → type_resolver_source.rb} +2 -2
- data/lib/graphql/stitching/executor.rb +19 -11
- data/lib/graphql/stitching/http_executable.rb +3 -0
- data/lib/graphql/stitching/plan.rb +1 -1
- data/lib/graphql/stitching/planner/step.rb +1 -1
- data/lib/graphql/stitching/planner.rb +29 -15
- data/lib/graphql/stitching/{skip_include.rb → request/skip_include.rb} +3 -3
- data/lib/graphql/stitching/request.rb +44 -6
- data/lib/graphql/stitching/supergraph/to_definition.rb +3 -3
- data/lib/graphql/stitching/supergraph.rb +6 -3
- data/lib/graphql/stitching/{resolver → type_resolver}/arguments.rb +7 -7
- data/lib/graphql/stitching/{resolver → type_resolver}/keys.rb +3 -4
- data/lib/graphql/stitching/{resolver.rb → type_resolver.rb} +5 -5
- data/lib/graphql/stitching/util.rb +1 -0
- data/lib/graphql/stitching/version.rb +1 -1
- data/lib/graphql/stitching.rb +32 -4
- metadata +56 -10
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module GraphQL::Stitching
|
4
|
-
class
|
4
|
+
class TypeResolver
|
5
5
|
# Defines a single resolver argument structure
|
6
6
|
# @api private
|
7
7
|
class Argument
|
@@ -129,9 +129,9 @@ module GraphQL::Stitching
|
|
129
129
|
end
|
130
130
|
|
131
131
|
def verify_key(arg, key)
|
132
|
-
key_field = value.reduce(
|
133
|
-
if ns ==
|
134
|
-
|
132
|
+
key_field = value.reduce(TypeResolver::KeyField.new("", inner: key)) do |field, ns|
|
133
|
+
if ns == TYPENAME
|
134
|
+
TypeResolver::KeyField.new(TYPENAME)
|
135
135
|
elsif field
|
136
136
|
field.inner.find { _1.name == ns }
|
137
137
|
end
|
@@ -146,7 +146,7 @@ module GraphQL::Stitching
|
|
146
146
|
|
147
147
|
def build(origin_obj)
|
148
148
|
value.each_with_index.reduce(origin_obj) do |obj, (ns, idx)|
|
149
|
-
obj[idx.zero? ?
|
149
|
+
obj[idx.zero? ? TypeResolver.export_key(ns) : ns]
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
@@ -174,7 +174,7 @@ module GraphQL::Stitching
|
|
174
174
|
# Parses an argument template string into resolver arguments via schema casting.
|
175
175
|
# @param template [String] the template string to parse.
|
176
176
|
# @param field_def [GraphQL::Schema::FieldDefinition] a field definition providing arguments schema.
|
177
|
-
# @return [[GraphQL::Stitching::
|
177
|
+
# @return [[GraphQL::Stitching::TypeResolver::Argument]] an array of resolver arguments.
|
178
178
|
def parse_arguments_with_field(template, field_def)
|
179
179
|
ast = parse_arg_defs(template)
|
180
180
|
args = build_argument_set(ast, field_def.arguments)
|
@@ -196,7 +196,7 @@ module GraphQL::Stitching
|
|
196
196
|
# Parses an argument template string into resolver arguments via SDL casting.
|
197
197
|
# @param template [String] the template string to parse.
|
198
198
|
# @param type_defs [String] the type definition string declaring argument types.
|
199
|
-
# @return [[GraphQL::Stitching::
|
199
|
+
# @return [[GraphQL::Stitching::TypeResolver::Argument]] an array of resolver arguments.
|
200
200
|
def parse_arguments_with_type_defs(template, type_defs)
|
201
201
|
type_map = parse_type_defs(type_defs)
|
202
202
|
parse_arg_defs(template).map { build_argument(_1, type_struct: type_map[_1.name]) }
|
@@ -1,9 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module GraphQL::Stitching
|
4
|
-
class
|
4
|
+
class TypeResolver
|
5
5
|
EXPORT_PREFIX = "_export_"
|
6
|
-
TYPE_NAME = "__typename"
|
7
6
|
|
8
7
|
class FieldNode
|
9
8
|
# GraphQL Ruby changed the argument assigning Field.alias from
|
@@ -59,8 +58,8 @@ module GraphQL::Stitching
|
|
59
58
|
|
60
59
|
EMPTY_FIELD_SET = KeyFieldSet.new(GraphQL::Stitching::EMPTY_ARRAY)
|
61
60
|
TYPENAME_EXPORT_NODE = FieldNode.build(
|
62
|
-
field_alias: "#{EXPORT_PREFIX}#{
|
63
|
-
field_name:
|
61
|
+
field_alias: "#{EXPORT_PREFIX}#{TYPENAME}",
|
62
|
+
field_name: TYPENAME,
|
64
63
|
)
|
65
64
|
|
66
65
|
class Key < KeyFieldSet
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "
|
4
|
-
require_relative "
|
3
|
+
require_relative "type_resolver/arguments"
|
4
|
+
require_relative "type_resolver/keys"
|
5
5
|
|
6
6
|
module GraphQL
|
7
7
|
module Stitching
|
8
|
-
# Defines a
|
9
|
-
class
|
8
|
+
# Defines a type resolver query that provides direct access to an entity type.
|
9
|
+
class TypeResolver
|
10
10
|
extend ArgumentsParser
|
11
11
|
extend KeysParser
|
12
12
|
|
@@ -47,7 +47,7 @@ module GraphQL
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def version
|
50
|
-
@version ||=
|
50
|
+
@version ||= Stitching.digest.call("#{Stitching::VERSION}/#{as_json.to_json}")
|
51
51
|
end
|
52
52
|
|
53
53
|
def ==(other)
|
data/lib/graphql/stitching.rb
CHANGED
@@ -4,7 +4,22 @@ require "graphql"
|
|
4
4
|
|
5
5
|
module GraphQL
|
6
6
|
module Stitching
|
7
|
+
# scope name of query operations.
|
8
|
+
QUERY_OP = "query"
|
9
|
+
|
10
|
+
# scope name of mutation operations.
|
11
|
+
MUTATION_OP = "mutation"
|
12
|
+
|
13
|
+
# scope name of subscription operations.
|
14
|
+
SUBSCRIPTION_OP = "subscription"
|
15
|
+
|
16
|
+
# introspection typename field.
|
17
|
+
TYPENAME = "__typename"
|
18
|
+
|
19
|
+
# @api private
|
7
20
|
EMPTY_OBJECT = {}.freeze
|
21
|
+
|
22
|
+
# @api private
|
8
23
|
EMPTY_ARRAY = [].freeze
|
9
24
|
|
10
25
|
class StitchingError < StandardError; end
|
@@ -12,12 +27,26 @@ module GraphQL
|
|
12
27
|
class ValidationError < CompositionError; end
|
13
28
|
|
14
29
|
class << self
|
30
|
+
attr_writer :stitch_directive
|
31
|
+
|
32
|
+
# Proc used to compute digests; uses SHA2 by default.
|
33
|
+
# @returns [Proc] proc used to compute digests.
|
34
|
+
def digest(&block)
|
35
|
+
if block_given?
|
36
|
+
@digest = block
|
37
|
+
else
|
38
|
+
@digest ||= ->(str) { Digest::SHA2.hexdigest(str) }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Name of the directive used to mark type resolvers.
|
43
|
+
# @returns [String] name of the type resolver directive.
|
15
44
|
def stitch_directive
|
16
45
|
@stitch_directive ||= "stitch"
|
17
46
|
end
|
18
47
|
|
19
|
-
|
20
|
-
|
48
|
+
# Names of stitching directives to omit from the composed supergraph.
|
49
|
+
# @returns [Array<String>] list of stitching directive names.
|
21
50
|
def stitching_directive_names
|
22
51
|
[stitch_directive]
|
23
52
|
end
|
@@ -33,7 +62,6 @@ require_relative "stitching/http_executable"
|
|
33
62
|
require_relative "stitching/plan"
|
34
63
|
require_relative "stitching/planner"
|
35
64
|
require_relative "stitching/request"
|
36
|
-
require_relative "stitching/
|
37
|
-
require_relative "stitching/skip_include"
|
65
|
+
require_relative "stitching/type_resolver"
|
38
66
|
require_relative "stitching/util"
|
39
67
|
require_relative "stitching/version"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-stitching
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg MacWilliam
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -89,8 +89,9 @@ files:
|
|
89
89
|
- docs/images/stitching.png
|
90
90
|
- docs/mechanics.md
|
91
91
|
- docs/request.md
|
92
|
-
- docs/
|
92
|
+
- docs/subscriptions.md
|
93
93
|
- docs/supergraph.md
|
94
|
+
- docs/type_resolver.md
|
94
95
|
- examples/file_uploads/Gemfile
|
95
96
|
- examples/file_uploads/Procfile
|
96
97
|
- examples/file_uploads/README.md
|
@@ -105,6 +106,51 @@ files:
|
|
105
106
|
- examples/merged_types/graphiql.html
|
106
107
|
- examples/merged_types/remote1.rb
|
107
108
|
- examples/merged_types/remote2.rb
|
109
|
+
- examples/subscriptions/.gitattributes
|
110
|
+
- examples/subscriptions/.gitignore
|
111
|
+
- examples/subscriptions/Gemfile
|
112
|
+
- examples/subscriptions/README.md
|
113
|
+
- examples/subscriptions/Rakefile
|
114
|
+
- examples/subscriptions/app/channels/graphql_channel.rb
|
115
|
+
- examples/subscriptions/app/controllers/graphql_controller.rb
|
116
|
+
- examples/subscriptions/app/graphql/entities_schema.rb
|
117
|
+
- examples/subscriptions/app/graphql/stitched_schema.rb
|
118
|
+
- examples/subscriptions/app/graphql/subscriptions_schema.rb
|
119
|
+
- examples/subscriptions/app/models/repository.rb
|
120
|
+
- examples/subscriptions/app/views/graphql/client.html.erb
|
121
|
+
- examples/subscriptions/bin/bundle
|
122
|
+
- examples/subscriptions/bin/docker-entrypoint
|
123
|
+
- examples/subscriptions/bin/importmap
|
124
|
+
- examples/subscriptions/bin/rails
|
125
|
+
- examples/subscriptions/bin/rake
|
126
|
+
- examples/subscriptions/bin/setup
|
127
|
+
- examples/subscriptions/config.ru
|
128
|
+
- examples/subscriptions/config/application.rb
|
129
|
+
- examples/subscriptions/config/boot.rb
|
130
|
+
- examples/subscriptions/config/cable.yml
|
131
|
+
- examples/subscriptions/config/credentials.yml.enc
|
132
|
+
- examples/subscriptions/config/database.yml
|
133
|
+
- examples/subscriptions/config/environment.rb
|
134
|
+
- examples/subscriptions/config/environments/development.rb
|
135
|
+
- examples/subscriptions/config/environments/production.rb
|
136
|
+
- examples/subscriptions/config/environments/test.rb
|
137
|
+
- examples/subscriptions/config/initializers/content_security_policy.rb
|
138
|
+
- examples/subscriptions/config/initializers/filter_parameter_logging.rb
|
139
|
+
- examples/subscriptions/config/initializers/inflections.rb
|
140
|
+
- examples/subscriptions/config/initializers/permissions_policy.rb
|
141
|
+
- examples/subscriptions/config/locales/en.yml
|
142
|
+
- examples/subscriptions/config/master.key
|
143
|
+
- examples/subscriptions/config/puma.rb
|
144
|
+
- examples/subscriptions/config/routes.rb
|
145
|
+
- examples/subscriptions/config/storage.yml
|
146
|
+
- examples/subscriptions/db/seeds.rb
|
147
|
+
- examples/subscriptions/public/404.html
|
148
|
+
- examples/subscriptions/public/422.html
|
149
|
+
- examples/subscriptions/public/500.html
|
150
|
+
- examples/subscriptions/public/apple-touch-icon-precomposed.png
|
151
|
+
- examples/subscriptions/public/apple-touch-icon.png
|
152
|
+
- examples/subscriptions/public/favicon.ico
|
153
|
+
- examples/subscriptions/public/robots.txt
|
108
154
|
- gemfiles/graphql_1.13.9.gemfile
|
109
155
|
- gemfiles/graphql_2.0.0.gemfile
|
110
156
|
- gemfiles/graphql_2.1.0.gemfile
|
@@ -114,27 +160,27 @@ files:
|
|
114
160
|
- lib/graphql/stitching/client.rb
|
115
161
|
- lib/graphql/stitching/composer.rb
|
116
162
|
- lib/graphql/stitching/composer/base_validator.rb
|
117
|
-
- lib/graphql/stitching/composer/
|
163
|
+
- lib/graphql/stitching/composer/type_resolver_config.rb
|
118
164
|
- lib/graphql/stitching/composer/validate_interfaces.rb
|
119
|
-
- lib/graphql/stitching/composer/
|
165
|
+
- lib/graphql/stitching/composer/validate_type_resolvers.rb
|
120
166
|
- lib/graphql/stitching/executor.rb
|
121
|
-
- lib/graphql/stitching/executor/resolver_source.rb
|
122
167
|
- lib/graphql/stitching/executor/root_source.rb
|
123
168
|
- lib/graphql/stitching/executor/shaper.rb
|
169
|
+
- lib/graphql/stitching/executor/type_resolver_source.rb
|
124
170
|
- lib/graphql/stitching/http_executable.rb
|
125
171
|
- lib/graphql/stitching/plan.rb
|
126
172
|
- lib/graphql/stitching/planner.rb
|
127
173
|
- lib/graphql/stitching/planner/step.rb
|
128
174
|
- lib/graphql/stitching/request.rb
|
129
|
-
- lib/graphql/stitching/
|
130
|
-
- lib/graphql/stitching/resolver/arguments.rb
|
131
|
-
- lib/graphql/stitching/resolver/keys.rb
|
132
|
-
- lib/graphql/stitching/skip_include.rb
|
175
|
+
- lib/graphql/stitching/request/skip_include.rb
|
133
176
|
- lib/graphql/stitching/supergraph.rb
|
134
177
|
- lib/graphql/stitching/supergraph/key_directive.rb
|
135
178
|
- lib/graphql/stitching/supergraph/resolver_directive.rb
|
136
179
|
- lib/graphql/stitching/supergraph/source_directive.rb
|
137
180
|
- lib/graphql/stitching/supergraph/to_definition.rb
|
181
|
+
- lib/graphql/stitching/type_resolver.rb
|
182
|
+
- lib/graphql/stitching/type_resolver/arguments.rb
|
183
|
+
- lib/graphql/stitching/type_resolver/keys.rb
|
138
184
|
- lib/graphql/stitching/util.rb
|
139
185
|
- lib/graphql/stitching/version.rb
|
140
186
|
homepage: https://github.com/gmac/graphql-stitching-ruby
|