@graphql-tools/batch-delegate 10.0.1 → 10.0.2-alpha-d83adffc9111fdd4d1112c93a9b70254b1a42e09

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,15 @@
1
1
  # @graphql-tools/batch-delegate
2
2
 
3
+ ## 10.0.2-alpha-d83adffc9111fdd4d1112c93a9b70254b1a42e09
4
+ ### Patch Changes
5
+
6
+
7
+
8
+ - [#1556](https://github.com/graphql-hive/gateway/pull/1556) [`d83adff`](https://github.com/graphql-hive/gateway/commit/d83adffc9111fdd4d1112c93a9b70254b1a42e09) Thanks [@ardatan](https://github.com/ardatan)! - Correct error paths in case of batch delegation with the same error
9
+
10
+ - Updated dependencies [[`d83adff`](https://github.com/graphql-hive/gateway/commit/d83adffc9111fdd4d1112c93a9b70254b1a42e09)]:
11
+ - @graphql-tools/delegate@11.0.2-alpha-d83adffc9111fdd4d1112c93a9b70254b1a42e09
12
+
3
13
  ## 10.0.1
4
14
  ### Patch Changes
5
15
 
package/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ var promiseHelpers = require('@whatwg-node/promise-helpers');
4
+ var graphql = require('graphql');
3
5
  var delegate = require('@graphql-tools/delegate');
4
6
  var utils = require('@graphql-tools/utils');
5
- var promiseHelpers = require('@whatwg-node/promise-helpers');
6
7
  var DataLoader = require('dataloader');
7
- var graphql = require('graphql');
8
8
 
9
9
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
10
 
@@ -107,7 +107,16 @@ function batchDelegateToSchema(options) {
107
107
  return [];
108
108
  }
109
109
  const loader = getLoader(options);
110
- return Array.isArray(key) ? loader.loadMany(key) : loader.load(key);
110
+ return promiseHelpers.handleMaybePromise(
111
+ () => Array.isArray(key) ? loader.loadMany(key) : loader.load(key),
112
+ (res) => res,
113
+ (error) => {
114
+ if (options.info?.path && error instanceof graphql.GraphQLError) {
115
+ return utils.relocatedError(error, utils.pathToArray(options.info.path));
116
+ }
117
+ return error;
118
+ }
119
+ );
111
120
  }
112
121
 
113
122
  function createBatchDelegateFn(optionsOrArgsFromKeys, lazyOptionsFn, dataLoaderOptions, valuesFromResults) {
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
+ import { fakePromise, handleMaybePromise } from '@whatwg-node/promise-helpers';
2
+ import { getNamedType, print, GraphQLList, GraphQLError } from 'graphql';
1
3
  import { getActualFieldNodes, delegateToSchema } from '@graphql-tools/delegate';
2
- import { memoize2, memoize1, relocatedError } from '@graphql-tools/utils';
3
- import { fakePromise } from '@whatwg-node/promise-helpers';
4
+ import { memoize2, memoize1, relocatedError, pathToArray } from '@graphql-tools/utils';
4
5
  import DataLoader from 'dataloader';
5
- import { getNamedType, print, GraphQLList } from 'graphql';
6
6
 
7
7
  const DEFAULT_ARGS_FROM_KEYS = (keys) => ({ ids: keys });
8
8
  function createBatchFn(options) {
@@ -101,7 +101,16 @@ function batchDelegateToSchema(options) {
101
101
  return [];
102
102
  }
103
103
  const loader = getLoader(options);
104
- return Array.isArray(key) ? loader.loadMany(key) : loader.load(key);
104
+ return handleMaybePromise(
105
+ () => Array.isArray(key) ? loader.loadMany(key) : loader.load(key),
106
+ (res) => res,
107
+ (error) => {
108
+ if (options.info?.path && error instanceof GraphQLError) {
109
+ return relocatedError(error, pathToArray(options.info.path));
110
+ }
111
+ return error;
112
+ }
113
+ );
105
114
  }
106
115
 
107
116
  function createBatchDelegateFn(optionsOrArgsFromKeys, lazyOptionsFn, dataLoaderOptions, valuesFromResults) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/batch-delegate",
3
- "version": "10.0.1",
3
+ "version": "10.0.2-alpha-d83adffc9111fdd4d1112c93a9b70254b1a42e09",
4
4
  "type": "module",
5
5
  "description": "A set of utils for faster development of GraphQL tools",
6
6
  "repository": {
@@ -38,7 +38,7 @@
38
38
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
39
39
  },
40
40
  "dependencies": {
41
- "@graphql-tools/delegate": "^11.0.1",
41
+ "@graphql-tools/delegate": "11.0.2-alpha-d83adffc9111fdd4d1112c93a9b70254b1a42e09",
42
42
  "@graphql-tools/utils": "^10.9.1",
43
43
  "@whatwg-node/promise-helpers": "^1.3.2",
44
44
  "dataloader": "^2.2.3",