graphql-stitching 1.6.0 → 1.6.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/.github/workflows/ci.yml +2 -0
- data/README.md +2 -2
- data/gemfiles/graphql_2.4.0.gemfile +9 -0
- data/lib/graphql/stitching/composer.rb +6 -17
- data/lib/graphql/stitching/executor/shaper.rb +5 -17
- data/lib/graphql/stitching/supergraph/to_definition.rb +1 -2
- data/lib/graphql/stitching/supergraph.rb +0 -2
- data/lib/graphql/stitching/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da2c14565c38d14e4e49f51ff2027f89a2ee4c0313102083c9ea3baadbcd02d4
|
4
|
+
data.tar.gz: eec311845ed143af3f8d598c22f2b6026a46d34868fd7546abfb585a8fed6ebc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87608b9f5391ec190e0d0f534e1a58447f056b37e37c3f569d908b2c7043d40ef38732b3bff6e4975d81d34b04bb84cd88f809b364d73aeade68675f8c35f35f
|
7
|
+
data.tar.gz: eb1e085ad36c36b52b0c871d9d8f3ff0ca5b6d29ff51c1ea6cd9564c0cdba8e554381615099a331426f4857b82049290287c79cc1338388a36027cb451aa3bb9
|
data/.github/workflows/ci.yml
CHANGED
data/README.md
CHANGED
@@ -74,7 +74,7 @@ result = client.execute(
|
|
74
74
|
|
75
75
|
Schemas provided in [location settings](./docs/composer.md#performing-composition) may be class-based schemas with local resolvers (locally-executable schemas), or schemas built from SDL strings (schema definition language parsed using `GraphQL::Schema.from_definition`) and mapped to remote locations via [executables](#executables).
|
76
76
|
|
77
|
-
|
77
|
+
A Client bundles up the component parts of stitching, which are worth familiarizing with:
|
78
78
|
|
79
79
|
- [Composer](./docs/composer.md) - merges and validates many schemas into one supergraph.
|
80
80
|
- [Supergraph](./docs/supergraph.md) - manages the combined schema, location routing maps, and executable resources. Can be exported, cached, and rehydrated.
|
@@ -87,7 +87,7 @@ While `Client` is sufficient for most usecases, the library offers several discr
|
|
87
87
|
|
88
88
|

|
89
89
|
|
90
|
-
To facilitate this, schemas should be designed around
|
90
|
+
To facilitate this, schemas should be designed around **merged type keys** that stitching can cross-reference and fetch across locations using **type resolver queries** (discussed below). For those in an Apollo ecosystem, there's also _limited_ support for merging types though [federation `_entities`](./docs/federation_entities.md).
|
91
91
|
|
92
92
|
### Merged type keys
|
93
93
|
|
@@ -13,13 +13,11 @@ module GraphQL
|
|
13
13
|
class Composer
|
14
14
|
# @api private
|
15
15
|
NO_DEFAULT_VALUE = begin
|
16
|
-
|
17
|
-
field(:f, String)
|
18
|
-
argument(:a, String)
|
19
|
-
end
|
16
|
+
t = Class.new(GraphQL::Schema::Object) do
|
17
|
+
field(:f, String) { _1.argument(:a, String) }
|
20
18
|
end
|
21
19
|
|
22
|
-
|
20
|
+
t.get_field("f").get_argument("a").default_value
|
23
21
|
end
|
24
22
|
|
25
23
|
# @api private
|
@@ -103,9 +101,8 @@ module GraphQL
|
|
103
101
|
@subgraph_types_by_name_and_location = schemas.each_with_object({}) do |(location, schema), memo|
|
104
102
|
raise CompositionError, "Location keys must be strings" unless location.is_a?(String)
|
105
103
|
|
106
|
-
introspection_types = schema.introspection_system.types.keys
|
107
104
|
schema.types.each do |type_name, subgraph_type|
|
108
|
-
next if
|
105
|
+
next if subgraph_type.introspection?
|
109
106
|
|
110
107
|
if type_name == @query_name && subgraph_type != schema.query
|
111
108
|
raise CompositionError, "Query name \"#{@query_name}\" is used by non-query type in #{location} schema."
|
@@ -373,6 +370,7 @@ module GraphQL
|
|
373
370
|
deprecation_reason: merge_deprecations(type_name, fields_by_location, field_name: field_name),
|
374
371
|
type: Util.unwrap_non_null(type),
|
375
372
|
null: !type.non_null?,
|
373
|
+
connection: false,
|
376
374
|
camelize: false,
|
377
375
|
)
|
378
376
|
|
@@ -403,14 +401,6 @@ module GraphQL
|
|
403
401
|
next
|
404
402
|
end
|
405
403
|
|
406
|
-
# Getting double args sometimes... why?
|
407
|
-
begin
|
408
|
-
next if owner.arguments(GraphQL::Query::NullContext.instance, false).key?(argument_name)
|
409
|
-
rescue ArgumentError
|
410
|
-
# pre- graphql v2.4.5
|
411
|
-
next if owner.arguments.key?(argument_name)
|
412
|
-
end
|
413
|
-
|
414
404
|
kwargs = {}
|
415
405
|
default_values_by_location = arguments_by_location.each_with_object({}) do |(location, argument), memo|
|
416
406
|
next if argument.default_value == NO_DEFAULT_VALUE
|
@@ -648,9 +638,8 @@ module GraphQL
|
|
648
638
|
writes = []
|
649
639
|
|
650
640
|
schemas.each do |schema|
|
651
|
-
introspection_types = schema.introspection_system.types.keys
|
652
641
|
schema.types.each_value do |type|
|
653
|
-
next if
|
642
|
+
next if type.introspection?
|
654
643
|
|
655
644
|
if type.kind.object? || type.kind.interface?
|
656
645
|
type.fields.each_value do |field|
|
@@ -31,8 +31,11 @@ module GraphQL::Stitching
|
|
31
31
|
when GraphQL::Language::Nodes::Field
|
32
32
|
field_name = node.alias || node.name
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
if @request.query.get_field(parent_type, node.name).introspection?
|
35
|
+
if node.name == TYPENAME && parent_type == @root_type
|
36
|
+
raw_object[field_name] = @root_type.graphql_name
|
37
|
+
end
|
38
|
+
next
|
36
39
|
end
|
37
40
|
|
38
41
|
node_type = @supergraph.memoized_schema_fields(parent_type.graphql_name)[node.name].type
|
@@ -100,21 +103,6 @@ module GraphQL::Stitching
|
|
100
103
|
resolved_list
|
101
104
|
end
|
102
105
|
|
103
|
-
def introspection_field?(parent_type, node)
|
104
|
-
return false unless node.name.start_with?("__")
|
105
|
-
is_root = parent_type == @root_type
|
106
|
-
|
107
|
-
case node.name
|
108
|
-
when TYPENAME
|
109
|
-
yield(is_root)
|
110
|
-
true
|
111
|
-
when "__schema", "__type"
|
112
|
-
is_root && @request.operation.operation_type == "query"
|
113
|
-
else
|
114
|
-
false
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
106
|
def typename_in_type?(typename, type)
|
119
107
|
return true if type.graphql_name == typename
|
120
108
|
|
@@ -17,10 +17,9 @@ module GraphQL::Stitching
|
|
17
17
|
field_map = {}
|
18
18
|
resolver_map = {}
|
19
19
|
possible_locations = {}
|
20
|
-
introspection_types = schema.introspection_system.types.keys
|
21
20
|
|
22
21
|
schema.types.each do |type_name, type|
|
23
|
-
next if
|
22
|
+
next if type.introspection?
|
24
23
|
|
25
24
|
# Collect/build key definitions for each type
|
26
25
|
locations_by_key = type.directives.each_with_object({}) do |directive, memo|
|
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.6.
|
4
|
+
version: 1.6.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: 2025-
|
11
|
+
date: 2025-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- gemfiles/graphql_2.1.0.gemfile
|
156
156
|
- gemfiles/graphql_2.2.0.gemfile
|
157
157
|
- gemfiles/graphql_2.3.0.gemfile
|
158
|
+
- gemfiles/graphql_2.4.0.gemfile
|
158
159
|
- graphql-stitching.gemspec
|
159
160
|
- lib/graphql/stitching.rb
|
160
161
|
- lib/graphql/stitching/client.rb
|