@graphql-tools/delegate 10.2.11 → 10.2.12-alpha-bb010bd4b613397bc4e6ba96149dc972a0ef0997

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,16 @@
1
1
  # @graphql-tools/delegate
2
2
 
3
+ ## 10.2.12-alpha-bb010bd4b613397bc4e6ba96149dc972a0ef0997
4
+
5
+ ### Patch Changes
6
+
7
+ - [#620](https://github.com/graphql-hive/gateway/pull/620) [`d72209a`](https://github.com/graphql-hive/gateway/commit/d72209ad82ec53689f93ce5d81bfa52493919ad9) Thanks [@renovate](https://github.com/apps/renovate)! - dependencies updates:
8
+
9
+ - Updated dependency [`@graphql-tools/utils@^10.8.1` ↗︎](https://www.npmjs.com/package/@graphql-tools/utils/v/10.8.1) (from `^10.7.0`, in `dependencies`)
10
+
11
+ - Updated dependencies [[`d72209a`](https://github.com/graphql-hive/gateway/commit/d72209ad82ec53689f93ce5d81bfa52493919ad9)]:
12
+ - @graphql-tools/batch-execute@9.0.12-alpha-bb010bd4b613397bc4e6ba96149dc972a0ef0997
13
+
3
14
  ## 10.2.11
4
15
 
5
16
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -72,7 +72,7 @@ function getPlanLeftOverFromParent(parent) {
72
72
  if (parent != null && typeof parent === "object") {
73
73
  return parent[PLAN_LEFT_OVER];
74
74
  }
75
- return undefined;
75
+ return void 0;
76
76
  }
77
77
 
78
78
  const UNPATHED_ERRORS_SYMBOL = Symbol.for("subschemaErrors");
@@ -80,7 +80,7 @@ const OBJECT_SUBSCHEMA_SYMBOL = Symbol.for("initialSubschema");
80
80
  const FIELD_SUBSCHEMA_MAP_SYMBOL = Symbol.for("subschemaMap");
81
81
 
82
82
  function isExternalObject(data) {
83
- return data[UNPATHED_ERRORS_SYMBOL] !== undefined;
83
+ return data[UNPATHED_ERRORS_SYMBOL] !== void 0;
84
84
  }
85
85
  function annotateExternalObject(object, errors, subschema, subschemaMap) {
86
86
  Object.defineProperties(object, {
@@ -127,7 +127,7 @@ function mergeFields(mergedTypeInfo, object, sourceSubschema, context, info) {
127
127
  info
128
128
  )
129
129
  ),
130
- undefined
130
+ void 0
131
131
  ),
132
132
  () => object
133
133
  );
@@ -190,7 +190,7 @@ function handleResolverResult(resolverResult, subschema, selectionSet, object, c
190
190
  object[responseKey] = existingPropValue.map(
191
191
  (existingElement, index) => sourcePropValue instanceof Error ? existingElement : utils.mergeDeep(
192
192
  [existingElement, sourcePropValue[index]],
193
- undefined,
193
+ void 0,
194
194
  true,
195
195
  true
196
196
  )
@@ -198,7 +198,7 @@ function handleResolverResult(resolverResult, subschema, selectionSet, object, c
198
198
  } else if (!(sourcePropValue instanceof Error)) {
199
199
  object[responseKey] = utils.mergeDeep(
200
200
  [existingPropValue, sourcePropValue],
201
- undefined,
201
+ void 0,
202
202
  true,
203
203
  true
204
204
  );
@@ -416,7 +416,7 @@ function reportUnpathedErrorsViaNull(unpathedErrors) {
416
416
  if (unreportedErrors.length === 1 && unreportedError) {
417
417
  return graphql.locatedError(
418
418
  unreportedError,
419
- undefined,
419
+ void 0,
420
420
  unreportedError.path
421
421
  );
422
422
  }
@@ -427,7 +427,7 @@ function reportUnpathedErrorsViaNull(unpathedErrors) {
427
427
  // locatedError path argument must be defined, but it is just forwarded to a constructor that allows a undefined value
428
428
  // https://github.com/graphql/graphql-js/blob/b4bff0ba9c15c9d7245dd68556e754c41f263289/src/error/locatedError.js#L25
429
429
  // https://github.com/graphql/graphql-js/blob/b4bff0ba9c15c9d7245dd68556e754c41f263289/src/error/GraphQLError.js#L19
430
- graphql.locatedError(e, undefined, unreportedError?.path)
430
+ graphql.locatedError(e, void 0, unreportedError?.path)
431
431
  )
432
432
  ),
433
433
  unreportedErrors.map((error) => error.message).join(", \n")
@@ -457,9 +457,9 @@ function checkResultAndHandleErrors(result = {
457
457
  onLocatedError
458
458
  } = delegationContext;
459
459
  const { data, unpathedErrors } = mergeDataAndErrors(
460
- result.data == null ? undefined : result.data[responseKey],
460
+ result.data == null ? void 0 : result.data[responseKey],
461
461
  result.errors == null ? [] : result.errors,
462
- info != null && info.path ? graphql.responsePathAsArray(info.path) : undefined,
462
+ info != null && info.path ? graphql.responsePathAsArray(info.path) : void 0,
463
463
  onLocatedError
464
464
  );
465
465
  return resolveExternalValue(
@@ -479,7 +479,7 @@ function mergeDataAndErrors(data, errors, path, onLocatedError, index = 1) {
479
479
  }
480
480
  if (errors.length === 1 && errors[0]) {
481
481
  const error = onLocatedError ? onLocatedError(errors[0]) : errors[0];
482
- const newPath = path === undefined ? error.path : !error.path ? path : path.concat(error.path.slice(1));
482
+ const newPath = path === void 0 ? error.path : !error.path ? path : path.concat(error.path.slice(1));
483
483
  return { data: utils.relocatedError(errors[0], newPath), unpathedErrors: [] };
484
484
  }
485
485
  const combinedError = new AggregateError(
@@ -489,7 +489,7 @@ function mergeDataAndErrors(data, errors, path, onLocatedError, index = 1) {
489
489
  // locatedError path argument must be defined, but it is just forwarded to a constructor that allows a undefined value
490
490
  // https://github.com/graphql/graphql-js/blob/b4bff0ba9c15c9d7245dd68556e754c41f263289/src/error/locatedError.js#L25
491
491
  // https://github.com/graphql/graphql-js/blob/b4bff0ba9c15c9d7245dd68556e754c41f263289/src/error/GraphQLError.js#L19
492
- graphql.locatedError(e, undefined, path)
492
+ graphql.locatedError(e, void 0, path)
493
493
  )
494
494
  ),
495
495
  errors.map((error) => error.message).join(", \n")
@@ -505,7 +505,7 @@ function mergeDataAndErrors(data, errors, path, onLocatedError, index = 1) {
505
505
  const pathSegment = error.path?.[index];
506
506
  if (pathSegment != null) {
507
507
  let pathSegmentErrors = errorMap.get(pathSegment);
508
- if (pathSegmentErrors === undefined) {
508
+ if (pathSegmentErrors === void 0) {
509
509
  pathSegmentErrors = [error];
510
510
  errorMap.set(pathSegment, pathSegmentErrors);
511
511
  } else {
@@ -516,7 +516,7 @@ function mergeDataAndErrors(data, errors, path, onLocatedError, index = 1) {
516
516
  }
517
517
  }
518
518
  for (const [pathSegment, pathSegmentErrors] of errorMap) {
519
- if (data[pathSegment] !== undefined) {
519
+ if (data[pathSegment] !== void 0) {
520
520
  const { data: newData, unpathedErrors: newErrors } = mergeDataAndErrors(
521
521
  data[pathSegment],
522
522
  pathSegmentErrors,
@@ -571,9 +571,55 @@ const getTypeInfo = utils.memoize1(function getTypeInfo2(schema) {
571
571
  return new graphql.TypeInfo(schema);
572
572
  });
573
573
  const getTypeInfoWithType = utils.memoize2(function getTypeInfoWithType2(schema, type) {
574
- return graphql.versionInfo.major < 16 ? new graphql.TypeInfo(schema, undefined, type) : new graphql.TypeInfo(schema, type);
574
+ return graphql.versionInfo.major < 16 ? new graphql.TypeInfo(schema, void 0, type) : new graphql.TypeInfo(schema, type);
575
575
  });
576
576
 
577
+ function updateArgument(argumentNodes, variableDefinitionsMap, variableValues, argName, varName, type, value) {
578
+ argumentNodes[argName] = {
579
+ kind: graphql.Kind.ARGUMENT,
580
+ name: {
581
+ kind: graphql.Kind.NAME,
582
+ value: argName
583
+ },
584
+ value: {
585
+ kind: graphql.Kind.VARIABLE,
586
+ name: {
587
+ kind: graphql.Kind.NAME,
588
+ value: varName
589
+ }
590
+ }
591
+ };
592
+ variableDefinitionsMap[varName] = {
593
+ kind: graphql.Kind.VARIABLE_DEFINITION,
594
+ variable: {
595
+ kind: graphql.Kind.VARIABLE,
596
+ name: {
597
+ kind: graphql.Kind.NAME,
598
+ value: varName
599
+ }
600
+ },
601
+ type: utils.astFromType(type)
602
+ };
603
+ if (value !== void 0) {
604
+ variableValues[varName] = value;
605
+ return;
606
+ }
607
+ if (varName in variableValues) {
608
+ delete variableValues[varName];
609
+ }
610
+ }
611
+ function createVariableNameGenerator(variableDefinitionMap) {
612
+ let varCounter = 0;
613
+ return (argName) => {
614
+ let varName;
615
+ do {
616
+ varName = varCounter === 0 ? argName : `_v${varCounter.toString()}_${argName}`;
617
+ varCounter++;
618
+ } while (varName in variableDefinitionMap);
619
+ return varName;
620
+ };
621
+ }
622
+
577
623
  function finalizeGatewayDocument(targetSchema, fragments, operations, onOverlappingAliases, delegationContext) {
578
624
  let usedVariables = [];
579
625
  let usedFragments = [];
@@ -727,7 +773,7 @@ function finalizeGatewayRequest(originalRequest, delegationContext, onOverlappin
727
773
  if (variables != null) {
728
774
  for (const variableName of usedVariables) {
729
775
  const variableValue = variables[variableName];
730
- if (variableValue !== undefined) {
776
+ if (variableValue !== void 0) {
731
777
  newVariables[variableName] = variableValue;
732
778
  }
733
779
  }
@@ -811,14 +857,14 @@ function addVariablesToRootFields(targetSchema, operations, args) {
811
857
  };
812
858
  }
813
859
  function updateArguments(targetField, argumentNodeMap, variableDefinitionMap, variableValues, newArgs) {
814
- const generateVariableName = utils.createVariableNameGenerator(
860
+ const generateVariableName = createVariableNameGenerator(
815
861
  variableDefinitionMap
816
862
  );
817
863
  for (const argument of targetField.args) {
818
864
  const argName = argument.name;
819
865
  const argType = argument.type;
820
866
  if (argName in newArgs) {
821
- utils.updateArgument(
867
+ updateArgument(
822
868
  argumentNodeMap,
823
869
  variableDefinitionMap,
824
870
  variableValues,
@@ -970,7 +1016,7 @@ function finalizeSelectionSet(schema, type, validFragments, selectionSet, onOver
970
1016
  }));
971
1017
  }
972
1018
  }
973
- return undefined;
1019
+ return void 0;
974
1020
  },
975
1021
  leave: (node) => {
976
1022
  const type2 = typeInfo.getType();
@@ -987,7 +1033,7 @@ function finalizeSelectionSet(schema, type, validFragments, selectionSet, onOver
987
1033
  return null;
988
1034
  }
989
1035
  }
990
- return undefined;
1036
+ return void 0;
991
1037
  }
992
1038
  },
993
1039
  [graphql.Kind.FRAGMENT_SPREAD]: {
@@ -1001,7 +1047,7 @@ function finalizeSelectionSet(schema, type, validFragments, selectionSet, onOver
1001
1047
  return null;
1002
1048
  }
1003
1049
  usedFragments.push(node.name.value);
1004
- return undefined;
1050
+ return void 0;
1005
1051
  }
1006
1052
  },
1007
1053
  [graphql.Kind.SELECTION_SET]: {
@@ -1037,7 +1083,7 @@ function finalizeSelectionSet(schema, type, validFragments, selectionSet, onOver
1037
1083
  return null;
1038
1084
  }
1039
1085
  }
1040
- return undefined;
1086
+ return void 0;
1041
1087
  },
1042
1088
  leave: (selection, _key, parent) => {
1043
1089
  if (!selection.selectionSet?.selections?.length) {
@@ -1588,7 +1634,7 @@ function wrapConcreteTypes(returnType, targetSchema, document) {
1588
1634
  if (!rootTypeNames.has(typeName)) {
1589
1635
  return false;
1590
1636
  }
1591
- return undefined;
1637
+ return void 0;
1592
1638
  },
1593
1639
  [graphql.Kind.FIELD]: (node) => {
1594
1640
  const fieldType = typeInfo.getType();
@@ -1614,7 +1660,7 @@ function wrapConcreteTypes(returnType, targetSchema, document) {
1614
1660
  };
1615
1661
  }
1616
1662
  }
1617
- return undefined;
1663
+ return void 0;
1618
1664
  }
1619
1665
  }),
1620
1666
  // visitorKeys argument usage a la https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-graphql/src/batching/merge-queries.js
@@ -1740,7 +1786,7 @@ function createRequest({
1740
1786
  newSelectionSet = selections.length ? {
1741
1787
  kind: graphql.Kind.SELECTION_SET,
1742
1788
  selections
1743
- } : undefined;
1789
+ } : void 0;
1744
1790
  const args = fieldNodes?.[0]?.arguments;
1745
1791
  if (args) {
1746
1792
  for (const argNode of args) {
@@ -1762,7 +1808,7 @@ function createRequest({
1762
1808
  varType,
1763
1809
  variableValues?.[varName]
1764
1810
  );
1765
- if (serializedValue !== undefined) {
1811
+ if (serializedValue !== void 0) {
1766
1812
  newVariables[varName] = serializedValue;
1767
1813
  }
1768
1814
  }
@@ -1778,7 +1824,7 @@ function createRequest({
1778
1824
  }
1779
1825
  const fieldNode = fieldNodes?.[0];
1780
1826
  const rootFieldName = targetFieldName ?? fieldNode?.name.value;
1781
- if (rootFieldName === undefined) {
1827
+ if (rootFieldName === void 0) {
1782
1828
  throw new Error(
1783
1829
  `Either "targetFieldName" or a non empty "fieldNodes" array must be provided.`
1784
1830
  );
@@ -1796,7 +1842,7 @@ function createRequest({
1796
1842
  const operationName = targetOperationName ? {
1797
1843
  kind: graphql.Kind.NAME,
1798
1844
  value: targetOperationName
1799
- } : undefined;
1845
+ } : void 0;
1800
1846
  const operationDefinition = {
1801
1847
  kind: graphql.Kind.OPERATION_DEFINITION,
1802
1848
  name: operationName,
@@ -1831,7 +1877,7 @@ function createRequest({
1831
1877
  };
1832
1878
  }
1833
1879
  function updateArgumentsWithDefaults(sourceParentType, sourceFieldName, argumentNodeMap, variableDefinitionMap, variableValues) {
1834
- const generateVariableName = utils.createVariableNameGenerator(
1880
+ const generateVariableName = createVariableNameGenerator(
1835
1881
  variableDefinitionMap
1836
1882
  );
1837
1883
  const sourceField = sourceParentType.getFields()[sourceFieldName];
@@ -1843,10 +1889,10 @@ function updateArgumentsWithDefaults(sourceParentType, sourceFieldName, argument
1843
1889
  for (const argument of sourceField.args) {
1844
1890
  const argName = argument.name;
1845
1891
  const sourceArgType = argument.type;
1846
- if (argumentNodeMap[argName] === undefined) {
1892
+ if (argumentNodeMap[argName] === void 0) {
1847
1893
  const defaultValue = argument.defaultValue;
1848
- if (defaultValue !== undefined) {
1849
- utils.updateArgument(
1894
+ if (defaultValue !== void 0) {
1895
+ updateArgument(
1850
1896
  argumentNodeMap,
1851
1897
  variableDefinitionMap,
1852
1898
  variableValues,
@@ -1907,7 +1953,7 @@ function defaultMergedResolver(parent, args, context, info) {
1907
1953
  }
1908
1954
  return deferred.promise;
1909
1955
  }
1910
- return undefined;
1956
+ return void 0;
1911
1957
  }
1912
1958
  return handleResult(parent, responseKey, context, info);
1913
1959
  }
@@ -2134,8 +2180,8 @@ function parentSatisfiedSelectionSet(parent, selectionSet) {
2134
2180
  const subschemas2 = /* @__PURE__ */ new Set();
2135
2181
  for (const item of parent) {
2136
2182
  const satisfied = parentSatisfiedSelectionSet(item, selectionSet);
2137
- if (satisfied === undefined) {
2138
- return undefined;
2183
+ if (satisfied === void 0) {
2184
+ return void 0;
2139
2185
  }
2140
2186
  for (const subschema of satisfied) {
2141
2187
  subschemas2.add(subschema);
@@ -2146,15 +2192,15 @@ function parentSatisfiedSelectionSet(parent, selectionSet) {
2146
2192
  if (parent === null) {
2147
2193
  return /* @__PURE__ */ new Set();
2148
2194
  }
2149
- if (parent === undefined) {
2150
- return undefined;
2195
+ if (parent === void 0) {
2196
+ return void 0;
2151
2197
  }
2152
2198
  const subschemas = /* @__PURE__ */ new Set();
2153
2199
  for (const selection of selectionSet.selections) {
2154
2200
  if (selection.kind === graphql.Kind.FIELD) {
2155
2201
  const responseKey = selection.alias?.value ?? selection.name.value;
2156
- if (parent[responseKey] === undefined) {
2157
- return undefined;
2202
+ if (parent[responseKey] === void 0) {
2203
+ return void 0;
2158
2204
  }
2159
2205
  if (isExternalObject(parent)) {
2160
2206
  const subschema = getSubschema(parent, responseKey);
@@ -2170,8 +2216,8 @@ function parentSatisfiedSelectionSet(parent, selectionSet) {
2170
2216
  parent[responseKey],
2171
2217
  selection.selectionSet
2172
2218
  );
2173
- if (satisfied === undefined) {
2174
- return undefined;
2219
+ if (satisfied === void 0) {
2220
+ return void 0;
2175
2221
  }
2176
2222
  for (const subschema of satisfied) {
2177
2223
  subschemas.add(subschema);
@@ -2182,8 +2228,8 @@ function parentSatisfiedSelectionSet(parent, selectionSet) {
2182
2228
  parent,
2183
2229
  selection.selectionSet
2184
2230
  );
2185
- if (inlineSatisfied === undefined) {
2186
- return undefined;
2231
+ if (inlineSatisfied === void 0) {
2232
+ return void 0;
2187
2233
  }
2188
2234
  for (const subschema of inlineSatisfied) {
2189
2235
  subschemas.add(subschema);
@@ -2237,7 +2283,7 @@ function isSubschemaConfig(value) {
2237
2283
  function cloneSubschemaConfig(subschemaConfig) {
2238
2284
  const newSubschemaConfig = {
2239
2285
  ...subschemaConfig,
2240
- transforms: subschemaConfig.transforms != null ? [...subschemaConfig.transforms] : undefined
2286
+ transforms: subschemaConfig.transforms != null ? [...subschemaConfig.transforms] : void 0
2241
2287
  };
2242
2288
  if (newSubschemaConfig.merge != null) {
2243
2289
  newSubschemaConfig.merge = { ...subschemaConfig.merge };
@@ -2423,7 +2469,7 @@ function getDelegationContext({
2423
2469
  }
2424
2470
  return {
2425
2471
  subschema: schema,
2426
- subschemaConfig: undefined,
2472
+ subschemaConfig: void 0,
2427
2473
  targetSchema: subschemaOrSubschemaConfig,
2428
2474
  operation,
2429
2475
  fieldName: targetFieldName,
@@ -2649,7 +2695,7 @@ function subtractSelectionSets(selectionSetA, selectionSetB) {
2649
2695
  return null;
2650
2696
  }
2651
2697
  }
2652
- return undefined;
2698
+ return void 0;
2653
2699
  }
2654
2700
  },
2655
2701
  [graphql.Kind.SELECTION_SET]: {
@@ -2657,7 +2703,7 @@ function subtractSelectionSets(selectionSetA, selectionSetB) {
2657
2703
  if (node.selections.length === 0) {
2658
2704
  return null;
2659
2705
  }
2660
- return undefined;
2706
+ return void 0;
2661
2707
  }
2662
2708
  },
2663
2709
  [graphql.Kind.INLINE_FRAGMENT]: {
@@ -2665,7 +2711,7 @@ function subtractSelectionSets(selectionSetA, selectionSetB) {
2665
2711
  if (node.selectionSet?.selections.length === 0) {
2666
2712
  return null;
2667
2713
  }
2668
- return undefined;
2714
+ return void 0;
2669
2715
  }
2670
2716
  }
2671
2717
  });
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ExecutionRequest, ExecutionResult, Executor, MaybePromise, PromiseWithResolvers, Maybe } from '@graphql-tools/utils';
2
2
  export { createDeferred } from '@graphql-tools/utils';
3
3
  import * as graphql from 'graphql';
4
- import { GraphQLSchema, OperationTypeNode, GraphQLResolveInfo, GraphQLOutputType, GraphQLError, SelectionSetNode, FieldNode, GraphQLObjectType, FragmentDefinitionNode, VariableDefinitionNode, GraphQLNamedType, GraphQLFieldResolver, GraphQLNamedOutputType, GraphQLInterfaceType, SelectionNode, GraphQLField, TypeInfo, GraphQLType } from 'graphql';
4
+ import { GraphQLSchema, OperationTypeNode, GraphQLFieldResolver, GraphQLResolveInfo, GraphQLOutputType, GraphQLError, SelectionSetNode, GraphQLObjectType, FragmentDefinitionNode, VariableDefinitionNode, FieldNode, GraphQLNamedType, GraphQLNamedOutputType, GraphQLInterfaceType, SelectionNode, GraphQLField, TypeInfo, GraphQLType } from 'graphql';
5
5
  import DataLoader from 'dataloader';
6
6
  export { executorFromSchema as createDefaultExecutor } from '@graphql-tools/executor';
7
7
 
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ExecutionRequest, ExecutionResult, Executor, MaybePromise, PromiseWithResolvers, Maybe } from '@graphql-tools/utils';
2
2
  export { createDeferred } from '@graphql-tools/utils';
3
3
  import * as graphql from 'graphql';
4
- import { GraphQLSchema, OperationTypeNode, GraphQLResolveInfo, GraphQLOutputType, GraphQLError, SelectionSetNode, FieldNode, GraphQLObjectType, FragmentDefinitionNode, VariableDefinitionNode, GraphQLNamedType, GraphQLFieldResolver, GraphQLNamedOutputType, GraphQLInterfaceType, SelectionNode, GraphQLField, TypeInfo, GraphQLType } from 'graphql';
4
+ import { GraphQLSchema, OperationTypeNode, GraphQLFieldResolver, GraphQLResolveInfo, GraphQLOutputType, GraphQLError, SelectionSetNode, GraphQLObjectType, FragmentDefinitionNode, VariableDefinitionNode, FieldNode, GraphQLNamedType, GraphQLNamedOutputType, GraphQLInterfaceType, SelectionNode, GraphQLField, TypeInfo, GraphQLType } from 'graphql';
5
5
  import DataLoader from 'dataloader';
6
6
  export { executorFromSchema as createDefaultExecutor } from '@graphql-tools/executor';
7
7
 
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { memoize2, memoize1, mapMaybePromise, collectFields, relocatedError, mergeDeep, pathToArray, isPromise, getResponseKeyFromInfo, getDefinedRootType, createVariableNameGenerator, updateArgument, serializeInputValue, createGraphQLError, implementsAbstractType, getRootTypeNames, createDeferred, isAsyncIterable, mapAsyncIterator, getOperationASTFromRequest } from '@graphql-tools/utils';
1
+ import { memoize2, memoize1, mapMaybePromise, collectFields, relocatedError, mergeDeep, pathToArray, isPromise, getResponseKeyFromInfo, astFromType, getDefinedRootType, createGraphQLError, serializeInputValue, implementsAbstractType, getRootTypeNames, createDeferred, isAsyncIterable, mapAsyncIterator, getOperationASTFromRequest } from '@graphql-tools/utils';
2
2
  export { createDeferred } from '@graphql-tools/utils';
3
- import { GraphQLError, locatedError, isAbstractType, getNullableType, isLeafType, isCompositeType, isListType, responsePathAsArray, Kind, TypeInfo, versionInfo, visit, visitWithTypeInfo, isObjectType, isInterfaceType, isUnionType, getNamedType, isNullableType, typeFromAST, defaultFieldResolver, validate } from 'graphql';
3
+ import { GraphQLError, locatedError, isAbstractType, getNullableType, isLeafType, isCompositeType, isListType, responsePathAsArray, Kind, TypeInfo, versionInfo, visit, visitWithTypeInfo, isNullableType, isUnionType, getNamedType, isObjectType, isInterfaceType, typeFromAST, defaultFieldResolver, validate } from 'graphql';
4
4
  import { CRITICAL_ERROR, executorFromSchema } from '@graphql-tools/executor';
5
5
  export { executorFromSchema as createDefaultExecutor } from '@graphql-tools/executor';
6
6
  import { getBatchingExecutor } from '@graphql-tools/batch-execute';
@@ -72,7 +72,7 @@ function getPlanLeftOverFromParent(parent) {
72
72
  if (parent != null && typeof parent === "object") {
73
73
  return parent[PLAN_LEFT_OVER];
74
74
  }
75
- return undefined;
75
+ return void 0;
76
76
  }
77
77
 
78
78
  const UNPATHED_ERRORS_SYMBOL = Symbol.for("subschemaErrors");
@@ -80,7 +80,7 @@ const OBJECT_SUBSCHEMA_SYMBOL = Symbol.for("initialSubschema");
80
80
  const FIELD_SUBSCHEMA_MAP_SYMBOL = Symbol.for("subschemaMap");
81
81
 
82
82
  function isExternalObject(data) {
83
- return data[UNPATHED_ERRORS_SYMBOL] !== undefined;
83
+ return data[UNPATHED_ERRORS_SYMBOL] !== void 0;
84
84
  }
85
85
  function annotateExternalObject(object, errors, subschema, subschemaMap) {
86
86
  Object.defineProperties(object, {
@@ -127,7 +127,7 @@ function mergeFields(mergedTypeInfo, object, sourceSubschema, context, info) {
127
127
  info
128
128
  )
129
129
  ),
130
- undefined
130
+ void 0
131
131
  ),
132
132
  () => object
133
133
  );
@@ -190,7 +190,7 @@ function handleResolverResult(resolverResult, subschema, selectionSet, object, c
190
190
  object[responseKey] = existingPropValue.map(
191
191
  (existingElement, index) => sourcePropValue instanceof Error ? existingElement : mergeDeep(
192
192
  [existingElement, sourcePropValue[index]],
193
- undefined,
193
+ void 0,
194
194
  true,
195
195
  true
196
196
  )
@@ -198,7 +198,7 @@ function handleResolverResult(resolverResult, subschema, selectionSet, object, c
198
198
  } else if (!(sourcePropValue instanceof Error)) {
199
199
  object[responseKey] = mergeDeep(
200
200
  [existingPropValue, sourcePropValue],
201
- undefined,
201
+ void 0,
202
202
  true,
203
203
  true
204
204
  );
@@ -416,7 +416,7 @@ function reportUnpathedErrorsViaNull(unpathedErrors) {
416
416
  if (unreportedErrors.length === 1 && unreportedError) {
417
417
  return locatedError(
418
418
  unreportedError,
419
- undefined,
419
+ void 0,
420
420
  unreportedError.path
421
421
  );
422
422
  }
@@ -427,7 +427,7 @@ function reportUnpathedErrorsViaNull(unpathedErrors) {
427
427
  // locatedError path argument must be defined, but it is just forwarded to a constructor that allows a undefined value
428
428
  // https://github.com/graphql/graphql-js/blob/b4bff0ba9c15c9d7245dd68556e754c41f263289/src/error/locatedError.js#L25
429
429
  // https://github.com/graphql/graphql-js/blob/b4bff0ba9c15c9d7245dd68556e754c41f263289/src/error/GraphQLError.js#L19
430
- locatedError(e, undefined, unreportedError?.path)
430
+ locatedError(e, void 0, unreportedError?.path)
431
431
  )
432
432
  ),
433
433
  unreportedErrors.map((error) => error.message).join(", \n")
@@ -457,9 +457,9 @@ function checkResultAndHandleErrors(result = {
457
457
  onLocatedError
458
458
  } = delegationContext;
459
459
  const { data, unpathedErrors } = mergeDataAndErrors(
460
- result.data == null ? undefined : result.data[responseKey],
460
+ result.data == null ? void 0 : result.data[responseKey],
461
461
  result.errors == null ? [] : result.errors,
462
- info != null && info.path ? responsePathAsArray(info.path) : undefined,
462
+ info != null && info.path ? responsePathAsArray(info.path) : void 0,
463
463
  onLocatedError
464
464
  );
465
465
  return resolveExternalValue(
@@ -479,7 +479,7 @@ function mergeDataAndErrors(data, errors, path, onLocatedError, index = 1) {
479
479
  }
480
480
  if (errors.length === 1 && errors[0]) {
481
481
  const error = onLocatedError ? onLocatedError(errors[0]) : errors[0];
482
- const newPath = path === undefined ? error.path : !error.path ? path : path.concat(error.path.slice(1));
482
+ const newPath = path === void 0 ? error.path : !error.path ? path : path.concat(error.path.slice(1));
483
483
  return { data: relocatedError(errors[0], newPath), unpathedErrors: [] };
484
484
  }
485
485
  const combinedError = new AggregateError(
@@ -489,7 +489,7 @@ function mergeDataAndErrors(data, errors, path, onLocatedError, index = 1) {
489
489
  // locatedError path argument must be defined, but it is just forwarded to a constructor that allows a undefined value
490
490
  // https://github.com/graphql/graphql-js/blob/b4bff0ba9c15c9d7245dd68556e754c41f263289/src/error/locatedError.js#L25
491
491
  // https://github.com/graphql/graphql-js/blob/b4bff0ba9c15c9d7245dd68556e754c41f263289/src/error/GraphQLError.js#L19
492
- locatedError(e, undefined, path)
492
+ locatedError(e, void 0, path)
493
493
  )
494
494
  ),
495
495
  errors.map((error) => error.message).join(", \n")
@@ -505,7 +505,7 @@ function mergeDataAndErrors(data, errors, path, onLocatedError, index = 1) {
505
505
  const pathSegment = error.path?.[index];
506
506
  if (pathSegment != null) {
507
507
  let pathSegmentErrors = errorMap.get(pathSegment);
508
- if (pathSegmentErrors === undefined) {
508
+ if (pathSegmentErrors === void 0) {
509
509
  pathSegmentErrors = [error];
510
510
  errorMap.set(pathSegment, pathSegmentErrors);
511
511
  } else {
@@ -516,7 +516,7 @@ function mergeDataAndErrors(data, errors, path, onLocatedError, index = 1) {
516
516
  }
517
517
  }
518
518
  for (const [pathSegment, pathSegmentErrors] of errorMap) {
519
- if (data[pathSegment] !== undefined) {
519
+ if (data[pathSegment] !== void 0) {
520
520
  const { data: newData, unpathedErrors: newErrors } = mergeDataAndErrors(
521
521
  data[pathSegment],
522
522
  pathSegmentErrors,
@@ -571,9 +571,55 @@ const getTypeInfo = memoize1(function getTypeInfo2(schema) {
571
571
  return new TypeInfo(schema);
572
572
  });
573
573
  const getTypeInfoWithType = memoize2(function getTypeInfoWithType2(schema, type) {
574
- return versionInfo.major < 16 ? new TypeInfo(schema, undefined, type) : new TypeInfo(schema, type);
574
+ return versionInfo.major < 16 ? new TypeInfo(schema, void 0, type) : new TypeInfo(schema, type);
575
575
  });
576
576
 
577
+ function updateArgument(argumentNodes, variableDefinitionsMap, variableValues, argName, varName, type, value) {
578
+ argumentNodes[argName] = {
579
+ kind: Kind.ARGUMENT,
580
+ name: {
581
+ kind: Kind.NAME,
582
+ value: argName
583
+ },
584
+ value: {
585
+ kind: Kind.VARIABLE,
586
+ name: {
587
+ kind: Kind.NAME,
588
+ value: varName
589
+ }
590
+ }
591
+ };
592
+ variableDefinitionsMap[varName] = {
593
+ kind: Kind.VARIABLE_DEFINITION,
594
+ variable: {
595
+ kind: Kind.VARIABLE,
596
+ name: {
597
+ kind: Kind.NAME,
598
+ value: varName
599
+ }
600
+ },
601
+ type: astFromType(type)
602
+ };
603
+ if (value !== void 0) {
604
+ variableValues[varName] = value;
605
+ return;
606
+ }
607
+ if (varName in variableValues) {
608
+ delete variableValues[varName];
609
+ }
610
+ }
611
+ function createVariableNameGenerator(variableDefinitionMap) {
612
+ let varCounter = 0;
613
+ return (argName) => {
614
+ let varName;
615
+ do {
616
+ varName = varCounter === 0 ? argName : `_v${varCounter.toString()}_${argName}`;
617
+ varCounter++;
618
+ } while (varName in variableDefinitionMap);
619
+ return varName;
620
+ };
621
+ }
622
+
577
623
  function finalizeGatewayDocument(targetSchema, fragments, operations, onOverlappingAliases, delegationContext) {
578
624
  let usedVariables = [];
579
625
  let usedFragments = [];
@@ -727,7 +773,7 @@ function finalizeGatewayRequest(originalRequest, delegationContext, onOverlappin
727
773
  if (variables != null) {
728
774
  for (const variableName of usedVariables) {
729
775
  const variableValue = variables[variableName];
730
- if (variableValue !== undefined) {
776
+ if (variableValue !== void 0) {
731
777
  newVariables[variableName] = variableValue;
732
778
  }
733
779
  }
@@ -970,7 +1016,7 @@ function finalizeSelectionSet(schema, type, validFragments, selectionSet, onOver
970
1016
  }));
971
1017
  }
972
1018
  }
973
- return undefined;
1019
+ return void 0;
974
1020
  },
975
1021
  leave: (node) => {
976
1022
  const type2 = typeInfo.getType();
@@ -987,7 +1033,7 @@ function finalizeSelectionSet(schema, type, validFragments, selectionSet, onOver
987
1033
  return null;
988
1034
  }
989
1035
  }
990
- return undefined;
1036
+ return void 0;
991
1037
  }
992
1038
  },
993
1039
  [Kind.FRAGMENT_SPREAD]: {
@@ -1001,7 +1047,7 @@ function finalizeSelectionSet(schema, type, validFragments, selectionSet, onOver
1001
1047
  return null;
1002
1048
  }
1003
1049
  usedFragments.push(node.name.value);
1004
- return undefined;
1050
+ return void 0;
1005
1051
  }
1006
1052
  },
1007
1053
  [Kind.SELECTION_SET]: {
@@ -1037,7 +1083,7 @@ function finalizeSelectionSet(schema, type, validFragments, selectionSet, onOver
1037
1083
  return null;
1038
1084
  }
1039
1085
  }
1040
- return undefined;
1086
+ return void 0;
1041
1087
  },
1042
1088
  leave: (selection, _key, parent) => {
1043
1089
  if (!selection.selectionSet?.selections?.length) {
@@ -1588,7 +1634,7 @@ function wrapConcreteTypes(returnType, targetSchema, document) {
1588
1634
  if (!rootTypeNames.has(typeName)) {
1589
1635
  return false;
1590
1636
  }
1591
- return undefined;
1637
+ return void 0;
1592
1638
  },
1593
1639
  [Kind.FIELD]: (node) => {
1594
1640
  const fieldType = typeInfo.getType();
@@ -1614,7 +1660,7 @@ function wrapConcreteTypes(returnType, targetSchema, document) {
1614
1660
  };
1615
1661
  }
1616
1662
  }
1617
- return undefined;
1663
+ return void 0;
1618
1664
  }
1619
1665
  }),
1620
1666
  // visitorKeys argument usage a la https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-graphql/src/batching/merge-queries.js
@@ -1740,7 +1786,7 @@ function createRequest({
1740
1786
  newSelectionSet = selections.length ? {
1741
1787
  kind: Kind.SELECTION_SET,
1742
1788
  selections
1743
- } : undefined;
1789
+ } : void 0;
1744
1790
  const args = fieldNodes?.[0]?.arguments;
1745
1791
  if (args) {
1746
1792
  for (const argNode of args) {
@@ -1762,7 +1808,7 @@ function createRequest({
1762
1808
  varType,
1763
1809
  variableValues?.[varName]
1764
1810
  );
1765
- if (serializedValue !== undefined) {
1811
+ if (serializedValue !== void 0) {
1766
1812
  newVariables[varName] = serializedValue;
1767
1813
  }
1768
1814
  }
@@ -1778,7 +1824,7 @@ function createRequest({
1778
1824
  }
1779
1825
  const fieldNode = fieldNodes?.[0];
1780
1826
  const rootFieldName = targetFieldName ?? fieldNode?.name.value;
1781
- if (rootFieldName === undefined) {
1827
+ if (rootFieldName === void 0) {
1782
1828
  throw new Error(
1783
1829
  `Either "targetFieldName" or a non empty "fieldNodes" array must be provided.`
1784
1830
  );
@@ -1796,7 +1842,7 @@ function createRequest({
1796
1842
  const operationName = targetOperationName ? {
1797
1843
  kind: Kind.NAME,
1798
1844
  value: targetOperationName
1799
- } : undefined;
1845
+ } : void 0;
1800
1846
  const operationDefinition = {
1801
1847
  kind: Kind.OPERATION_DEFINITION,
1802
1848
  name: operationName,
@@ -1843,9 +1889,9 @@ function updateArgumentsWithDefaults(sourceParentType, sourceFieldName, argument
1843
1889
  for (const argument of sourceField.args) {
1844
1890
  const argName = argument.name;
1845
1891
  const sourceArgType = argument.type;
1846
- if (argumentNodeMap[argName] === undefined) {
1892
+ if (argumentNodeMap[argName] === void 0) {
1847
1893
  const defaultValue = argument.defaultValue;
1848
- if (defaultValue !== undefined) {
1894
+ if (defaultValue !== void 0) {
1849
1895
  updateArgument(
1850
1896
  argumentNodeMap,
1851
1897
  variableDefinitionMap,
@@ -1907,7 +1953,7 @@ function defaultMergedResolver(parent, args, context, info) {
1907
1953
  }
1908
1954
  return deferred.promise;
1909
1955
  }
1910
- return undefined;
1956
+ return void 0;
1911
1957
  }
1912
1958
  return handleResult(parent, responseKey, context, info);
1913
1959
  }
@@ -2134,8 +2180,8 @@ function parentSatisfiedSelectionSet(parent, selectionSet) {
2134
2180
  const subschemas2 = /* @__PURE__ */ new Set();
2135
2181
  for (const item of parent) {
2136
2182
  const satisfied = parentSatisfiedSelectionSet(item, selectionSet);
2137
- if (satisfied === undefined) {
2138
- return undefined;
2183
+ if (satisfied === void 0) {
2184
+ return void 0;
2139
2185
  }
2140
2186
  for (const subschema of satisfied) {
2141
2187
  subschemas2.add(subschema);
@@ -2146,15 +2192,15 @@ function parentSatisfiedSelectionSet(parent, selectionSet) {
2146
2192
  if (parent === null) {
2147
2193
  return /* @__PURE__ */ new Set();
2148
2194
  }
2149
- if (parent === undefined) {
2150
- return undefined;
2195
+ if (parent === void 0) {
2196
+ return void 0;
2151
2197
  }
2152
2198
  const subschemas = /* @__PURE__ */ new Set();
2153
2199
  for (const selection of selectionSet.selections) {
2154
2200
  if (selection.kind === Kind.FIELD) {
2155
2201
  const responseKey = selection.alias?.value ?? selection.name.value;
2156
- if (parent[responseKey] === undefined) {
2157
- return undefined;
2202
+ if (parent[responseKey] === void 0) {
2203
+ return void 0;
2158
2204
  }
2159
2205
  if (isExternalObject(parent)) {
2160
2206
  const subschema = getSubschema(parent, responseKey);
@@ -2170,8 +2216,8 @@ function parentSatisfiedSelectionSet(parent, selectionSet) {
2170
2216
  parent[responseKey],
2171
2217
  selection.selectionSet
2172
2218
  );
2173
- if (satisfied === undefined) {
2174
- return undefined;
2219
+ if (satisfied === void 0) {
2220
+ return void 0;
2175
2221
  }
2176
2222
  for (const subschema of satisfied) {
2177
2223
  subschemas.add(subschema);
@@ -2182,8 +2228,8 @@ function parentSatisfiedSelectionSet(parent, selectionSet) {
2182
2228
  parent,
2183
2229
  selection.selectionSet
2184
2230
  );
2185
- if (inlineSatisfied === undefined) {
2186
- return undefined;
2231
+ if (inlineSatisfied === void 0) {
2232
+ return void 0;
2187
2233
  }
2188
2234
  for (const subschema of inlineSatisfied) {
2189
2235
  subschemas.add(subschema);
@@ -2237,7 +2283,7 @@ function isSubschemaConfig(value) {
2237
2283
  function cloneSubschemaConfig(subschemaConfig) {
2238
2284
  const newSubschemaConfig = {
2239
2285
  ...subschemaConfig,
2240
- transforms: subschemaConfig.transforms != null ? [...subschemaConfig.transforms] : undefined
2286
+ transforms: subschemaConfig.transforms != null ? [...subschemaConfig.transforms] : void 0
2241
2287
  };
2242
2288
  if (newSubschemaConfig.merge != null) {
2243
2289
  newSubschemaConfig.merge = { ...subschemaConfig.merge };
@@ -2423,7 +2469,7 @@ function getDelegationContext({
2423
2469
  }
2424
2470
  return {
2425
2471
  subschema: schema,
2426
- subschemaConfig: undefined,
2472
+ subschemaConfig: void 0,
2427
2473
  targetSchema: subschemaOrSubschemaConfig,
2428
2474
  operation,
2429
2475
  fieldName: targetFieldName,
@@ -2649,7 +2695,7 @@ function subtractSelectionSets(selectionSetA, selectionSetB) {
2649
2695
  return null;
2650
2696
  }
2651
2697
  }
2652
- return undefined;
2698
+ return void 0;
2653
2699
  }
2654
2700
  },
2655
2701
  [Kind.SELECTION_SET]: {
@@ -2657,7 +2703,7 @@ function subtractSelectionSets(selectionSetA, selectionSetB) {
2657
2703
  if (node.selections.length === 0) {
2658
2704
  return null;
2659
2705
  }
2660
- return undefined;
2706
+ return void 0;
2661
2707
  }
2662
2708
  },
2663
2709
  [Kind.INLINE_FRAGMENT]: {
@@ -2665,7 +2711,7 @@ function subtractSelectionSets(selectionSetA, selectionSetB) {
2665
2711
  if (node.selectionSet?.selections.length === 0) {
2666
2712
  return null;
2667
2713
  }
2668
- return undefined;
2714
+ return void 0;
2669
2715
  }
2670
2716
  }
2671
2717
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/delegate",
3
- "version": "10.2.11",
3
+ "version": "10.2.12-alpha-bb010bd4b613397bc4e6ba96149dc972a0ef0997",
4
4
  "type": "module",
5
5
  "description": "A set of utils for faster development of GraphQL tools",
6
6
  "repository": {
@@ -38,10 +38,10 @@
38
38
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
39
39
  },
40
40
  "dependencies": {
41
- "@graphql-tools/batch-execute": "^9.0.11",
41
+ "@graphql-tools/batch-execute": "9.0.12-alpha-bb010bd4b613397bc4e6ba96149dc972a0ef0997",
42
42
  "@graphql-tools/executor": "^1.3.10",
43
43
  "@graphql-tools/schema": "^10.0.11",
44
- "@graphql-tools/utils": "^10.7.0",
44
+ "@graphql-tools/utils": "^10.8.1",
45
45
  "@repeaterjs/repeater": "^3.0.6",
46
46
  "dataloader": "^2.2.3",
47
47
  "dset": "^3.1.2",
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "graphql": "^16.9.0",
52
- "pkgroll": "2.6.1"
52
+ "pkgroll": "2.8.2"
53
53
  },
54
54
  "sideEffects": false
55
55
  }