@graphql-tools/batch-delegate 9.0.36 → 9.0.37-alpha-071d64e79465dc9de058cc16c99ec1a5472d2bc1
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 +9 -0
- package/dist/index.cjs +25 -31
- package/dist/index.js +26 -32
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @graphql-tools/batch-delegate
|
|
2
2
|
|
|
3
|
+
## 9.0.37-alpha-071d64e79465dc9de058cc16c99ec1a5472d2bc1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1134](https://github.com/graphql-hive/gateway/pull/1134) [`071d64e`](https://github.com/graphql-hive/gateway/commit/071d64e79465dc9de058cc16c99ec1a5472d2bc1) Thanks [@ardatan](https://github.com/ardatan)! - Small improvements on usage of promise helpers
|
|
8
|
+
|
|
9
|
+
- Updated dependencies []:
|
|
10
|
+
- @graphql-tools/delegate@10.2.19-alpha-071d64e79465dc9de058cc16c99ec1a5472d2bc1
|
|
11
|
+
|
|
3
12
|
## 9.0.36
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -16,38 +16,32 @@ function createBatchFn(options) {
|
|
|
16
16
|
const fieldName = options.fieldName ?? options.info.fieldName;
|
|
17
17
|
const { valuesFromResults, lazyOptionsFn } = options;
|
|
18
18
|
return function batchFn(keys) {
|
|
19
|
-
return promiseHelpers.fakePromise(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
returnType
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return originalError;
|
|
28
|
-
}
|
|
29
|
-
const [pathFieldName, pathNumber, ...rest] = originalError.path;
|
|
30
|
-
if (pathFieldName !== fieldName) {
|
|
31
|
-
return originalError;
|
|
32
|
-
}
|
|
33
|
-
const pathNumberType = typeof pathNumber;
|
|
34
|
-
if (pathNumberType !== "number") {
|
|
35
|
-
return originalError;
|
|
36
|
-
}
|
|
37
|
-
return utils.relocatedError(originalError, [fieldName, ...rest]);
|
|
38
|
-
},
|
|
39
|
-
args: argsFromKeys(keys),
|
|
40
|
-
...lazyOptionsFn == null ? options : lazyOptionsFn(options, keys)
|
|
41
|
-
}),
|
|
42
|
-
(results) => {
|
|
43
|
-
if (results instanceof Error) {
|
|
44
|
-
return keys.map(() => results);
|
|
19
|
+
return promiseHelpers.fakePromise().then(
|
|
20
|
+
() => delegate.delegateToSchema({
|
|
21
|
+
returnType: new graphql.GraphQLList(
|
|
22
|
+
graphql.getNamedType(options.returnType || options.info.returnType)
|
|
23
|
+
),
|
|
24
|
+
onLocatedError: (originalError) => {
|
|
25
|
+
if (originalError.path == null) {
|
|
26
|
+
return originalError;
|
|
45
27
|
}
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
28
|
+
const [pathFieldName, pathNumber, ...rest] = originalError.path;
|
|
29
|
+
if (pathFieldName !== fieldName) {
|
|
30
|
+
return originalError;
|
|
31
|
+
}
|
|
32
|
+
const pathNumberType = typeof pathNumber;
|
|
33
|
+
if (pathNumberType !== "number") {
|
|
34
|
+
return originalError;
|
|
35
|
+
}
|
|
36
|
+
return utils.relocatedError(originalError, [fieldName, ...rest]);
|
|
37
|
+
},
|
|
38
|
+
args: argsFromKeys(keys),
|
|
39
|
+
...lazyOptionsFn == null ? options : lazyOptionsFn(options, keys)
|
|
40
|
+
})
|
|
41
|
+
).then((results) => {
|
|
42
|
+
const values = valuesFromResults == null ? results : results instanceof Error ? keys.map(() => results) : valuesFromResults(results, keys);
|
|
43
|
+
return Array.isArray(values) ? values : keys.map(() => values);
|
|
44
|
+
}).catch((error) => keys.map(() => error));
|
|
51
45
|
};
|
|
52
46
|
}
|
|
53
47
|
const getLoadersMap = utils.memoize2(function getLoadersMap2(_context, _schema) {
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getActualFieldNodes, delegateToSchema } from '@graphql-tools/delegate';
|
|
2
2
|
import { memoize2, memoize1, relocatedError } from '@graphql-tools/utils';
|
|
3
|
-
import { fakePromise
|
|
3
|
+
import { fakePromise } from '@whatwg-node/promise-helpers';
|
|
4
4
|
import DataLoader from 'dataloader';
|
|
5
5
|
import { getNamedType, print, GraphQLList } from 'graphql';
|
|
6
6
|
|
|
@@ -10,38 +10,32 @@ function createBatchFn(options) {
|
|
|
10
10
|
const fieldName = options.fieldName ?? options.info.fieldName;
|
|
11
11
|
const { valuesFromResults, lazyOptionsFn } = options;
|
|
12
12
|
return function batchFn(keys) {
|
|
13
|
-
return fakePromise(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
returnType
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return originalError;
|
|
22
|
-
}
|
|
23
|
-
const [pathFieldName, pathNumber, ...rest] = originalError.path;
|
|
24
|
-
if (pathFieldName !== fieldName) {
|
|
25
|
-
return originalError;
|
|
26
|
-
}
|
|
27
|
-
const pathNumberType = typeof pathNumber;
|
|
28
|
-
if (pathNumberType !== "number") {
|
|
29
|
-
return originalError;
|
|
30
|
-
}
|
|
31
|
-
return relocatedError(originalError, [fieldName, ...rest]);
|
|
32
|
-
},
|
|
33
|
-
args: argsFromKeys(keys),
|
|
34
|
-
...lazyOptionsFn == null ? options : lazyOptionsFn(options, keys)
|
|
35
|
-
}),
|
|
36
|
-
(results) => {
|
|
37
|
-
if (results instanceof Error) {
|
|
38
|
-
return keys.map(() => results);
|
|
13
|
+
return fakePromise().then(
|
|
14
|
+
() => delegateToSchema({
|
|
15
|
+
returnType: new GraphQLList(
|
|
16
|
+
getNamedType(options.returnType || options.info.returnType)
|
|
17
|
+
),
|
|
18
|
+
onLocatedError: (originalError) => {
|
|
19
|
+
if (originalError.path == null) {
|
|
20
|
+
return originalError;
|
|
39
21
|
}
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
22
|
+
const [pathFieldName, pathNumber, ...rest] = originalError.path;
|
|
23
|
+
if (pathFieldName !== fieldName) {
|
|
24
|
+
return originalError;
|
|
25
|
+
}
|
|
26
|
+
const pathNumberType = typeof pathNumber;
|
|
27
|
+
if (pathNumberType !== "number") {
|
|
28
|
+
return originalError;
|
|
29
|
+
}
|
|
30
|
+
return relocatedError(originalError, [fieldName, ...rest]);
|
|
31
|
+
},
|
|
32
|
+
args: argsFromKeys(keys),
|
|
33
|
+
...lazyOptionsFn == null ? options : lazyOptionsFn(options, keys)
|
|
34
|
+
})
|
|
35
|
+
).then((results) => {
|
|
36
|
+
const values = valuesFromResults == null ? results : results instanceof Error ? keys.map(() => results) : valuesFromResults(results, keys);
|
|
37
|
+
return Array.isArray(values) ? values : keys.map(() => values);
|
|
38
|
+
}).catch((error) => keys.map(() => error));
|
|
45
39
|
};
|
|
46
40
|
}
|
|
47
41
|
const getLoadersMap = memoize2(function getLoadersMap2(_context, _schema) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/batch-delegate",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.37-alpha-071d64e79465dc9de058cc16c99ec1a5472d2bc1",
|
|
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": "
|
|
41
|
+
"@graphql-tools/delegate": "10.2.19-alpha-071d64e79465dc9de058cc16c99ec1a5472d2bc1",
|
|
42
42
|
"@graphql-tools/utils": "^10.8.1",
|
|
43
43
|
"@whatwg-node/promise-helpers": "^1.3.0",
|
|
44
44
|
"dataloader": "^2.2.3",
|