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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 227a7813eed1050c451d9bbee900305cfbac67aff35baa88f6ba9551535d1e97
4
- data.tar.gz: 1533e6109c6a72af3f7d07891714c09a73476ca0a5a7ea53d83cbe829564ace3
3
+ metadata.gz: da2c14565c38d14e4e49f51ff2027f89a2ee4c0313102083c9ea3baadbcd02d4
4
+ data.tar.gz: eec311845ed143af3f8d598c22f2b6026a46d34868fd7546abfb585a8fed6ebc
5
5
  SHA512:
6
- metadata.gz: 8342158a10bc25fb68c833a3366c2fd6e831cf86cccf15a2491067680bb5299700783af57fd5042b394131b48759f077d32f4b210149a2b3cb34e43e3cca77ff
7
- data.tar.gz: 7313c93bb8cedf7ac06708a1f7fba6a2c46196982380a28a6d9244cf7320ad0149cb17df8ecb1abe438e14eac08b2f71e154dd9f2d6c3095be8e849c46061e16
6
+ metadata.gz: 87608b9f5391ec190e0d0f534e1a58447f056b37e37c3f569d908b2c7043d40ef38732b3bff6e4975d81d34b04bb84cd88f809b364d73aeade68675f8c35f35f
7
+ data.tar.gz: eb1e085ad36c36b52b0c871d9d8f3ff0ca5b6d29ff51c1ea6cd9564c0cdba8e554381615099a331426f4857b82049290287c79cc1338388a36027cb451aa3bb9
@@ -14,6 +14,8 @@ jobs:
14
14
  include:
15
15
  - gemfile: Gemfile
16
16
  ruby: 3.3
17
+ - gemfile: gemfiles/graphql_2.4.0.gemfile
18
+ ruby: 3.2
17
19
  - gemfile: gemfiles/graphql_2.3.0.gemfile
18
20
  ruby: 3.2
19
21
  - gemfile: gemfiles/graphql_2.2.0.gemfile
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
- While `Client` is sufficient for most usecases, the library offers several discrete components that can be assembled into tailored workflows:
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
  ![Merging types](./docs/images/merging.png)
89
89
 
90
- To facilitate this, schemas should be designed around [merged type keys](#merged-type-keys) that stitching can cross-reference and fetch across locations using [type resolver queries](#merged-type-resolver-queries). For those in an Apollo ecosystem, there's also _limited_ support for merging types though a [federation `_entities` protocol](./docs/federation_entities.md).
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
 
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'graphql', '~> 2.4.0'
6
+ gem 'warning'
7
+ gem 'minitest-stub-const'
8
+
9
+ gemspec path: "../"
@@ -13,13 +13,11 @@ module GraphQL
13
13
  class Composer
14
14
  # @api private
15
15
  NO_DEFAULT_VALUE = begin
16
- class T < GraphQL::Schema::Object
17
- field(:f, String) do
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
- T.get_field("f").get_argument("a").default_value
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 introspection_types.include?(type_name)
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 introspection_types.include?(type.graphql_name)
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
- next if introspection_field?(parent_type, node) do |is_root_typename|
35
- raw_object[field_name] = @root_type.graphql_name if is_root_typename
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 introspection_types.include?(type_name)
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|
@@ -20,8 +20,6 @@ module GraphQL
20
20
 
21
21
  def initialize(schema:, fields: {}, resolvers: {}, executables: {})
22
22
  @schema = schema
23
- @schema.use(GraphQL::Schema::AlwaysVisible)
24
-
25
23
  @resolvers = resolvers
26
24
  @resolvers_by_version = nil
27
25
  @fields_by_type_and_location = nil
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module Stitching
5
- VERSION = "1.6.0"
5
+ VERSION = "1.6.1"
6
6
  end
7
7
  end
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.0
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-03-17 00:00:00.000000000 Z
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