@graphql-tools/stitch 10.1.20-alpha-cc6e877dd43c47e20e00638efc161a0bed4e2ccb → 10.1.20

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.
package/CHANGELOG.md CHANGED
@@ -1,44 +1,12 @@
1
1
  # @graphql-tools/stitch
2
2
 
3
- ## 10.1.20-alpha-cc6e877dd43c47e20e00638efc161a0bed4e2ccb
3
+ ## 10.1.20
4
4
  ### Patch Changes
5
5
 
6
-
7
-
8
- - [#2351](https://github.com/graphql-hive/gateway/pull/2351) [`96a4674`](https://github.com/graphql-hive/gateway/commit/96a4674a514e93d69c299c07916e06f49feed477) Thanks [@ardatan](https://github.com/ardatan)! - Fix `@provides` so the gateway only requests the provided fields the client actually selected, and stops delegating to the owner subgraph when `@provides` already covers the request.
9
-
10
- Previously, when a subgraph declared `@provides(fields: "...")` on a field, the gateway would still:
11
-
12
- 1. Forward **every** field listed in `@provides` to that subgraph, even when the client never asked for them.
13
- 2. After receiving the response, plan additional delegations to the owner subgraph for `@provides`-covered fields whenever the providing subgraph declared them as `@external`, even though the data was already returned.
14
-
15
- For example with:
16
-
17
- ```graphql
18
- # subgraph B (provider)
19
- type Query {
20
- entity: Entity @provides(fields: "name description")
21
- }
22
-
23
- type Entity @key(fields: "id") {
24
- id: ID!
25
- name: String! @external
26
- description: String! @external
27
- }
28
- ```
29
-
30
- a client query of `{ entity { id name } }` would still cause the gateway to ask subgraph B for `description` *and* fetch `name` again from subgraph A (the owner of `Entity`).
31
-
32
- After this fix:
33
-
34
- - Only the `@provides` fields the client actually selected are forwarded to the providing subgraph (request side).
35
- - The delegation planner now recognises `@provides` declarations at every nested level (e.g. `@provides(fields: "categories { id name subCategories { id name } }")`) and `@provides` declarations made via inline fragments on union/interface members (e.g. `@provides(fields: "... on Book { title }")`), so the gateway no longer round-trips to the owner subgraph for fields that the providing subgraph has already returned.
36
-
37
- Aliases, fragments, fragment spreads, `@include`/`@skip` directives wrapping a `@provides` field, and nested `@provides` selections are preserved.
38
- - Updated dependencies [[`96a4674`](https://github.com/graphql-hive/gateway/commit/96a4674a514e93d69c299c07916e06f49feed477)]:
39
- - @graphql-tools/delegate@12.0.17-alpha-cc6e877dd43c47e20e00638efc161a0bed4e2ccb
40
- - @graphql-tools/batch-delegate@10.0.23-alpha-cc6e877dd43c47e20e00638efc161a0bed4e2ccb
41
- - @graphql-tools/wrap@11.1.16-alpha-cc6e877dd43c47e20e00638efc161a0bed4e2ccb
6
+ - Updated dependencies [[`3e774e0`](https://github.com/graphql-hive/gateway/commit/3e774e050bc2d3c33e0f36a258ab6a8d94bf0750)]:
7
+ - @graphql-tools/delegate@12.0.17
8
+ - @graphql-tools/batch-delegate@10.0.23
9
+ - @graphql-tools/wrap@11.1.16
42
10
 
43
11
  ## 10.1.19
44
12
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -108,14 +108,9 @@ function getFieldsNotInSubschema(schema, stitchingInfo, gatewayType, subschemaTy
108
108
  kind: graphql.Kind.SELECTION_SET,
109
109
  selections: subFieldNodes
110
110
  };
111
- const flattenedProvided = flattenSelectionsForType(
112
- providedSelectionNode,
113
- gatewayType,
114
- schema
115
- );
116
111
  const subtracted = delegate.subtractSelectionSets(
117
112
  subFieldSelection,
118
- flattenedProvided
113
+ providedSelectionNode
119
114
  );
120
115
  if (subtracted?.selections?.length) {
121
116
  fieldNotInSchema = true;
@@ -214,38 +209,6 @@ function addMissingRequiredFields({
214
209
  }
215
210
  }
216
211
  }
217
- const flattenSelectionsForTypeImpl = (selectionSet, gatewayType, schema) => {
218
- let changed = false;
219
- const flat = [];
220
- for (const selection of selectionSet.selections) {
221
- if (selection.kind === graphql.Kind.INLINE_FRAGMENT) {
222
- const condName = selection.typeCondition?.name.value;
223
- const condType = condName ? schema.getType(condName) : gatewayType;
224
- const matchesGatewayType = condType != null && (condType.name === gatewayType.name || graphql.isAbstractType(condType) && schema.isSubType(condType, gatewayType));
225
- if (matchesGatewayType) {
226
- changed = true;
227
- const inner = flattenSelectionsForType(
228
- selection.selectionSet,
229
- gatewayType,
230
- schema
231
- );
232
- for (const innerSel of inner.selections) {
233
- flat.push(innerSel);
234
- }
235
- continue;
236
- }
237
- }
238
- flat.push(selection);
239
- }
240
- if (!changed) {
241
- return selectionSet;
242
- }
243
- return {
244
- kind: graphql.Kind.SELECTION_SET,
245
- selections: flat
246
- };
247
- };
248
- const flattenSelectionsForType = utils.memoize3(flattenSelectionsForTypeImpl);
249
212
 
250
213
  function memoize5of7(fn) {
251
214
  const memoize5Cache = /* @__PURE__ */ new WeakMap();
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { handleOverrideByDelegation, subtractSelectionSets, extractUnavailableFields, leftOverByDelegationPlan, extractUnavailableFieldsFromSelectionSet, delegateToSchema, cloneSubschemaConfig, isSubschemaConfig, defaultMergedResolver, Subschema } from '@graphql-tools/delegate';
2
2
  import { mergeType, mergeInputType, mergeInterface, mergeUnion, mergeEnum, mergeScalar, mergeTypeDefs, mergeResolvers, mergeExtensions, applyExtensions } from '@graphql-tools/merge';
3
3
  import { extendResolversFromInterfaces, addResolversToSchema, assertResolversPresent, makeExecutableSchema } from '@graphql-tools/schema';
4
- import { collectSubFields, memoize3, memoize2, memoize1, parseSelectionSet, collectFields, isSome, getImplementingTypes, getRootTypeNames, filterSchema, mergeDeep, getDescription, createNamedStub, createStub, getRootTypeMap, getRootTypes, inspect, rewireTypes, getOperationASTFromRequest, getDefinedRootType, getArgumentValues } from '@graphql-tools/utils';
4
+ import { collectSubFields, memoize2, memoize1, memoize3, parseSelectionSet, collectFields, isSome, getImplementingTypes, getRootTypeNames, filterSchema, mergeDeep, getDescription, createNamedStub, createStub, getRootTypeMap, getRootTypes, inspect, rewireTypes, getOperationASTFromRequest, getDefinedRootType, getArgumentValues } from '@graphql-tools/utils';
5
5
  import { isAbstractType, Kind, TypeNameMetaFieldDef, getNamedType, GraphQLList, isLeafType, isInputObjectType, isUnionType, print, isObjectType, isInterfaceType, visit, isScalarType, isCompositeType, isNonNullType, isEnumType, isListType, getNullableType, isNullableType, GraphQLObjectType, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLUnionType, GraphQLEnumType, GraphQLScalarType, GraphQLDirective, valueFromASTUntyped, getDirectiveValues, GraphQLDeprecatedDirective, DirectiveLocation, isNamedType, isIntrospectionType, isDirective, isSpecifiedScalarType, specifiedDirectives, GraphQLSchema, extendSchema } from 'graphql';
6
6
  import { handleMaybePromise } from '@whatwg-node/promise-helpers';
7
7
  import { batchDelegateToSchema } from '@graphql-tools/batch-delegate';
@@ -106,14 +106,9 @@ function getFieldsNotInSubschema(schema, stitchingInfo, gatewayType, subschemaTy
106
106
  kind: Kind.SELECTION_SET,
107
107
  selections: subFieldNodes
108
108
  };
109
- const flattenedProvided = flattenSelectionsForType(
110
- providedSelectionNode,
111
- gatewayType,
112
- schema
113
- );
114
109
  const subtracted = subtractSelectionSets(
115
110
  subFieldSelection,
116
- flattenedProvided
111
+ providedSelectionNode
117
112
  );
118
113
  if (subtracted?.selections?.length) {
119
114
  fieldNotInSchema = true;
@@ -212,38 +207,6 @@ function addMissingRequiredFields({
212
207
  }
213
208
  }
214
209
  }
215
- const flattenSelectionsForTypeImpl = (selectionSet, gatewayType, schema) => {
216
- let changed = false;
217
- const flat = [];
218
- for (const selection of selectionSet.selections) {
219
- if (selection.kind === Kind.INLINE_FRAGMENT) {
220
- const condName = selection.typeCondition?.name.value;
221
- const condType = condName ? schema.getType(condName) : gatewayType;
222
- const matchesGatewayType = condType != null && (condType.name === gatewayType.name || isAbstractType(condType) && schema.isSubType(condType, gatewayType));
223
- if (matchesGatewayType) {
224
- changed = true;
225
- const inner = flattenSelectionsForType(
226
- selection.selectionSet,
227
- gatewayType,
228
- schema
229
- );
230
- for (const innerSel of inner.selections) {
231
- flat.push(innerSel);
232
- }
233
- continue;
234
- }
235
- }
236
- flat.push(selection);
237
- }
238
- if (!changed) {
239
- return selectionSet;
240
- }
241
- return {
242
- kind: Kind.SELECTION_SET,
243
- selections: flat
244
- };
245
- };
246
- const flattenSelectionsForType = memoize3(flattenSelectionsForTypeImpl);
247
210
 
248
211
  function memoize5of7(fn) {
249
212
  const memoize5Cache = /* @__PURE__ */ new WeakMap();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/stitch",
3
- "version": "10.1.20-alpha-cc6e877dd43c47e20e00638efc161a0bed4e2ccb",
3
+ "version": "10.1.20",
4
4
  "type": "module",
5
5
  "description": "A set of utils for faster development of GraphQL tools",
6
6
  "repository": {
@@ -38,13 +38,13 @@
38
38
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
39
39
  },
40
40
  "dependencies": {
41
- "@graphql-tools/batch-delegate": "10.0.23-alpha-cc6e877dd43c47e20e00638efc161a0bed4e2ccb",
42
- "@graphql-tools/delegate": "12.0.17-alpha-cc6e877dd43c47e20e00638efc161a0bed4e2ccb",
41
+ "@graphql-tools/batch-delegate": "^10.0.23",
42
+ "@graphql-tools/delegate": "^12.0.17",
43
43
  "@graphql-tools/executor": "^1.4.13",
44
44
  "@graphql-tools/merge": "^9.1.5",
45
45
  "@graphql-tools/schema": "^10.0.29",
46
46
  "@graphql-tools/utils": "^11.0.0",
47
- "@graphql-tools/wrap": "11.1.16-alpha-cc6e877dd43c47e20e00638efc161a0bed4e2ccb",
47
+ "@graphql-tools/wrap": "^11.1.16",
48
48
  "@whatwg-node/promise-helpers": "^1.3.2",
49
49
  "tslib": "^2.8.1"
50
50
  },