@graphql-tools/batch-execute 10.0.5 → 10.1.0-alpha-e0aaaf43b7d191baf6d83fd81f3323cbce2fb2c9
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 +23 -0
- package/dist/index.cjs +7 -1
- package/dist/index.js +7 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @graphql-tools/batch-execute
|
|
2
2
|
|
|
3
|
+
## 10.1.0-alpha-e0aaaf43b7d191baf6d83fd81f3323cbce2fb2c9
|
|
4
|
+
### Minor Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [#1928](https://github.com/graphql-hive/gateway/pull/1928) [`51263c0`](https://github.com/graphql-hive/gateway/commit/51263c0c8febd0d46557e87a35d858d3d75fc118) Thanks [@ardatan](https://github.com/ardatan)! - # Execution cancellation on batched requests
|
|
9
|
+
|
|
10
|
+
When using [Batched Execution](https://the-guild.dev/graphql/stitching/handbook/appendices/batching-arrays-and-queries), it is now possible to cancel the entire batched request if all individual requests' `AbortSignal`s are aborted. This enhancement improves resource management and responsiveness in applications that utilize batched GraphQL operations.
|
|
11
|
+
|
|
12
|
+
Previously, aborting individual requests did not affect the batched request. With this update, if all individual requests signal an abort, the batched request will also be aborted, ensuring that unnecessary processing is avoided.
|
|
13
|
+
|
|
14
|
+
This feature is implemented using the new utility function `AbortSignal.all`, which combines multiple `AbortSignal` instances into a single signal. If all of the requests are aborted, the combined signal will also be aborted.
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
- [#1928](https://github.com/graphql-hive/gateway/pull/1928) [`890ac0d`](https://github.com/graphql-hive/gateway/commit/890ac0d972419977f38e9649e70656c1ad8a117a) Thanks [@ardatan](https://github.com/ardatan)! - dependencies updates:
|
|
21
|
+
|
|
22
|
+
- Added dependency [`@graphql-hive/signal@^2.0.0` ↗︎](https://www.npmjs.com/package/@graphql-hive/signal/v/2.0.0) (to `dependencies`)
|
|
23
|
+
- Updated dependencies [[`51263c0`](https://github.com/graphql-hive/gateway/commit/51263c0c8febd0d46557e87a35d858d3d75fc118)]:
|
|
24
|
+
- @graphql-hive/signal@2.1.0-alpha-e0aaaf43b7d191baf6d83fd81f3323cbce2fb2c9
|
|
25
|
+
|
|
3
26
|
## 10.0.5
|
|
4
27
|
### Patch Changes
|
|
5
28
|
|
package/dist/index.cjs
CHANGED
|
@@ -4,6 +4,7 @@ var utils = require('@graphql-tools/utils');
|
|
|
4
4
|
var promiseHelpers = require('@whatwg-node/promise-helpers');
|
|
5
5
|
var DataLoader = require('dataloader');
|
|
6
6
|
var graphql = require('graphql');
|
|
7
|
+
var signal = require('@graphql-hive/signal');
|
|
7
8
|
|
|
8
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
10
|
|
|
@@ -55,6 +56,7 @@ function mergeRequests(requests, extensionsReducer) {
|
|
|
55
56
|
const mergedVariableDefinitions = [];
|
|
56
57
|
const mergedSelections = [];
|
|
57
58
|
const mergedFragmentDefinitions = [];
|
|
59
|
+
const signals = [];
|
|
58
60
|
let mergedExtensions = /* @__PURE__ */ Object.create(null);
|
|
59
61
|
for (let index = 0; index < requests.length; index++) {
|
|
60
62
|
const request = requests[index];
|
|
@@ -73,6 +75,9 @@ function mergeRequests(requests, extensionsReducer) {
|
|
|
73
75
|
}
|
|
74
76
|
Object.assign(mergedVariables, prefixedRequests.variables);
|
|
75
77
|
mergedExtensions = extensionsReducer(mergedExtensions, request);
|
|
78
|
+
if (request.signal) {
|
|
79
|
+
signals.push(request.signal);
|
|
80
|
+
}
|
|
76
81
|
}
|
|
77
82
|
}
|
|
78
83
|
const firstRequest = requests[0];
|
|
@@ -107,7 +112,8 @@ function mergeRequests(requests, extensionsReducer) {
|
|
|
107
112
|
context: firstRequest.context,
|
|
108
113
|
info: firstRequest.info,
|
|
109
114
|
operationType,
|
|
110
|
-
rootValue: firstRequest.rootValue
|
|
115
|
+
rootValue: firstRequest.rootValue,
|
|
116
|
+
signal: signal.abortSignalAll(signals)
|
|
111
117
|
};
|
|
112
118
|
}
|
|
113
119
|
function prefixRequest(prefix, request) {
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { getOperationASTFromRequest, relocatedError, memoize2of4 } from '@graphq
|
|
|
2
2
|
import { fakePromise } from '@whatwg-node/promise-helpers';
|
|
3
3
|
import DataLoader from 'dataloader';
|
|
4
4
|
import { Kind, visit } from 'graphql';
|
|
5
|
+
import { abortSignalAll } from '@graphql-hive/signal';
|
|
5
6
|
|
|
6
7
|
function createPrefix(index) {
|
|
7
8
|
return `_v${index}_`;
|
|
@@ -49,6 +50,7 @@ function mergeRequests(requests, extensionsReducer) {
|
|
|
49
50
|
const mergedVariableDefinitions = [];
|
|
50
51
|
const mergedSelections = [];
|
|
51
52
|
const mergedFragmentDefinitions = [];
|
|
53
|
+
const signals = [];
|
|
52
54
|
let mergedExtensions = /* @__PURE__ */ Object.create(null);
|
|
53
55
|
for (let index = 0; index < requests.length; index++) {
|
|
54
56
|
const request = requests[index];
|
|
@@ -67,6 +69,9 @@ function mergeRequests(requests, extensionsReducer) {
|
|
|
67
69
|
}
|
|
68
70
|
Object.assign(mergedVariables, prefixedRequests.variables);
|
|
69
71
|
mergedExtensions = extensionsReducer(mergedExtensions, request);
|
|
72
|
+
if (request.signal) {
|
|
73
|
+
signals.push(request.signal);
|
|
74
|
+
}
|
|
70
75
|
}
|
|
71
76
|
}
|
|
72
77
|
const firstRequest = requests[0];
|
|
@@ -101,7 +106,8 @@ function mergeRequests(requests, extensionsReducer) {
|
|
|
101
106
|
context: firstRequest.context,
|
|
102
107
|
info: firstRequest.info,
|
|
103
108
|
operationType,
|
|
104
|
-
rootValue: firstRequest.rootValue
|
|
109
|
+
rootValue: firstRequest.rootValue,
|
|
110
|
+
signal: abortSignalAll(signals)
|
|
105
111
|
};
|
|
106
112
|
}
|
|
107
113
|
function prefixRequest(prefix, request) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/batch-execute",
|
|
3
|
-
"version": "10.0
|
|
3
|
+
"version": "10.1.0-alpha-e0aaaf43b7d191baf6d83fd81f3323cbce2fb2c9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
6
6
|
"repository": {
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
+
"@graphql-hive/signal": "2.1.0-alpha-e0aaaf43b7d191baf6d83fd81f3323cbce2fb2c9",
|
|
41
42
|
"@graphql-tools/utils": "^11.0.0",
|
|
42
43
|
"@whatwg-node/promise-helpers": "^1.3.2",
|
|
43
44
|
"dataloader": "^2.2.3",
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"graphql": "^16.12.0",
|
|
48
|
-
"pkgroll": "2.
|
|
49
|
+
"pkgroll": "2.23.0"
|
|
49
50
|
},
|
|
50
51
|
"sideEffects": false
|
|
51
52
|
}
|