@graphql-tools/delegate 12.1.2-alpha-a25a0e4521aff5261d06903efe4386cd565f2e57 → 12.1.2

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,13 +1,11 @@
1
1
  # @graphql-tools/delegate
2
2
 
3
- ## 12.1.2-alpha-a25a0e4521aff5261d06903efe4386cd565f2e57
3
+ ## 12.1.2
4
4
  ### Patch Changes
5
5
 
6
6
 
7
7
 
8
- - [#2555](https://github.com/graphql-hive/gateway/pull/2555) [`a25a0e4`](https://github.com/graphql-hive/gateway/commit/a25a0e4521aff5261d06903efe4386cd565f2e57) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Flush deferred merged fields without blocking the initial payload
9
-
10
- Deferred fields on merged entity types are now delegated when their deferred resolvers run instead of being included in the initial delegation plan. This allows the initial payload to be delivered before slower merged subgraph fields resolve.
8
+ - [#2544](https://github.com/graphql-hive/gateway/pull/2544) [`af2cccb`](https://github.com/graphql-hive/gateway/commit/af2cccb7150db504ce42ab6b463166341377614f) Thanks [@egoodwinx](https://github.com/egoodwinx)! - Create new getCoercedVariableValues to support graphql-js 17
11
9
 
12
10
  ## 12.1.1
13
11
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -57,6 +57,16 @@ class Subschema {
57
57
  }
58
58
  }
59
59
 
60
+ function getCoercedVariableValues(variableValues) {
61
+ if (variableValues == null) {
62
+ return void 0;
63
+ }
64
+ if (Object.hasOwn(variableValues, "coerced") && Object.hasOwn(variableValues, "sources")) {
65
+ return variableValues.coerced;
66
+ }
67
+ return variableValues;
68
+ }
69
+
60
70
  const prototypePollutingKeys = [
61
71
  "__proto__",
62
72
  "constructor",
@@ -96,17 +106,19 @@ function getSubschema(object, responseKey) {
96
106
  function getUnpathedErrors(object) {
97
107
  return object[UNPATHED_ERRORS_SYMBOL];
98
108
  }
109
+ const EMPTY_ARRAY = [];
99
110
  const EMPTY_OBJECT = /* @__PURE__ */ Object.create(null);
100
111
  const getActualFieldNodes = utils.memoize1(function(fieldNode) {
101
112
  return [fieldNode];
102
113
  });
103
- function mergeFields(mergedTypeInfo, object, sourceSubschema, context, info, fieldNodes = info.fieldNodes) {
114
+ function mergeFields(mergedTypeInfo, object, sourceSubschema, context, info) {
115
+ const variableValues = getCoercedVariableValues(info.variableValues);
104
116
  const delegationMaps = mergedTypeInfo.delegationPlanBuilder(
105
117
  info.schema,
106
118
  sourceSubschema,
107
- info.variableValues != null && Object.keys(info.variableValues).length > 0 ? info.variableValues : EMPTY_OBJECT,
119
+ variableValues != null && Object.keys(variableValues).length > 0 ? variableValues : EMPTY_OBJECT,
108
120
  info.fragments != null && Object.keys(info.fragments).length > 0 ? info.fragments : EMPTY_OBJECT,
109
- fieldNodes.length === 1 && fieldNodes[0] ? getActualFieldNodes(fieldNodes[0]) : fieldNodes,
121
+ info.fieldNodes?.length ? info.fieldNodes.length === 1 && info.fieldNodes[0] ? getActualFieldNodes(info.fieldNodes[0]) : info.fieldNodes : EMPTY_ARRAY,
110
122
  context,
111
123
  info
112
124
  );
@@ -136,7 +148,7 @@ function handleResolverResult(resolverResult, subschema, selectionSet, object, c
136
148
  const { fields } = utils.collectFields(
137
149
  schema,
138
150
  info.fragments,
139
- info.variableValues,
151
+ getCoercedVariableValues(info.variableValues) ?? EMPTY_OBJECT,
140
152
  type,
141
153
  selectionSet
142
154
  );
@@ -820,7 +832,9 @@ function finalizeGatewayRequest(originalRequest, delegationContext, onOverlappin
820
832
  delegationContext
821
833
  );
822
834
  const newVariables = {};
823
- const outerVariables = delegationContext.info?.variableValues;
835
+ const outerVariables = getCoercedVariableValues(
836
+ delegationContext.info?.variableValues
837
+ );
824
838
  for (const varName of usedVariables) {
825
839
  const existingVar = originalRequest.variables?.[varName];
826
840
  const outerVar = outerVariables?.[varName];
@@ -2340,7 +2354,8 @@ function createRequest({
2340
2354
  `Either "targetFieldName" or a non empty "fieldNodes" array must be provided.`
2341
2355
  );
2342
2356
  }
2343
- const newVariables = info?.variableValues ? { ...info.variableValues } : {};
2357
+ const outerVariableValues = getCoercedVariableValues(info?.variableValues);
2358
+ const newVariables = outerVariableValues ? { ...outerVariableValues } : {};
2344
2359
  const variableDefinitions = info?.operation.variableDefinitions ? [...info.operation.variableDefinitions] : [];
2345
2360
  const argNodes = [];
2346
2361
  const replacedVariableNames = /* @__PURE__ */ new Set();
@@ -2381,7 +2396,7 @@ function createRequest({
2381
2396
  ) || // It should not conflict with the variable on the gateway request
2382
2397
  // Because the gateway request can have a variable that has nothing to do with
2383
2398
  // this argument
2384
- info?.variableValues?.[varName2] != null;
2399
+ outerVariableValues?.[varName2] != null;
2385
2400
  let varName = argName;
2386
2401
  if (varExists(varName)) {
2387
2402
  varName = `_${rootFieldName}_${argName}`;
@@ -2571,9 +2586,9 @@ function defaultMergedResolver(parent, args, context, info) {
2571
2586
  }
2572
2587
  const deferred = promiseHelpers.createDeferredPromise();
2573
2588
  missingDeferredFields.set(responseKey, deferred);
2574
- const stitchingInfo2 = info.schema.extensions?.["stitchingInfo"];
2575
- const parentTypeName2 = parent?.__typename || info.parentType.name;
2576
- const fieldNodesByType = stitchingInfo2?.fieldNodesByField?.[parentTypeName2]?.[info.fieldName];
2589
+ const stitchingInfo = info.schema.extensions?.["stitchingInfo"];
2590
+ const parentTypeName = parent?.__typename || info.parentType.name;
2591
+ const fieldNodesByType = stitchingInfo?.fieldNodesByField?.[parentTypeName]?.[info.fieldName];
2577
2592
  if (fieldNodesByType?.every((fieldNode) => {
2578
2593
  const responseKey2 = fieldNode.alias?.value ?? fieldNode.name.value;
2579
2594
  return Object.prototype.hasOwnProperty.call(parent, responseKey2);
@@ -2587,29 +2602,6 @@ function defaultMergedResolver(parent, args, context, info) {
2587
2602
  if (Object.prototype.hasOwnProperty.call(parent, info.fieldName)) {
2588
2603
  return graphql.defaultFieldResolver(parent, args, context, info);
2589
2604
  }
2590
- const stitchingInfo = info.schema?.extensions?.["stitchingInfo"];
2591
- const parentTypeName = parent.__typename || info.parentType?.name;
2592
- const mergedTypeInfo = parentTypeName ? stitchingInfo?.mergedTypes[parentTypeName] : void 0;
2593
- const sourceSubschema = parent[OBJECT_SUBSCHEMA_SYMBOL];
2594
- if (mergedTypeInfo && sourceSubschema) {
2595
- const fieldNode = {
2596
- kind: graphql.Kind.FIELD,
2597
- name: info.fieldNodes[0]?.name ?? {
2598
- kind: graphql.Kind.NAME,
2599
- value: info.fieldName
2600
- },
2601
- selectionSet: {
2602
- kind: graphql.Kind.SELECTION_SET,
2603
- selections: info.fieldNodes
2604
- }
2605
- };
2606
- return promiseHelpers.handleMaybePromise(
2607
- () => mergeFields(mergedTypeInfo, parent, sourceSubschema, context, info, [
2608
- fieldNode
2609
- ]),
2610
- () => Object.prototype.hasOwnProperty.call(parent, responseKey) ? handleResult(parent, responseKey, context, info) : void 0
2611
- );
2612
- }
2613
2605
  return void 0;
2614
2606
  }
2615
2607
  return handleResult(parent, responseKey, context, info);
@@ -2739,10 +2731,13 @@ function handleFlattenedParent(flattenedParent, leftOverParent, possibleSubschem
2739
2731
  responseKey
2740
2732
  );
2741
2733
  if (sourceSubschema && nestedTypeName) {
2734
+ const variableValues = getCoercedVariableValues(
2735
+ info.variableValues
2736
+ );
2742
2737
  const delegationPlan = stitchingInfo.mergedTypes[nestedTypeName]?.delegationPlanBuilder(
2743
2738
  info.schema,
2744
2739
  sourceSubschema,
2745
- info.variableValues != null && Object.keys(info.variableValues).length > 0 ? info.variableValues : EMPTY_OBJECT,
2740
+ variableValues != null && Object.keys(variableValues).length > 0 ? variableValues : EMPTY_OBJECT,
2746
2741
  info.fragments != null && Object.keys(info.fragments).length > 0 ? info.fragments : EMPTY_OBJECT,
2747
2742
  getActualFieldNodes(fieldNode),
2748
2743
  context,
@@ -3516,6 +3511,7 @@ Object.defineProperty(exports, "createDefaultExecutor", {
3516
3511
  enumerable: true,
3517
3512
  get: function () { return executor.executorFromSchema; }
3518
3513
  });
3514
+ exports.EMPTY_ARRAY = EMPTY_ARRAY;
3519
3515
  exports.EMPTY_OBJECT = EMPTY_OBJECT;
3520
3516
  exports.FIELD_SUBSCHEMA_MAP_SYMBOL = FIELD_SUBSCHEMA_MAP_SYMBOL;
3521
3517
  exports.OBJECT_SUBSCHEMA_SYMBOL = OBJECT_SUBSCHEMA_SYMBOL;
package/dist/index.d.cts CHANGED
@@ -199,9 +199,10 @@ declare function isExternalObject(data: any): data is ExternalObject;
199
199
  declare function annotateExternalObject<TContext>(object: any, errors: Array<GraphQLError>, subschema: GraphQLSchema | SubschemaConfig<any, any, any, TContext> | undefined, subschemaMap: Record<string, GraphQLSchema | SubschemaConfig<any, any, any, Record<string, any>>>): ExternalObject;
200
200
  declare function getSubschema(object: ExternalObject, responseKey: string): GraphQLSchema | SubschemaConfig;
201
201
  declare function getUnpathedErrors(object: ExternalObject): Array<GraphQLError>;
202
+ declare const EMPTY_ARRAY: any[];
202
203
  declare const EMPTY_OBJECT: any;
203
204
  declare const getActualFieldNodes: (fieldNode: FieldNode) => FieldNode[];
204
- declare function mergeFields<TContext>(mergedTypeInfo: MergedTypeInfo, object: any, sourceSubschema: Subschema<any, any, any, TContext>, context: any, info: GraphQLResolveInfo, fieldNodes?: FieldNode[]): MaybePromise<any>;
205
+ declare function mergeFields<TContext>(mergedTypeInfo: MergedTypeInfo, object: any, sourceSubschema: Subschema<any, any, any, TContext>, context: any, info: GraphQLResolveInfo): MaybePromise<any>;
205
206
  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;
206
207
 
207
208
  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;
@@ -238,4 +239,4 @@ declare function isPrototypePollutingKey(key: string): key is PrototypePolluting
238
239
 
239
240
  declare const handleOverrideByDelegation: (info: GraphQLResolveInfo$1, context: any, overrideHandler: OverrideHandler) => boolean;
240
241
 
241
- export { type BatchingOptions, type CreateProxyingResolverFn, type Deferred, type DelegationContext, type DelegationPlanBuilder, type DelegationPlanLeftOver, EMPTY_OBJECT, type ExternalObject, FIELD_SUBSCHEMA_MAP_SYMBOL, type ICreateProxyingResolverOptions, type ICreateRequest, type IDelegateRequestOptions, type IDelegateToSchemaOptions, type MergedFieldConfig, type MergedTypeConfig, type MergedTypeEntryPoint, type MergedTypeInfo, type MergedTypeResolver, type MergedTypeResolverOptions, OBJECT_SUBSCHEMA_SYMBOL, type OverrideHandler, PLAN_LEFT_OVER, type RequestTransform, type ResultTransform, type SchemaTransform, type StitchingInfo, Subschema, type SubschemaConfig, type Transform, Transformer, UNPATHED_ERRORS_SYMBOL, annotateExternalObject, applySchemaTransforms, cloneSubschemaConfig, createRequest, defaultMergedResolver, delegateRequest, delegateToSchema, extractUnavailableFields, extractUnavailableFieldsFromSelectionSet, getActualFieldNodes, getDelegatingOperation, getPlanLeftOverFromParent, getSubschema, getTypeInfo, getTypeInfoWithType, getUnpathedErrors, handleOverrideByDelegation, handleResolverResult, isExternalObject, isPrototypePollutingKey, isSubschema, isSubschemaConfig, leftOverByDelegationPlan, mergeFields, resolveExternalValue, subtractSelectionSets };
242
+ export { type BatchingOptions, type CreateProxyingResolverFn, type Deferred, type DelegationContext, type DelegationPlanBuilder, type DelegationPlanLeftOver, EMPTY_ARRAY, EMPTY_OBJECT, type ExternalObject, FIELD_SUBSCHEMA_MAP_SYMBOL, type ICreateProxyingResolverOptions, type ICreateRequest, type IDelegateRequestOptions, type IDelegateToSchemaOptions, type MergedFieldConfig, type MergedTypeConfig, type MergedTypeEntryPoint, type MergedTypeInfo, type MergedTypeResolver, type MergedTypeResolverOptions, OBJECT_SUBSCHEMA_SYMBOL, type OverrideHandler, PLAN_LEFT_OVER, type RequestTransform, type ResultTransform, type SchemaTransform, type StitchingInfo, Subschema, type SubschemaConfig, type Transform, Transformer, UNPATHED_ERRORS_SYMBOL, annotateExternalObject, applySchemaTransforms, cloneSubschemaConfig, createRequest, defaultMergedResolver, delegateRequest, delegateToSchema, extractUnavailableFields, extractUnavailableFieldsFromSelectionSet, getActualFieldNodes, getDelegatingOperation, getPlanLeftOverFromParent, getSubschema, getTypeInfo, getTypeInfoWithType, getUnpathedErrors, handleOverrideByDelegation, handleResolverResult, isExternalObject, isPrototypePollutingKey, isSubschema, isSubschemaConfig, leftOverByDelegationPlan, mergeFields, resolveExternalValue, subtractSelectionSets };
package/dist/index.d.ts CHANGED
@@ -199,9 +199,10 @@ declare function isExternalObject(data: any): data is ExternalObject;
199
199
  declare function annotateExternalObject<TContext>(object: any, errors: Array<GraphQLError>, subschema: GraphQLSchema | SubschemaConfig<any, any, any, TContext> | undefined, subschemaMap: Record<string, GraphQLSchema | SubschemaConfig<any, any, any, Record<string, any>>>): ExternalObject;
200
200
  declare function getSubschema(object: ExternalObject, responseKey: string): GraphQLSchema | SubschemaConfig;
201
201
  declare function getUnpathedErrors(object: ExternalObject): Array<GraphQLError>;
202
+ declare const EMPTY_ARRAY: any[];
202
203
  declare const EMPTY_OBJECT: any;
203
204
  declare const getActualFieldNodes: (fieldNode: FieldNode) => FieldNode[];
204
- declare function mergeFields<TContext>(mergedTypeInfo: MergedTypeInfo, object: any, sourceSubschema: Subschema<any, any, any, TContext>, context: any, info: GraphQLResolveInfo, fieldNodes?: FieldNode[]): MaybePromise<any>;
205
+ declare function mergeFields<TContext>(mergedTypeInfo: MergedTypeInfo, object: any, sourceSubschema: Subschema<any, any, any, TContext>, context: any, info: GraphQLResolveInfo): MaybePromise<any>;
205
206
  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;
206
207
 
207
208
  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;
@@ -238,4 +239,4 @@ declare function isPrototypePollutingKey(key: string): key is PrototypePolluting
238
239
 
239
240
  declare const handleOverrideByDelegation: (info: GraphQLResolveInfo$1, context: any, overrideHandler: OverrideHandler) => boolean;
240
241
 
241
- export { type BatchingOptions, type CreateProxyingResolverFn, type Deferred, type DelegationContext, type DelegationPlanBuilder, type DelegationPlanLeftOver, EMPTY_OBJECT, type ExternalObject, FIELD_SUBSCHEMA_MAP_SYMBOL, type ICreateProxyingResolverOptions, type ICreateRequest, type IDelegateRequestOptions, type IDelegateToSchemaOptions, type MergedFieldConfig, type MergedTypeConfig, type MergedTypeEntryPoint, type MergedTypeInfo, type MergedTypeResolver, type MergedTypeResolverOptions, OBJECT_SUBSCHEMA_SYMBOL, type OverrideHandler, PLAN_LEFT_OVER, type RequestTransform, type ResultTransform, type SchemaTransform, type StitchingInfo, Subschema, type SubschemaConfig, type Transform, Transformer, UNPATHED_ERRORS_SYMBOL, annotateExternalObject, applySchemaTransforms, cloneSubschemaConfig, createRequest, defaultMergedResolver, delegateRequest, delegateToSchema, extractUnavailableFields, extractUnavailableFieldsFromSelectionSet, getActualFieldNodes, getDelegatingOperation, getPlanLeftOverFromParent, getSubschema, getTypeInfo, getTypeInfoWithType, getUnpathedErrors, handleOverrideByDelegation, handleResolverResult, isExternalObject, isPrototypePollutingKey, isSubschema, isSubschemaConfig, leftOverByDelegationPlan, mergeFields, resolveExternalValue, subtractSelectionSets };
242
+ export { type BatchingOptions, type CreateProxyingResolverFn, type Deferred, type DelegationContext, type DelegationPlanBuilder, type DelegationPlanLeftOver, EMPTY_ARRAY, EMPTY_OBJECT, type ExternalObject, FIELD_SUBSCHEMA_MAP_SYMBOL, type ICreateProxyingResolverOptions, type ICreateRequest, type IDelegateRequestOptions, type IDelegateToSchemaOptions, type MergedFieldConfig, type MergedTypeConfig, type MergedTypeEntryPoint, type MergedTypeInfo, type MergedTypeResolver, type MergedTypeResolverOptions, OBJECT_SUBSCHEMA_SYMBOL, type OverrideHandler, PLAN_LEFT_OVER, type RequestTransform, type ResultTransform, type SchemaTransform, type StitchingInfo, Subschema, type SubschemaConfig, type Transform, Transformer, UNPATHED_ERRORS_SYMBOL, annotateExternalObject, applySchemaTransforms, cloneSubschemaConfig, createRequest, defaultMergedResolver, delegateRequest, delegateToSchema, extractUnavailableFields, extractUnavailableFieldsFromSelectionSet, getActualFieldNodes, getDelegatingOperation, getPlanLeftOverFromParent, getSubschema, getTypeInfo, getTypeInfoWithType, getUnpathedErrors, handleOverrideByDelegation, handleResolverResult, isExternalObject, isPrototypePollutingKey, isSubschema, isSubschemaConfig, leftOverByDelegationPlan, mergeFields, resolveExternalValue, subtractSelectionSets };
package/dist/index.js CHANGED
@@ -57,6 +57,16 @@ class Subschema {
57
57
  }
58
58
  }
59
59
 
60
+ function getCoercedVariableValues(variableValues) {
61
+ if (variableValues == null) {
62
+ return void 0;
63
+ }
64
+ if (Object.hasOwn(variableValues, "coerced") && Object.hasOwn(variableValues, "sources")) {
65
+ return variableValues.coerced;
66
+ }
67
+ return variableValues;
68
+ }
69
+
60
70
  const prototypePollutingKeys = [
61
71
  "__proto__",
62
72
  "constructor",
@@ -96,17 +106,19 @@ function getSubschema(object, responseKey) {
96
106
  function getUnpathedErrors(object) {
97
107
  return object[UNPATHED_ERRORS_SYMBOL];
98
108
  }
109
+ const EMPTY_ARRAY = [];
99
110
  const EMPTY_OBJECT = /* @__PURE__ */ Object.create(null);
100
111
  const getActualFieldNodes = memoize1(function(fieldNode) {
101
112
  return [fieldNode];
102
113
  });
103
- function mergeFields(mergedTypeInfo, object, sourceSubschema, context, info, fieldNodes = info.fieldNodes) {
114
+ function mergeFields(mergedTypeInfo, object, sourceSubschema, context, info) {
115
+ const variableValues = getCoercedVariableValues(info.variableValues);
104
116
  const delegationMaps = mergedTypeInfo.delegationPlanBuilder(
105
117
  info.schema,
106
118
  sourceSubschema,
107
- info.variableValues != null && Object.keys(info.variableValues).length > 0 ? info.variableValues : EMPTY_OBJECT,
119
+ variableValues != null && Object.keys(variableValues).length > 0 ? variableValues : EMPTY_OBJECT,
108
120
  info.fragments != null && Object.keys(info.fragments).length > 0 ? info.fragments : EMPTY_OBJECT,
109
- fieldNodes.length === 1 && fieldNodes[0] ? getActualFieldNodes(fieldNodes[0]) : fieldNodes,
121
+ info.fieldNodes?.length ? info.fieldNodes.length === 1 && info.fieldNodes[0] ? getActualFieldNodes(info.fieldNodes[0]) : info.fieldNodes : EMPTY_ARRAY,
110
122
  context,
111
123
  info
112
124
  );
@@ -136,7 +148,7 @@ function handleResolverResult(resolverResult, subschema, selectionSet, object, c
136
148
  const { fields } = collectFields(
137
149
  schema,
138
150
  info.fragments,
139
- info.variableValues,
151
+ getCoercedVariableValues(info.variableValues) ?? EMPTY_OBJECT,
140
152
  type,
141
153
  selectionSet
142
154
  );
@@ -820,7 +832,9 @@ function finalizeGatewayRequest(originalRequest, delegationContext, onOverlappin
820
832
  delegationContext
821
833
  );
822
834
  const newVariables = {};
823
- const outerVariables = delegationContext.info?.variableValues;
835
+ const outerVariables = getCoercedVariableValues(
836
+ delegationContext.info?.variableValues
837
+ );
824
838
  for (const varName of usedVariables) {
825
839
  const existingVar = originalRequest.variables?.[varName];
826
840
  const outerVar = outerVariables?.[varName];
@@ -2340,7 +2354,8 @@ function createRequest({
2340
2354
  `Either "targetFieldName" or a non empty "fieldNodes" array must be provided.`
2341
2355
  );
2342
2356
  }
2343
- const newVariables = info?.variableValues ? { ...info.variableValues } : {};
2357
+ const outerVariableValues = getCoercedVariableValues(info?.variableValues);
2358
+ const newVariables = outerVariableValues ? { ...outerVariableValues } : {};
2344
2359
  const variableDefinitions = info?.operation.variableDefinitions ? [...info.operation.variableDefinitions] : [];
2345
2360
  const argNodes = [];
2346
2361
  const replacedVariableNames = /* @__PURE__ */ new Set();
@@ -2381,7 +2396,7 @@ function createRequest({
2381
2396
  ) || // It should not conflict with the variable on the gateway request
2382
2397
  // Because the gateway request can have a variable that has nothing to do with
2383
2398
  // this argument
2384
- info?.variableValues?.[varName2] != null;
2399
+ outerVariableValues?.[varName2] != null;
2385
2400
  let varName = argName;
2386
2401
  if (varExists(varName)) {
2387
2402
  varName = `_${rootFieldName}_${argName}`;
@@ -2571,9 +2586,9 @@ function defaultMergedResolver(parent, args, context, info) {
2571
2586
  }
2572
2587
  const deferred = createDeferredPromise();
2573
2588
  missingDeferredFields.set(responseKey, deferred);
2574
- const stitchingInfo2 = info.schema.extensions?.["stitchingInfo"];
2575
- const parentTypeName2 = parent?.__typename || info.parentType.name;
2576
- const fieldNodesByType = stitchingInfo2?.fieldNodesByField?.[parentTypeName2]?.[info.fieldName];
2589
+ const stitchingInfo = info.schema.extensions?.["stitchingInfo"];
2590
+ const parentTypeName = parent?.__typename || info.parentType.name;
2591
+ const fieldNodesByType = stitchingInfo?.fieldNodesByField?.[parentTypeName]?.[info.fieldName];
2577
2592
  if (fieldNodesByType?.every((fieldNode) => {
2578
2593
  const responseKey2 = fieldNode.alias?.value ?? fieldNode.name.value;
2579
2594
  return Object.prototype.hasOwnProperty.call(parent, responseKey2);
@@ -2587,29 +2602,6 @@ function defaultMergedResolver(parent, args, context, info) {
2587
2602
  if (Object.prototype.hasOwnProperty.call(parent, info.fieldName)) {
2588
2603
  return defaultFieldResolver(parent, args, context, info);
2589
2604
  }
2590
- const stitchingInfo = info.schema?.extensions?.["stitchingInfo"];
2591
- const parentTypeName = parent.__typename || info.parentType?.name;
2592
- const mergedTypeInfo = parentTypeName ? stitchingInfo?.mergedTypes[parentTypeName] : void 0;
2593
- const sourceSubschema = parent[OBJECT_SUBSCHEMA_SYMBOL];
2594
- if (mergedTypeInfo && sourceSubschema) {
2595
- const fieldNode = {
2596
- kind: Kind.FIELD,
2597
- name: info.fieldNodes[0]?.name ?? {
2598
- kind: Kind.NAME,
2599
- value: info.fieldName
2600
- },
2601
- selectionSet: {
2602
- kind: Kind.SELECTION_SET,
2603
- selections: info.fieldNodes
2604
- }
2605
- };
2606
- return handleMaybePromise(
2607
- () => mergeFields(mergedTypeInfo, parent, sourceSubschema, context, info, [
2608
- fieldNode
2609
- ]),
2610
- () => Object.prototype.hasOwnProperty.call(parent, responseKey) ? handleResult(parent, responseKey, context, info) : void 0
2611
- );
2612
- }
2613
2605
  return void 0;
2614
2606
  }
2615
2607
  return handleResult(parent, responseKey, context, info);
@@ -2739,10 +2731,13 @@ function handleFlattenedParent(flattenedParent, leftOverParent, possibleSubschem
2739
2731
  responseKey
2740
2732
  );
2741
2733
  if (sourceSubschema && nestedTypeName) {
2734
+ const variableValues = getCoercedVariableValues(
2735
+ info.variableValues
2736
+ );
2742
2737
  const delegationPlan = stitchingInfo.mergedTypes[nestedTypeName]?.delegationPlanBuilder(
2743
2738
  info.schema,
2744
2739
  sourceSubschema,
2745
- info.variableValues != null && Object.keys(info.variableValues).length > 0 ? info.variableValues : EMPTY_OBJECT,
2740
+ variableValues != null && Object.keys(variableValues).length > 0 ? variableValues : EMPTY_OBJECT,
2746
2741
  info.fragments != null && Object.keys(info.fragments).length > 0 ? info.fragments : EMPTY_OBJECT,
2747
2742
  getActualFieldNodes(fieldNode),
2748
2743
  context,
@@ -3508,4 +3503,4 @@ function subtractSelectionSets(selectionSetA, selectionSetB, fragments = {}) {
3508
3503
  };
3509
3504
  }
3510
3505
 
3511
- export { EMPTY_OBJECT, FIELD_SUBSCHEMA_MAP_SYMBOL, OBJECT_SUBSCHEMA_SYMBOL, PLAN_LEFT_OVER, Subschema, Transformer, UNPATHED_ERRORS_SYMBOL, annotateExternalObject, applySchemaTransforms, cloneSubschemaConfig, createRequest, defaultMergedResolver, delegateRequest, delegateToSchema, extractUnavailableFields, extractUnavailableFieldsFromSelectionSet, getActualFieldNodes, getDelegatingOperation, getPlanLeftOverFromParent, getSubschema, getTypeInfo, getTypeInfoWithType, getUnpathedErrors, handleOverrideByDelegation, handleResolverResult, isExternalObject, isPrototypePollutingKey, isSubschema, isSubschemaConfig, leftOverByDelegationPlan, mergeFields, resolveExternalValue, subtractSelectionSets };
3506
+ export { EMPTY_ARRAY, EMPTY_OBJECT, FIELD_SUBSCHEMA_MAP_SYMBOL, OBJECT_SUBSCHEMA_SYMBOL, PLAN_LEFT_OVER, Subschema, Transformer, UNPATHED_ERRORS_SYMBOL, annotateExternalObject, applySchemaTransforms, cloneSubschemaConfig, createRequest, defaultMergedResolver, delegateRequest, delegateToSchema, extractUnavailableFields, extractUnavailableFieldsFromSelectionSet, getActualFieldNodes, getDelegatingOperation, getPlanLeftOverFromParent, getSubschema, getTypeInfo, getTypeInfoWithType, getUnpathedErrors, handleOverrideByDelegation, handleResolverResult, isExternalObject, isPrototypePollutingKey, isSubschema, isSubschemaConfig, leftOverByDelegationPlan, mergeFields, resolveExternalValue, subtractSelectionSets };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/delegate",
3
- "version": "12.1.2-alpha-a25a0e4521aff5261d06903efe4386cd565f2e57",
3
+ "version": "12.1.2",
4
4
  "type": "module",
5
5
  "description": "A set of utils for faster development of GraphQL tools",
6
6
  "repository": {