@graphql-tools/delegate 10.2.13 → 10.2.14-alpha-0700d88cf1e9c11bc4b7dab376d3eb21c02cb1d6

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.14-alpha-0700d88cf1e9c11bc4b7dab376d3eb21c02cb1d6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#726](https://github.com/graphql-hive/gateway/pull/726) [`0700d88`](https://github.com/graphql-hive/gateway/commit/0700d88cf1e9c11bc4b7dab376d3eb21c02cb1d6) Thanks [@ardatan](https://github.com/ardatan)! - dependencies updates:
8
+
9
+ - Added dependency [`@whatwg-node/promise-helpers@^1.0.0` ↗︎](https://www.npmjs.com/package/@whatwg-node/promise-helpers/v/1.0.0) (to `dependencies`)
10
+
11
+ - Updated dependencies [[`0700d88`](https://github.com/graphql-hive/gateway/commit/0700d88cf1e9c11bc4b7dab376d3eb21c02cb1d6)]:
12
+ - @graphql-tools/batch-execute@9.0.13-alpha-0700d88cf1e9c11bc4b7dab376d3eb21c02cb1d6
13
+
3
14
  ## 10.2.13
4
15
 
5
16
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  var utils = require('@graphql-tools/utils');
4
4
  var graphql = require('graphql');
5
+ var promiseHelpers = require('@whatwg-node/promise-helpers');
5
6
  var executor = require('@graphql-tools/executor');
6
7
  var batchExecute = require('@graphql-tools/batch-execute');
7
8
  var repeater = require('@repeaterjs/repeater');
@@ -115,17 +116,15 @@ function mergeFields(mergedTypeInfo, object, sourceSubschema, context, info) {
115
116
  if (leftOver) {
116
117
  object[PLAN_LEFT_OVER] = leftOver;
117
118
  }
118
- return utils.mapMaybePromise(
119
- delegationMaps.reduce(
120
- (prev, delegationMap) => utils.mapMaybePromise(
121
- prev,
122
- () => executeDelegationStage(
123
- mergedTypeInfo,
124
- delegationMap,
125
- object,
126
- context,
127
- info
128
- )
119
+ return promiseHelpers.handleMaybePromise(
120
+ () => utils.promiseReduce(
121
+ delegationMaps,
122
+ (_, delegationMap) => executeDelegationStage(
123
+ mergedTypeInfo,
124
+ delegationMap,
125
+ object,
126
+ context,
127
+ info
129
128
  ),
130
129
  void 0
131
130
  ),
@@ -230,7 +229,7 @@ function executeDelegationStage(mergedTypeInfo, delegationMap, object, context,
230
229
  void 0,
231
230
  type
232
231
  );
233
- if (utils.isPromise(resolverResult$)) {
232
+ if (promiseHelpers.isPromise(resolverResult$)) {
234
233
  jobs.push(
235
234
  resolverResult$.then(
236
235
  (resolverResult) => handleResolverResult(
@@ -304,19 +303,18 @@ function resolveExternalValue(result, unpathedErrors, subschema, context, info,
304
303
  return null;
305
304
  }
306
305
  } else if (graphql.isCompositeType(type)) {
307
- const result$ = resolveExternalObject(
308
- type,
309
- result,
310
- unpathedErrors,
311
- subschema,
312
- context,
313
- info,
314
- skipTypeMerging
315
- );
316
- if (info && graphql.isAbstractType(type)) {
317
- return utils.mapMaybePromise(
318
- result$,
319
- function checkAbstractResolvedCorrectly(result2) {
306
+ return promiseHelpers.handleMaybePromise(
307
+ () => resolveExternalObject(
308
+ type,
309
+ result,
310
+ unpathedErrors,
311
+ subschema,
312
+ context,
313
+ info,
314
+ skipTypeMerging
315
+ ),
316
+ (result2) => {
317
+ if (info && graphql.isAbstractType(type)) {
320
318
  if (result2.__typename != null) {
321
319
  const resolvedType = info.schema.getType(result2.__typename);
322
320
  if (!resolvedType) {
@@ -325,9 +323,9 @@ function resolveExternalValue(result, unpathedErrors, subschema, context, info,
325
323
  }
326
324
  return result2;
327
325
  }
328
- );
329
- }
330
- return result$;
326
+ return result2;
327
+ }
328
+ );
331
329
  } else if (graphql.isListType(type)) {
332
330
  if (Array.isArray(result)) {
333
331
  return resolveExternalList(
@@ -1937,7 +1935,7 @@ function defaultMergedResolver(parent, args, context, info) {
1937
1935
  missingDeferredFields
1938
1936
  );
1939
1937
  }
1940
- const deferred = utils.createDeferred();
1938
+ const deferred = promiseHelpers.createDeferredPromise();
1941
1939
  missingDeferredFields.set(responseKey, deferred);
1942
1940
  const stitchingInfo = info.schema.extensions?.["stitchingInfo"];
1943
1941
  const parentTypeName = parent?.__typename || info.parentType.name;
@@ -1970,11 +1968,14 @@ function handleResult(parent, responseKey, context, info) {
1970
1968
  );
1971
1969
  const leftOver = getPlanLeftOverFromParent(parent);
1972
1970
  if (leftOver) {
1973
- return utils.mapMaybePromise(resolvedData$, (resolvedData) => {
1974
- parent[responseKey] = resolvedData;
1975
- handleLeftOver(parent, context, info, leftOver);
1976
- return resolvedData;
1977
- });
1971
+ return promiseHelpers.handleMaybePromise(
1972
+ () => resolvedData$,
1973
+ (resolvedData) => {
1974
+ parent[responseKey] = resolvedData;
1975
+ handleLeftOver(parent, context, info, leftOver);
1976
+ return resolvedData;
1977
+ }
1978
+ );
1978
1979
  }
1979
1980
  return resolvedData$;
1980
1981
  }
@@ -2006,19 +2007,22 @@ function handleLeftOver(parent, context, info, leftOver) {
2006
2007
  (selectionSet2) => selectionSet2.selections
2007
2008
  )
2008
2009
  };
2009
- utils.mapMaybePromise(flattenPromise(parent), (flattenedParent) => {
2010
- handleFlattenedParent(
2011
- flattenedParent,
2012
- parent,
2013
- possibleSubschema,
2014
- selectionSet,
2015
- leftOver,
2016
- stitchingInfo,
2017
- parentTypeName,
2018
- context,
2019
- info
2020
- );
2021
- });
2010
+ promiseHelpers.handleMaybePromise(
2011
+ () => flattenPromise(parent),
2012
+ (flattenedParent) => {
2013
+ handleFlattenedParent(
2014
+ flattenedParent,
2015
+ parent,
2016
+ possibleSubschema,
2017
+ selectionSet,
2018
+ leftOver,
2019
+ stitchingInfo,
2020
+ parentTypeName,
2021
+ context,
2022
+ info
2023
+ );
2024
+ }
2025
+ );
2022
2026
  }
2023
2027
  }
2024
2028
  }
@@ -2036,8 +2040,8 @@ function handleFlattenedParent(flattenedParent, leftOverParent, possibleSubschem
2036
2040
  kind: graphql.Kind.SELECTION_SET,
2037
2041
  selections: missingFieldNodes
2038
2042
  };
2039
- utils.mapMaybePromise(
2040
- resolver(
2043
+ promiseHelpers.handleMaybePromise(
2044
+ () => resolver(
2041
2045
  leftOverParent,
2042
2046
  context,
2043
2047
  info,
@@ -2239,7 +2243,7 @@ function parentSatisfiedSelectionSet(parent, selectionSet) {
2239
2243
  return subschemas;
2240
2244
  }
2241
2245
  function flattenPromise(data) {
2242
- if (utils.isPromise(data)) {
2246
+ if (promiseHelpers.isPromise(data)) {
2243
2247
  return data.then(flattenPromise);
2244
2248
  }
2245
2249
  if (Array.isArray(data)) {
@@ -2250,7 +2254,7 @@ function flattenPromise(data) {
2250
2254
  const newData = {};
2251
2255
  for (const key in data) {
2252
2256
  const keyResult = flattenPromise(data[key]);
2253
- if (utils.isPromise(keyResult)) {
2257
+ if (promiseHelpers.isPromise(keyResult)) {
2254
2258
  jobs.push(
2255
2259
  keyResult.then((resolvedKeyResult) => {
2256
2260
  newData[key] = resolvedKeyResult;
@@ -2361,9 +2365,8 @@ function delegateRequest(options) {
2361
2365
  if (options.validateRequest) {
2362
2366
  validateRequest(delegationContext, processedRequest.document);
2363
2367
  }
2364
- const executor = getExecutor(delegationContext);
2365
- return utils.mapMaybePromise(
2366
- executor(processedRequest),
2368
+ return promiseHelpers.handleMaybePromise(
2369
+ () => getExecutor(delegationContext)(processedRequest),
2367
2370
  function handleExecutorResult(executorResult) {
2368
2371
  if (utils.isAsyncIterable(executorResult)) {
2369
2372
  if (delegationContext.operation === "query" && graphql.isListType(delegationContext.returnType)) {
@@ -2420,7 +2423,7 @@ function delegateRequest(options) {
2420
2423
  }
2421
2424
  });
2422
2425
  }
2423
- return utils.mapAsyncIterator(
2426
+ return promiseHelpers.mapAsyncIterator(
2424
2427
  executorResult,
2425
2428
  (result) => transformer.transformResult(result)
2426
2429
  );
package/dist/index.d.cts CHANGED
@@ -1,8 +1,9 @@
1
- import { ExecutionRequest, ExecutionResult, Executor, MaybePromise, PromiseWithResolvers, Maybe } from '@graphql-tools/utils';
1
+ import { ExecutionRequest, ExecutionResult, Executor, Maybe } from '@graphql-tools/utils';
2
2
  export { createDeferred } from '@graphql-tools/utils';
3
3
  import * as graphql from 'graphql';
4
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
+ import { MaybePromise } from '@whatwg-node/promise-helpers';
6
7
  export { executorFromSchema as createDefaultExecutor } from '@graphql-tools/executor';
7
8
 
8
9
  declare const UNPATHED_ERRORS_SYMBOL: unique symbol;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { ExecutionRequest, ExecutionResult, Executor, MaybePromise, PromiseWithResolvers, Maybe } from '@graphql-tools/utils';
1
+ import { ExecutionRequest, ExecutionResult, Executor, Maybe } from '@graphql-tools/utils';
2
2
  export { createDeferred } from '@graphql-tools/utils';
3
3
  import * as graphql from 'graphql';
4
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
+ import { MaybePromise } from '@whatwg-node/promise-helpers';
6
7
  export { executorFromSchema as createDefaultExecutor } from '@graphql-tools/executor';
7
8
 
8
9
  declare const UNPATHED_ERRORS_SYMBOL: unique symbol;
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
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';
1
+ import { memoize2, memoize1, promiseReduce, collectFields, relocatedError, mergeDeep, pathToArray, getResponseKeyFromInfo, astFromType, getDefinedRootType, createGraphQLError, serializeInputValue, implementsAbstractType, getRootTypeNames, isAsyncIterable, getOperationASTFromRequest } from '@graphql-tools/utils';
2
2
  export { createDeferred } from '@graphql-tools/utils';
3
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
+ import { handleMaybePromise, isPromise, createDeferredPromise, mapAsyncIterator } from '@whatwg-node/promise-helpers';
4
5
  import { CRITICAL_ERROR, executorFromSchema } from '@graphql-tools/executor';
5
6
  export { executorFromSchema as createDefaultExecutor } from '@graphql-tools/executor';
6
7
  import { getBatchingExecutor } from '@graphql-tools/batch-execute';
@@ -115,17 +116,15 @@ function mergeFields(mergedTypeInfo, object, sourceSubschema, context, info) {
115
116
  if (leftOver) {
116
117
  object[PLAN_LEFT_OVER] = leftOver;
117
118
  }
118
- return mapMaybePromise(
119
- delegationMaps.reduce(
120
- (prev, delegationMap) => mapMaybePromise(
121
- prev,
122
- () => executeDelegationStage(
123
- mergedTypeInfo,
124
- delegationMap,
125
- object,
126
- context,
127
- info
128
- )
119
+ return handleMaybePromise(
120
+ () => promiseReduce(
121
+ delegationMaps,
122
+ (_, delegationMap) => executeDelegationStage(
123
+ mergedTypeInfo,
124
+ delegationMap,
125
+ object,
126
+ context,
127
+ info
129
128
  ),
130
129
  void 0
131
130
  ),
@@ -304,19 +303,18 @@ function resolveExternalValue(result, unpathedErrors, subschema, context, info,
304
303
  return null;
305
304
  }
306
305
  } else if (isCompositeType(type)) {
307
- const result$ = resolveExternalObject(
308
- type,
309
- result,
310
- unpathedErrors,
311
- subschema,
312
- context,
313
- info,
314
- skipTypeMerging
315
- );
316
- if (info && isAbstractType(type)) {
317
- return mapMaybePromise(
318
- result$,
319
- function checkAbstractResolvedCorrectly(result2) {
306
+ return handleMaybePromise(
307
+ () => resolveExternalObject(
308
+ type,
309
+ result,
310
+ unpathedErrors,
311
+ subschema,
312
+ context,
313
+ info,
314
+ skipTypeMerging
315
+ ),
316
+ (result2) => {
317
+ if (info && isAbstractType(type)) {
320
318
  if (result2.__typename != null) {
321
319
  const resolvedType = info.schema.getType(result2.__typename);
322
320
  if (!resolvedType) {
@@ -325,9 +323,9 @@ function resolveExternalValue(result, unpathedErrors, subschema, context, info,
325
323
  }
326
324
  return result2;
327
325
  }
328
- );
329
- }
330
- return result$;
326
+ return result2;
327
+ }
328
+ );
331
329
  } else if (isListType(type)) {
332
330
  if (Array.isArray(result)) {
333
331
  return resolveExternalList(
@@ -1937,7 +1935,7 @@ function defaultMergedResolver(parent, args, context, info) {
1937
1935
  missingDeferredFields
1938
1936
  );
1939
1937
  }
1940
- const deferred = createDeferred();
1938
+ const deferred = createDeferredPromise();
1941
1939
  missingDeferredFields.set(responseKey, deferred);
1942
1940
  const stitchingInfo = info.schema.extensions?.["stitchingInfo"];
1943
1941
  const parentTypeName = parent?.__typename || info.parentType.name;
@@ -1970,11 +1968,14 @@ function handleResult(parent, responseKey, context, info) {
1970
1968
  );
1971
1969
  const leftOver = getPlanLeftOverFromParent(parent);
1972
1970
  if (leftOver) {
1973
- return mapMaybePromise(resolvedData$, (resolvedData) => {
1974
- parent[responseKey] = resolvedData;
1975
- handleLeftOver(parent, context, info, leftOver);
1976
- return resolvedData;
1977
- });
1971
+ return handleMaybePromise(
1972
+ () => resolvedData$,
1973
+ (resolvedData) => {
1974
+ parent[responseKey] = resolvedData;
1975
+ handleLeftOver(parent, context, info, leftOver);
1976
+ return resolvedData;
1977
+ }
1978
+ );
1978
1979
  }
1979
1980
  return resolvedData$;
1980
1981
  }
@@ -2006,19 +2007,22 @@ function handleLeftOver(parent, context, info, leftOver) {
2006
2007
  (selectionSet2) => selectionSet2.selections
2007
2008
  )
2008
2009
  };
2009
- mapMaybePromise(flattenPromise(parent), (flattenedParent) => {
2010
- handleFlattenedParent(
2011
- flattenedParent,
2012
- parent,
2013
- possibleSubschema,
2014
- selectionSet,
2015
- leftOver,
2016
- stitchingInfo,
2017
- parentTypeName,
2018
- context,
2019
- info
2020
- );
2021
- });
2010
+ handleMaybePromise(
2011
+ () => flattenPromise(parent),
2012
+ (flattenedParent) => {
2013
+ handleFlattenedParent(
2014
+ flattenedParent,
2015
+ parent,
2016
+ possibleSubschema,
2017
+ selectionSet,
2018
+ leftOver,
2019
+ stitchingInfo,
2020
+ parentTypeName,
2021
+ context,
2022
+ info
2023
+ );
2024
+ }
2025
+ );
2022
2026
  }
2023
2027
  }
2024
2028
  }
@@ -2036,8 +2040,8 @@ function handleFlattenedParent(flattenedParent, leftOverParent, possibleSubschem
2036
2040
  kind: Kind.SELECTION_SET,
2037
2041
  selections: missingFieldNodes
2038
2042
  };
2039
- mapMaybePromise(
2040
- resolver(
2043
+ handleMaybePromise(
2044
+ () => resolver(
2041
2045
  leftOverParent,
2042
2046
  context,
2043
2047
  info,
@@ -2361,9 +2365,8 @@ function delegateRequest(options) {
2361
2365
  if (options.validateRequest) {
2362
2366
  validateRequest(delegationContext, processedRequest.document);
2363
2367
  }
2364
- const executor = getExecutor(delegationContext);
2365
- return mapMaybePromise(
2366
- executor(processedRequest),
2368
+ return handleMaybePromise(
2369
+ () => getExecutor(delegationContext)(processedRequest),
2367
2370
  function handleExecutorResult(executorResult) {
2368
2371
  if (isAsyncIterable(executorResult)) {
2369
2372
  if (delegationContext.operation === "query" && isListType(delegationContext.returnType)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/delegate",
3
- "version": "10.2.13",
3
+ "version": "10.2.14-alpha-0700d88cf1e9c11bc4b7dab376d3eb21c02cb1d6",
4
4
  "type": "module",
5
5
  "description": "A set of utils for faster development of GraphQL tools",
6
6
  "repository": {
@@ -38,18 +38,20 @@
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.12",
41
+ "@graphql-tools/batch-execute": "9.0.13-alpha-0700d88cf1e9c11bc4b7dab376d3eb21c02cb1d6",
42
42
  "@graphql-tools/executor": "^1.3.10",
43
43
  "@graphql-tools/schema": "^10.0.11",
44
44
  "@graphql-tools/utils": "^10.8.1",
45
45
  "@repeaterjs/repeater": "^3.0.6",
46
+ "@whatwg-node/promise-helpers": "^1.0.0",
46
47
  "dataloader": "^2.2.3",
47
48
  "dset": "^3.1.2",
48
49
  "tslib": "^2.8.1"
49
50
  },
50
51
  "devDependencies": {
52
+ "@types/lodash": "4.17.15",
51
53
  "graphql": "^16.9.0",
52
- "pkgroll": "2.10.0"
54
+ "pkgroll": "2.11.0"
53
55
  },
54
56
  "sideEffects": false
55
57
  }