@depup/graphql-tools__delegate 12.1.0-depup.0 → 12.1.1-depup.0

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/README.md CHANGED
@@ -13,8 +13,8 @@ npm install @depup/graphql-tools__delegate
13
13
 
14
14
  | Field | Value |
15
15
  |-------|-------|
16
- | Original | [@graphql-tools/delegate](https://www.npmjs.com/package/@graphql-tools/delegate) @ 12.1.0 |
17
- | Processed | 2026-07-21 |
16
+ | Original | [@graphql-tools/delegate](https://www.npmjs.com/package/@graphql-tools/delegate) @ 12.1.1 |
17
+ | Processed | 2026-07-27 |
18
18
  | Smoke test | passed |
19
19
  | Deps updated | 4 |
20
20
 
package/changes.json CHANGED
@@ -17,6 +17,6 @@
17
17
  "to": "^3.1.0"
18
18
  }
19
19
  },
20
- "timestamp": "2026-07-21T16:05:05.627Z",
20
+ "timestamp": "2026-07-27T16:43:40.163Z",
21
21
  "totalUpdated": 4
22
22
  }
package/dist/index.cjs CHANGED
@@ -2344,6 +2344,7 @@ function createRequest({
2344
2344
  const newVariables = info?.variableValues ? { ...info.variableValues } : {};
2345
2345
  const variableDefinitions = info?.operation.variableDefinitions ? [...info.operation.variableDefinitions] : [];
2346
2346
  const argNodes = [];
2347
+ const replacedVariableNames = /* @__PURE__ */ new Set();
2347
2348
  if (args != null) {
2348
2349
  const rootType = targetSchema != null ? utils.getDefinedRootType(targetSchema, targetOperation) : void 0;
2349
2350
  const rootField = rootType?.getFields()[rootFieldName];
@@ -2354,14 +2355,18 @@ function createRequest({
2354
2355
  const existingArgNode = fieldNode?.arguments?.find(
2355
2356
  (argNode) => argNode.name.value === argName
2356
2357
  );
2357
- if (existingArgNode?.value.kind === graphql.Kind.VARIABLE && argInstance) {
2358
+ if (existingArgNode && !argInstance) {
2359
+ argNodes.push(existingArgNode);
2360
+ continue;
2361
+ }
2362
+ if (existingArgNode?.value.kind === graphql.Kind.VARIABLE) {
2358
2363
  const varName = existingArgNode.value.name.value;
2359
2364
  const varValue = newVariables[varName];
2360
2365
  const variableDefinition = variableDefinitions.find(
2361
2366
  (definition) => definition.variable.name.value === varName
2362
2367
  );
2363
2368
  const variableType = variableDefinition && targetSchema ? graphql.typeFromAST(info?.schema ?? targetSchema, variableDefinition.type) : void 0;
2364
- if (varValue === argValue && variableType && graphql.isTypeSubTypeOf(
2369
+ if (varValue === argValue && variableType && argInstance && graphql.isTypeSubTypeOf(
2365
2370
  info?.schema ?? targetSchema,
2366
2371
  variableType,
2367
2372
  argInstance.type
@@ -2387,14 +2392,7 @@ function createRequest({
2387
2392
  }
2388
2393
  }
2389
2394
  if (existingArgNode?.value.kind === graphql.Kind.VARIABLE) {
2390
- const existingVarName = existingArgNode.value.name.value;
2391
- const existingVarIndex = variableDefinitions.findIndex(
2392
- (definition) => definition.variable.name.value === existingVarName
2393
- );
2394
- if (existingVarIndex !== -1) {
2395
- variableDefinitions.splice(existingVarIndex, 1);
2396
- delete newVariables[existingVarName];
2397
- }
2395
+ replacedVariableNames.add(existingArgNode.value.name.value);
2398
2396
  }
2399
2397
  variableDefinitions.push({
2400
2398
  kind: graphql.Kind.VARIABLE_DEFINITION,
@@ -2472,6 +2470,26 @@ function createRequest({
2472
2470
  kind: graphql.Kind.DOCUMENT,
2473
2471
  definitions
2474
2472
  };
2473
+ if (replacedVariableNames.size > 0) {
2474
+ const usedVariableNames = /* @__PURE__ */ new Set();
2475
+ graphql.visit(document, {
2476
+ VariableDefinition: () => false,
2477
+ Variable: (variableNode) => {
2478
+ usedVariableNames.add(variableNode.name.value);
2479
+ }
2480
+ });
2481
+ for (const variableName of replacedVariableNames) {
2482
+ if (!usedVariableNames.has(variableName)) {
2483
+ const variableIndex = variableDefinitions.findIndex(
2484
+ (definition) => definition.variable.name.value === variableName
2485
+ );
2486
+ if (variableIndex !== -1) {
2487
+ variableDefinitions.splice(variableIndex, 1);
2488
+ delete newVariables[variableName];
2489
+ }
2490
+ }
2491
+ }
2492
+ }
2475
2493
  return {
2476
2494
  subgraphName,
2477
2495
  document,
@@ -2995,10 +3013,11 @@ function delegateToSchema(options) {
2995
3013
  }
2996
3014
  }
2997
3015
  const fragments = info ? getFragmentDefinitions(info) : void 0;
3016
+ const targetRootType = operation === graphql.OperationTypeNode.MUTATION ? targetSchema.getMutationType() : operation === graphql.OperationTypeNode.SUBSCRIPTION ? targetSchema.getSubscriptionType() : targetSchema.getQueryType();
2998
3017
  const request = createRequest({
2999
3018
  subgraphName: schema.name,
3000
3019
  fragments,
3001
- targetSchema: targetSchema.getQueryType()?.getFields()[fieldName] == null && isSubschemaConfig(schema) ? schema.schema : targetSchema,
3020
+ targetSchema: targetRootType?.getFields()[fieldName] == null && isSubschemaConfig(schema) ? schema.schema : targetSchema,
3002
3021
  rootValue,
3003
3022
  targetOperationName: operationName,
3004
3023
  targetOperation: operation,
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { memoize2, memoize1, collectFields, relocatedError, mergeDeep, promiseReduce, pathToArray, getResponseKeyFromInfo, memoize3, getDefinedRootType, createGraphQLError, implementsAbstractType, getRootTypeNames, astFromArg, astFromValueUntyped, asArray, isAsyncIterable, 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, isNullableType, isUnionType, getNamedType, isObjectType, isInterfaceType, typeFromAST, isTypeSubTypeOf, isNonNullType, isInputObjectType, defaultFieldResolver, isSchema, validate } from 'graphql';
3
+ import { GraphQLError, locatedError, isAbstractType, getNullableType, isLeafType, isCompositeType, isListType, responsePathAsArray, Kind, TypeInfo, versionInfo, visit, visitWithTypeInfo, isNullableType, isUnionType, getNamedType, isObjectType, isInterfaceType, typeFromAST, isTypeSubTypeOf, isNonNullType, isInputObjectType, defaultFieldResolver, isSchema, OperationTypeNode, validate } from 'graphql';
4
4
  import { handleMaybePromise, isPromise, createDeferredPromise, mapAsyncIterator } from '@whatwg-node/promise-helpers';
5
5
  import { CRITICAL_ERROR, executorFromSchema } from '@graphql-tools/executor';
6
6
  export { executorFromSchema as createDefaultExecutor } from '@graphql-tools/executor';
@@ -2344,6 +2344,7 @@ function createRequest({
2344
2344
  const newVariables = info?.variableValues ? { ...info.variableValues } : {};
2345
2345
  const variableDefinitions = info?.operation.variableDefinitions ? [...info.operation.variableDefinitions] : [];
2346
2346
  const argNodes = [];
2347
+ const replacedVariableNames = /* @__PURE__ */ new Set();
2347
2348
  if (args != null) {
2348
2349
  const rootType = targetSchema != null ? getDefinedRootType(targetSchema, targetOperation) : void 0;
2349
2350
  const rootField = rootType?.getFields()[rootFieldName];
@@ -2354,14 +2355,18 @@ function createRequest({
2354
2355
  const existingArgNode = fieldNode?.arguments?.find(
2355
2356
  (argNode) => argNode.name.value === argName
2356
2357
  );
2357
- if (existingArgNode?.value.kind === Kind.VARIABLE && argInstance) {
2358
+ if (existingArgNode && !argInstance) {
2359
+ argNodes.push(existingArgNode);
2360
+ continue;
2361
+ }
2362
+ if (existingArgNode?.value.kind === Kind.VARIABLE) {
2358
2363
  const varName = existingArgNode.value.name.value;
2359
2364
  const varValue = newVariables[varName];
2360
2365
  const variableDefinition = variableDefinitions.find(
2361
2366
  (definition) => definition.variable.name.value === varName
2362
2367
  );
2363
2368
  const variableType = variableDefinition && targetSchema ? typeFromAST(info?.schema ?? targetSchema, variableDefinition.type) : void 0;
2364
- if (varValue === argValue && variableType && isTypeSubTypeOf(
2369
+ if (varValue === argValue && variableType && argInstance && isTypeSubTypeOf(
2365
2370
  info?.schema ?? targetSchema,
2366
2371
  variableType,
2367
2372
  argInstance.type
@@ -2387,14 +2392,7 @@ function createRequest({
2387
2392
  }
2388
2393
  }
2389
2394
  if (existingArgNode?.value.kind === Kind.VARIABLE) {
2390
- const existingVarName = existingArgNode.value.name.value;
2391
- const existingVarIndex = variableDefinitions.findIndex(
2392
- (definition) => definition.variable.name.value === existingVarName
2393
- );
2394
- if (existingVarIndex !== -1) {
2395
- variableDefinitions.splice(existingVarIndex, 1);
2396
- delete newVariables[existingVarName];
2397
- }
2395
+ replacedVariableNames.add(existingArgNode.value.name.value);
2398
2396
  }
2399
2397
  variableDefinitions.push({
2400
2398
  kind: Kind.VARIABLE_DEFINITION,
@@ -2472,6 +2470,26 @@ function createRequest({
2472
2470
  kind: Kind.DOCUMENT,
2473
2471
  definitions
2474
2472
  };
2473
+ if (replacedVariableNames.size > 0) {
2474
+ const usedVariableNames = /* @__PURE__ */ new Set();
2475
+ visit(document, {
2476
+ VariableDefinition: () => false,
2477
+ Variable: (variableNode) => {
2478
+ usedVariableNames.add(variableNode.name.value);
2479
+ }
2480
+ });
2481
+ for (const variableName of replacedVariableNames) {
2482
+ if (!usedVariableNames.has(variableName)) {
2483
+ const variableIndex = variableDefinitions.findIndex(
2484
+ (definition) => definition.variable.name.value === variableName
2485
+ );
2486
+ if (variableIndex !== -1) {
2487
+ variableDefinitions.splice(variableIndex, 1);
2488
+ delete newVariables[variableName];
2489
+ }
2490
+ }
2491
+ }
2492
+ }
2475
2493
  return {
2476
2494
  subgraphName,
2477
2495
  document,
@@ -2995,10 +3013,11 @@ function delegateToSchema(options) {
2995
3013
  }
2996
3014
  }
2997
3015
  const fragments = info ? getFragmentDefinitions(info) : void 0;
3016
+ const targetRootType = operation === OperationTypeNode.MUTATION ? targetSchema.getMutationType() : operation === OperationTypeNode.SUBSCRIPTION ? targetSchema.getSubscriptionType() : targetSchema.getQueryType();
2998
3017
  const request = createRequest({
2999
3018
  subgraphName: schema.name,
3000
3019
  fragments,
3001
- targetSchema: targetSchema.getQueryType()?.getFields()[fieldName] == null && isSubschemaConfig(schema) ? schema.schema : targetSchema,
3020
+ targetSchema: targetRootType?.getFields()[fieldName] == null && isSubschemaConfig(schema) ? schema.schema : targetSchema,
3002
3021
  rootValue,
3003
3022
  targetOperationName: operationName,
3004
3023
  targetOperation: operation,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depup/graphql-tools__delegate",
3
- "version": "12.1.0-depup.0",
3
+ "version": "12.1.1-depup.0",
4
4
  "type": "module",
5
5
  "description": "A set of utils for faster development of GraphQL tools (with updated dependencies)",
6
6
  "repository": {
@@ -83,8 +83,8 @@
83
83
  },
84
84
  "depsUpdated": 4,
85
85
  "originalPackage": "@graphql-tools/delegate",
86
- "originalVersion": "12.1.0",
87
- "processedAt": "2026-07-21T16:05:10.010Z",
86
+ "originalVersion": "12.1.1",
87
+ "processedAt": "2026-07-27T16:43:48.263Z",
88
88
  "smokeTest": "passed"
89
89
  }
90
90
  }