@graphql-tools/delegate 12.3.4 → 12.3.5-alpha-ddb49918835ecc42874592c15b6b37f21d31433e

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,5 +1,18 @@
1
1
  # @graphql-tools/delegate
2
2
 
3
+ ## 12.3.5-alpha-ddb49918835ecc42874592c15b6b37f21d31433e
4
+ ### Patch Changes
5
+
6
+
7
+
8
+ - [#2751](https://github.com/graphql-hive/gateway/pull/2751) [`b180423`](https://github.com/graphql-hive/gateway/commit/b1804230911a8cd047ee0953304469ff4cb6b131) Thanks [@aarne](https://github.com/aarne)! - Do not add a `null` item to a streamed list when the subgraph ends the stream with `{ "hasNext": false }`
9
+
10
+
11
+
12
+ - [#2767](https://github.com/graphql-hive/gateway/pull/2767) [`537901e`](https://github.com/graphql-hive/gateway/commit/537901e52a07ec93cd78fd3836f6223447064383) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Resolve `@interfaceObject` fields on an implementation that another subgraph extends directly
13
+
14
+ Previously the field resolved to `null` without an error, because only the implementation's subgraphs were considered and the `@interfaceObject` subgraph was never called.
15
+
3
16
  ## 12.3.4
4
17
  ### Patch Changes
5
18
 
package/dist/index.cjs CHANGED
@@ -121,7 +121,7 @@ const EMPTY_OBJECT = /* @__PURE__ */ Object.create(null);
121
121
  const getActualFieldNodes = utils.memoize1(function(fieldNode) {
122
122
  return [fieldNode];
123
123
  });
124
- function mergeFields(mergedTypeInfo, object, sourceSubschema, context, info, fieldNodes = info.fieldNodes) {
124
+ function mergeFields(mergedTypeInfo, object, sourceSubschema, context, info, fieldNodes = info.fieldNodes, skipSubschema) {
125
125
  const variableValues = getCoercedVariableValues(info.variableValues);
126
126
  const delegationMaps = mergedTypeInfo.delegationPlanBuilder(
127
127
  info.schema,
@@ -141,7 +141,11 @@ function mergeFields(mergedTypeInfo, object, sourceSubschema, context, info, fie
141
141
  delegationMaps,
142
142
  (_, delegationMap) => executeDelegationStage(
143
143
  mergedTypeInfo,
144
- delegationMap,
144
+ skipSubschema ? new Map(
145
+ Array.from(delegationMap).filter(
146
+ ([subschema]) => !skipSubschema(subschema)
147
+ )
148
+ ) : delegationMap,
145
149
  object,
146
150
  context,
147
151
  info
@@ -420,6 +424,29 @@ function resolveExternalObject(type, object, unpathedErrors, subschema, context,
420
424
  if (!mergedTypeInfo) {
421
425
  return object;
422
426
  }
427
+ const abstractMergedTypeInfo = mergedTypeInfo.typeName === type.name ? void 0 : stitchingInfo.mergedTypes[type.name];
428
+ const knowsConcreteType = (targetSubschema) => !!targetSubschema.transformedSchema.getType(object.__typename);
429
+ if (abstractMergedTypeInfo?.targetSubschemas.get(subschema)?.some((targetSubschema) => !knowsConcreteType(targetSubschema))) {
430
+ return promiseHelpers.handleMaybePromise(
431
+ () => mergeFields(
432
+ mergedTypeInfo,
433
+ object,
434
+ subschema,
435
+ context,
436
+ info
437
+ ),
438
+ () => mergeFields(
439
+ abstractMergedTypeInfo,
440
+ object,
441
+ subschema,
442
+ context,
443
+ info,
444
+ void 0,
445
+ // the concrete merge above already covered these
446
+ knowsConcreteType
447
+ )
448
+ );
449
+ }
423
450
  return mergeFields(
424
451
  mergedTypeInfo,
425
452
  object,
@@ -4414,6 +4441,12 @@ async function* streamListIterable(executorResult, transformer) {
4414
4441
  }
4415
4442
  continue;
4416
4443
  }
4444
+ if (result.data === void 0 && !result.errors?.length) {
4445
+ if (result.hasNext === false) {
4446
+ return;
4447
+ }
4448
+ continue;
4449
+ }
4417
4450
  const transformedResult = await transformer.transformResult(result);
4418
4451
  if (Array.isArray(transformedResult)) {
4419
4452
  for (let i = pushedCount; i < transformedResult.length; i++) {
package/dist/index.d.cts CHANGED
@@ -218,7 +218,7 @@ declare function getSubschema(object: ExternalObject, responseKey: string): Grap
218
218
  declare function getUnpathedErrors(object: ExternalObject): Array<GraphQLError>;
219
219
  declare const EMPTY_OBJECT: any;
220
220
  declare const getActualFieldNodes: (fieldNode: FieldNode) => FieldNode[];
221
- declare function mergeFields<TContext>(mergedTypeInfo: MergedTypeInfo, object: any, sourceSubschema: Subschema<any, any, any, TContext>, context: any, info: GraphQLResolveInfo, fieldNodes?: FieldNode[]): MaybePromise<any>;
221
+ declare function mergeFields<TContext>(mergedTypeInfo: MergedTypeInfo, object: any, sourceSubschema: Subschema<any, any, any, TContext>, context: any, info: GraphQLResolveInfo, fieldNodes?: FieldNode[], skipSubschema?: (subschema: Subschema) => boolean): MaybePromise<any>;
222
222
  declare function handleResolverResult(resolverResult: any, subschema: Subschema, selectionSet: SelectionSetNode, object: ExternalObject, combinedFieldSubschemaMap: Record<string, GraphQLSchema | SubschemaConfig<any, any, any, Record<string, any>>>, info: GraphQLResolveInfo, path: Array<string | number>, combinedErrors: Array<GraphQLError>): void;
223
223
 
224
224
  declare function resolveExternalValue<TContext extends Record<string, any>>(result: any, unpathedErrors: Array<GraphQLError>, subschema: GraphQLSchema | SubschemaConfig<any, any, any, TContext>, context?: Record<string, any>, info?: GraphQLResolveInfo, returnType?: GraphQLOutputType, skipTypeMerging?: boolean): any;
package/dist/index.d.ts CHANGED
@@ -218,7 +218,7 @@ declare function getSubschema(object: ExternalObject, responseKey: string): Grap
218
218
  declare function getUnpathedErrors(object: ExternalObject): Array<GraphQLError>;
219
219
  declare const EMPTY_OBJECT: any;
220
220
  declare const getActualFieldNodes: (fieldNode: FieldNode) => FieldNode[];
221
- declare function mergeFields<TContext>(mergedTypeInfo: MergedTypeInfo, object: any, sourceSubschema: Subschema<any, any, any, TContext>, context: any, info: GraphQLResolveInfo, fieldNodes?: FieldNode[]): MaybePromise<any>;
221
+ declare function mergeFields<TContext>(mergedTypeInfo: MergedTypeInfo, object: any, sourceSubschema: Subschema<any, any, any, TContext>, context: any, info: GraphQLResolveInfo, fieldNodes?: FieldNode[], skipSubschema?: (subschema: Subschema) => boolean): MaybePromise<any>;
222
222
  declare function handleResolverResult(resolverResult: any, subschema: Subschema, selectionSet: SelectionSetNode, object: ExternalObject, combinedFieldSubschemaMap: Record<string, GraphQLSchema | SubschemaConfig<any, any, any, Record<string, any>>>, info: GraphQLResolveInfo, path: Array<string | number>, combinedErrors: Array<GraphQLError>): void;
223
223
 
224
224
  declare function resolveExternalValue<TContext extends Record<string, any>>(result: any, unpathedErrors: Array<GraphQLError>, subschema: GraphQLSchema | SubschemaConfig<any, any, any, TContext>, context?: Record<string, any>, info?: GraphQLResolveInfo, returnType?: GraphQLOutputType, skipTypeMerging?: boolean): any;
package/dist/index.js CHANGED
@@ -121,7 +121,7 @@ const EMPTY_OBJECT = /* @__PURE__ */ Object.create(null);
121
121
  const getActualFieldNodes = memoize1(function(fieldNode) {
122
122
  return [fieldNode];
123
123
  });
124
- function mergeFields(mergedTypeInfo, object, sourceSubschema, context, info, fieldNodes = info.fieldNodes) {
124
+ function mergeFields(mergedTypeInfo, object, sourceSubschema, context, info, fieldNodes = info.fieldNodes, skipSubschema) {
125
125
  const variableValues = getCoercedVariableValues(info.variableValues);
126
126
  const delegationMaps = mergedTypeInfo.delegationPlanBuilder(
127
127
  info.schema,
@@ -141,7 +141,11 @@ function mergeFields(mergedTypeInfo, object, sourceSubschema, context, info, fie
141
141
  delegationMaps,
142
142
  (_, delegationMap) => executeDelegationStage(
143
143
  mergedTypeInfo,
144
- delegationMap,
144
+ skipSubschema ? new Map(
145
+ Array.from(delegationMap).filter(
146
+ ([subschema]) => !skipSubschema(subschema)
147
+ )
148
+ ) : delegationMap,
145
149
  object,
146
150
  context,
147
151
  info
@@ -420,6 +424,29 @@ function resolveExternalObject(type, object, unpathedErrors, subschema, context,
420
424
  if (!mergedTypeInfo) {
421
425
  return object;
422
426
  }
427
+ const abstractMergedTypeInfo = mergedTypeInfo.typeName === type.name ? void 0 : stitchingInfo.mergedTypes[type.name];
428
+ const knowsConcreteType = (targetSubschema) => !!targetSubschema.transformedSchema.getType(object.__typename);
429
+ if (abstractMergedTypeInfo?.targetSubschemas.get(subschema)?.some((targetSubschema) => !knowsConcreteType(targetSubschema))) {
430
+ return handleMaybePromise(
431
+ () => mergeFields(
432
+ mergedTypeInfo,
433
+ object,
434
+ subschema,
435
+ context,
436
+ info
437
+ ),
438
+ () => mergeFields(
439
+ abstractMergedTypeInfo,
440
+ object,
441
+ subschema,
442
+ context,
443
+ info,
444
+ void 0,
445
+ // the concrete merge above already covered these
446
+ knowsConcreteType
447
+ )
448
+ );
449
+ }
423
450
  return mergeFields(
424
451
  mergedTypeInfo,
425
452
  object,
@@ -4414,6 +4441,12 @@ async function* streamListIterable(executorResult, transformer) {
4414
4441
  }
4415
4442
  continue;
4416
4443
  }
4444
+ if (result.data === void 0 && !result.errors?.length) {
4445
+ if (result.hasNext === false) {
4446
+ return;
4447
+ }
4448
+ continue;
4449
+ }
4417
4450
  const transformedResult = await transformer.transformResult(result);
4418
4451
  if (Array.isArray(transformedResult)) {
4419
4452
  for (let i = pushedCount; i < transformedResult.length; i++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/delegate",
3
- "version": "12.3.4",
3
+ "version": "12.3.5-alpha-ddb49918835ecc42874592c15b6b37f21d31433e",
4
4
  "type": "module",
5
5
  "description": "A set of utils for faster development of GraphQL tools",
6
6
  "repository": {