@graphql-tools/executor 1.2.2 → 1.2.3-rc-20240321094334-45d083dabf3175feeb56af73b0ee06d98d83a1ae
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/cjs/execution/execute.js
CHANGED
|
@@ -815,7 +815,8 @@ function flattenIncrementalResults(incrementalResults, signal) {
|
|
|
815
815
|
let done = false;
|
|
816
816
|
signal?.addEventListener('abort', () => {
|
|
817
817
|
done = true;
|
|
818
|
-
|
|
818
|
+
// we catch here to avoid unhandled promise rejection
|
|
819
|
+
subsequentIterator.throw?.(signal?.reason).catch(() => undefined);
|
|
819
820
|
});
|
|
820
821
|
return {
|
|
821
822
|
[Symbol.asyncIterator]() {
|
|
@@ -1163,6 +1164,11 @@ function getCompletedIncrementalResults(exeContext) {
|
|
|
1163
1164
|
}
|
|
1164
1165
|
function yieldSubsequentPayloads(exeContext) {
|
|
1165
1166
|
let isDone = false;
|
|
1167
|
+
exeContext.signal?.addEventListener('abort', () => {
|
|
1168
|
+
for (const payload of exeContext.subsequentPayloads) {
|
|
1169
|
+
payload.cancel(exeContext.signal?.reason);
|
|
1170
|
+
}
|
|
1171
|
+
});
|
|
1166
1172
|
async function next() {
|
|
1167
1173
|
if (isDone) {
|
|
1168
1174
|
return { value: undefined, done: true };
|
|
@@ -1222,10 +1228,11 @@ class DeferredFragmentRecord {
|
|
|
1222
1228
|
this._exeContext.subsequentPayloads.add(this);
|
|
1223
1229
|
this.isCompleted = false;
|
|
1224
1230
|
this.data = null;
|
|
1225
|
-
this.promise = new Promise(resolve => {
|
|
1231
|
+
this.promise = new Promise((resolve, reject) => {
|
|
1226
1232
|
this._resolve = MaybePromise => {
|
|
1227
1233
|
resolve(MaybePromise);
|
|
1228
1234
|
};
|
|
1235
|
+
this._reject = reject;
|
|
1229
1236
|
}).then(data => {
|
|
1230
1237
|
this.data = data;
|
|
1231
1238
|
this.isCompleted = true;
|
|
@@ -1239,6 +1246,9 @@ class DeferredFragmentRecord {
|
|
|
1239
1246
|
}
|
|
1240
1247
|
this._resolve?.(data);
|
|
1241
1248
|
}
|
|
1249
|
+
cancel(reason) {
|
|
1250
|
+
this._reject?.(reason);
|
|
1251
|
+
}
|
|
1242
1252
|
}
|
|
1243
1253
|
class StreamRecord {
|
|
1244
1254
|
constructor(opts) {
|
|
@@ -1253,10 +1263,11 @@ class StreamRecord {
|
|
|
1253
1263
|
this._exeContext.subsequentPayloads.add(this);
|
|
1254
1264
|
this.isCompleted = false;
|
|
1255
1265
|
this.items = null;
|
|
1256
|
-
this.promise = new Promise(resolve => {
|
|
1266
|
+
this.promise = new Promise((resolve, reject) => {
|
|
1257
1267
|
this._resolve = MaybePromise => {
|
|
1258
1268
|
resolve(MaybePromise);
|
|
1259
1269
|
};
|
|
1270
|
+
this._reject = reject;
|
|
1260
1271
|
}).then(items => {
|
|
1261
1272
|
this.items = items;
|
|
1262
1273
|
this.isCompleted = true;
|
|
@@ -1273,6 +1284,9 @@ class StreamRecord {
|
|
|
1273
1284
|
setIsCompletedIterator() {
|
|
1274
1285
|
this.isCompletedIterator = true;
|
|
1275
1286
|
}
|
|
1287
|
+
cancel(reason) {
|
|
1288
|
+
this._reject?.(reason);
|
|
1289
|
+
}
|
|
1276
1290
|
}
|
|
1277
1291
|
function isStreamPayload(asyncPayload) {
|
|
1278
1292
|
return asyncPayload.type === 'stream';
|
package/esm/execution/execute.js
CHANGED
|
@@ -804,7 +804,8 @@ export function flattenIncrementalResults(incrementalResults, signal) {
|
|
|
804
804
|
let done = false;
|
|
805
805
|
signal?.addEventListener('abort', () => {
|
|
806
806
|
done = true;
|
|
807
|
-
|
|
807
|
+
// we catch here to avoid unhandled promise rejection
|
|
808
|
+
subsequentIterator.throw?.(signal?.reason).catch(() => undefined);
|
|
808
809
|
});
|
|
809
810
|
return {
|
|
810
811
|
[Symbol.asyncIterator]() {
|
|
@@ -1151,6 +1152,11 @@ function getCompletedIncrementalResults(exeContext) {
|
|
|
1151
1152
|
}
|
|
1152
1153
|
function yieldSubsequentPayloads(exeContext) {
|
|
1153
1154
|
let isDone = false;
|
|
1155
|
+
exeContext.signal?.addEventListener('abort', () => {
|
|
1156
|
+
for (const payload of exeContext.subsequentPayloads) {
|
|
1157
|
+
payload.cancel(exeContext.signal?.reason);
|
|
1158
|
+
}
|
|
1159
|
+
});
|
|
1154
1160
|
async function next() {
|
|
1155
1161
|
if (isDone) {
|
|
1156
1162
|
return { value: undefined, done: true };
|
|
@@ -1210,10 +1216,11 @@ class DeferredFragmentRecord {
|
|
|
1210
1216
|
this._exeContext.subsequentPayloads.add(this);
|
|
1211
1217
|
this.isCompleted = false;
|
|
1212
1218
|
this.data = null;
|
|
1213
|
-
this.promise = new Promise(resolve => {
|
|
1219
|
+
this.promise = new Promise((resolve, reject) => {
|
|
1214
1220
|
this._resolve = MaybePromise => {
|
|
1215
1221
|
resolve(MaybePromise);
|
|
1216
1222
|
};
|
|
1223
|
+
this._reject = reject;
|
|
1217
1224
|
}).then(data => {
|
|
1218
1225
|
this.data = data;
|
|
1219
1226
|
this.isCompleted = true;
|
|
@@ -1227,6 +1234,9 @@ class DeferredFragmentRecord {
|
|
|
1227
1234
|
}
|
|
1228
1235
|
this._resolve?.(data);
|
|
1229
1236
|
}
|
|
1237
|
+
cancel(reason) {
|
|
1238
|
+
this._reject?.(reason);
|
|
1239
|
+
}
|
|
1230
1240
|
}
|
|
1231
1241
|
class StreamRecord {
|
|
1232
1242
|
constructor(opts) {
|
|
@@ -1241,10 +1251,11 @@ class StreamRecord {
|
|
|
1241
1251
|
this._exeContext.subsequentPayloads.add(this);
|
|
1242
1252
|
this.isCompleted = false;
|
|
1243
1253
|
this.items = null;
|
|
1244
|
-
this.promise = new Promise(resolve => {
|
|
1254
|
+
this.promise = new Promise((resolve, reject) => {
|
|
1245
1255
|
this._resolve = MaybePromise => {
|
|
1246
1256
|
resolve(MaybePromise);
|
|
1247
1257
|
};
|
|
1258
|
+
this._reject = reject;
|
|
1248
1259
|
}).then(items => {
|
|
1249
1260
|
this.items = items;
|
|
1250
1261
|
this.isCompleted = true;
|
|
@@ -1261,6 +1272,9 @@ class StreamRecord {
|
|
|
1261
1272
|
setIsCompletedIterator() {
|
|
1262
1273
|
this.isCompletedIterator = true;
|
|
1263
1274
|
}
|
|
1275
|
+
cancel(reason) {
|
|
1276
|
+
this._reject?.(reason);
|
|
1277
|
+
}
|
|
1264
1278
|
}
|
|
1265
1279
|
function isStreamPayload(asyncPayload) {
|
|
1266
1280
|
return asyncPayload.type === 'stream';
|
package/package.json
CHANGED
|
@@ -216,6 +216,7 @@ declare class DeferredFragmentRecord {
|
|
|
216
216
|
isCompleted: boolean;
|
|
217
217
|
_exeContext: ExecutionContext;
|
|
218
218
|
_resolve?: (arg: MaybePromise<Record<string, unknown> | null>) => void;
|
|
219
|
+
_reject?: (reason: unknown) => void;
|
|
219
220
|
constructor(opts: {
|
|
220
221
|
label: string | undefined;
|
|
221
222
|
path: Path | undefined;
|
|
@@ -223,6 +224,7 @@ declare class DeferredFragmentRecord {
|
|
|
223
224
|
exeContext: ExecutionContext;
|
|
224
225
|
});
|
|
225
226
|
addData(data: MaybePromise<Record<string, unknown> | null>): void;
|
|
227
|
+
cancel(reason: unknown): void;
|
|
226
228
|
}
|
|
227
229
|
declare class StreamRecord {
|
|
228
230
|
type: 'stream';
|
|
@@ -237,6 +239,7 @@ declare class StreamRecord {
|
|
|
237
239
|
isCompleted: boolean;
|
|
238
240
|
_exeContext: ExecutionContext;
|
|
239
241
|
_resolve?: (arg: MaybePromise<Array<unknown> | null>) => void;
|
|
242
|
+
_reject?: (reason: unknown) => void;
|
|
240
243
|
constructor(opts: {
|
|
241
244
|
label: string | undefined;
|
|
242
245
|
path: Path | undefined;
|
|
@@ -246,6 +249,7 @@ declare class StreamRecord {
|
|
|
246
249
|
});
|
|
247
250
|
addItems(items: MaybePromise<Array<unknown> | null>): void;
|
|
248
251
|
setIsCompletedIterator(): void;
|
|
252
|
+
cancel(reason: unknown): void;
|
|
249
253
|
}
|
|
250
254
|
type AsyncPayloadRecord = DeferredFragmentRecord | StreamRecord;
|
|
251
255
|
/**
|
|
@@ -216,6 +216,7 @@ declare class DeferredFragmentRecord {
|
|
|
216
216
|
isCompleted: boolean;
|
|
217
217
|
_exeContext: ExecutionContext;
|
|
218
218
|
_resolve?: (arg: MaybePromise<Record<string, unknown> | null>) => void;
|
|
219
|
+
_reject?: (reason: unknown) => void;
|
|
219
220
|
constructor(opts: {
|
|
220
221
|
label: string | undefined;
|
|
221
222
|
path: Path | undefined;
|
|
@@ -223,6 +224,7 @@ declare class DeferredFragmentRecord {
|
|
|
223
224
|
exeContext: ExecutionContext;
|
|
224
225
|
});
|
|
225
226
|
addData(data: MaybePromise<Record<string, unknown> | null>): void;
|
|
227
|
+
cancel(reason: unknown): void;
|
|
226
228
|
}
|
|
227
229
|
declare class StreamRecord {
|
|
228
230
|
type: 'stream';
|
|
@@ -237,6 +239,7 @@ declare class StreamRecord {
|
|
|
237
239
|
isCompleted: boolean;
|
|
238
240
|
_exeContext: ExecutionContext;
|
|
239
241
|
_resolve?: (arg: MaybePromise<Array<unknown> | null>) => void;
|
|
242
|
+
_reject?: (reason: unknown) => void;
|
|
240
243
|
constructor(opts: {
|
|
241
244
|
label: string | undefined;
|
|
242
245
|
path: Path | undefined;
|
|
@@ -246,6 +249,7 @@ declare class StreamRecord {
|
|
|
246
249
|
});
|
|
247
250
|
addItems(items: MaybePromise<Array<unknown> | null>): void;
|
|
248
251
|
setIsCompletedIterator(): void;
|
|
252
|
+
cancel(reason: unknown): void;
|
|
249
253
|
}
|
|
250
254
|
type AsyncPayloadRecord = DeferredFragmentRecord | StreamRecord;
|
|
251
255
|
/**
|