@graphql-tools/executor-http 1.2.0 → 1.2.1-alpha-2b5980085d717f9d4c29c1052a95e3c6c05358e4
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 +7 -0
- package/dist/index.cjs +16 -10
- package/dist/index.js +16 -10
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @graphql-tools/executor-http
|
|
2
2
|
|
|
3
|
+
## 1.2.1-alpha-2b5980085d717f9d4c29c1052a95e3c6c05358e4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`b8223a0`](https://github.com/graphql-hive/gateway/commit/b8223a0f28c8308ae8a515e0ade453a02aa7aa37)]:
|
|
8
|
+
- abort-signal-any@0.0.1-alpha-2b5980085d717f9d4c29c1052a95e3c6c05358e4
|
|
9
|
+
|
|
3
10
|
## 1.2.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var utils = require('@graphql-tools/utils');
|
|
4
4
|
var disposablestack = require('@whatwg-node/disposablestack');
|
|
5
5
|
var fetch = require('@whatwg-node/fetch');
|
|
6
|
+
var abortSignalAny = require('abort-signal-any');
|
|
6
7
|
var valueOrPromise = require('value-or-promise');
|
|
7
8
|
var extractFiles = require('extract-files');
|
|
8
9
|
var graphql = require('graphql');
|
|
@@ -156,7 +157,7 @@ const DELIM = "\n\n";
|
|
|
156
157
|
function isReadableStream(value) {
|
|
157
158
|
return value && typeof value.getReader === "function";
|
|
158
159
|
}
|
|
159
|
-
function handleEventStreamResponse(
|
|
160
|
+
function handleEventStreamResponse(response, signal) {
|
|
160
161
|
const body = response.body;
|
|
161
162
|
if (!isReadableStream(body)) {
|
|
162
163
|
throw new Error(
|
|
@@ -172,7 +173,7 @@ function handleEventStreamResponse(signal, response) {
|
|
|
172
173
|
});
|
|
173
174
|
let currChunk = "";
|
|
174
175
|
async function pump() {
|
|
175
|
-
if (signal
|
|
176
|
+
if (signal?.aborted) {
|
|
176
177
|
await push(createResultForAbort(signal));
|
|
177
178
|
return stop();
|
|
178
179
|
}
|
|
@@ -325,13 +326,18 @@ function buildHTTPExecutor(options) {
|
|
|
325
326
|
Object.assign(headers, headersFromExtensions);
|
|
326
327
|
request.extensions = restExtensions;
|
|
327
328
|
}
|
|
328
|
-
|
|
329
|
+
const signals = [sharedSignal];
|
|
330
|
+
const signalFromRequest = request.signal || request.info?.signal;
|
|
331
|
+
if (signalFromRequest) {
|
|
332
|
+
if (signalFromRequest.aborted) {
|
|
333
|
+
return createResultForAbort(signalFromRequest.reason);
|
|
334
|
+
}
|
|
335
|
+
signals.push(signalFromRequest);
|
|
336
|
+
}
|
|
329
337
|
if (options?.timeout) {
|
|
330
|
-
|
|
331
|
-
sharedSignal,
|
|
332
|
-
AbortSignal.timeout(options.timeout)
|
|
333
|
-
]);
|
|
338
|
+
signals.push(AbortSignal.timeout(options.timeout));
|
|
334
339
|
}
|
|
340
|
+
const signal = abortSignalAny.abortSignalAny(signals);
|
|
335
341
|
const upstreamErrorExtensions = {
|
|
336
342
|
request: {
|
|
337
343
|
method
|
|
@@ -435,7 +441,7 @@ function buildHTTPExecutor(options) {
|
|
|
435
441
|
}
|
|
436
442
|
const contentType = fetchResult.headers.get("content-type");
|
|
437
443
|
if (contentType?.includes("text/event-stream")) {
|
|
438
|
-
return handleEventStreamResponse(
|
|
444
|
+
return handleEventStreamResponse(fetchResult, signal);
|
|
439
445
|
} else if (contentType?.includes("multipart/mixed")) {
|
|
440
446
|
return handleMultipartMixedResponse(fetchResult);
|
|
441
447
|
}
|
|
@@ -597,8 +603,8 @@ function coerceFetchError(e, {
|
|
|
597
603
|
extensions: upstreamErrorExtensions,
|
|
598
604
|
originalError: e
|
|
599
605
|
});
|
|
600
|
-
} else if (e.name === "AbortError" && signal
|
|
601
|
-
return createGraphQLErrorForAbort(signal
|
|
606
|
+
} else if (e.name === "AbortError" && signal?.reason) {
|
|
607
|
+
return createGraphQLErrorForAbort(signal?.reason, {
|
|
602
608
|
extensions: upstreamErrorExtensions
|
|
603
609
|
});
|
|
604
610
|
} else if (e.message) {
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isAsyncIterable, isPromise, mapMaybePromise, memoize1, createGraphQLError, inspect, mapAsyncIterator, mergeIncrementalResult, getOperationASTFromRequest } from '@graphql-tools/utils';
|
|
2
2
|
import { DisposableSymbols } from '@whatwg-node/disposablestack';
|
|
3
3
|
import { File, FormData, TextEncoder, crypto, TextDecoder, fetch } from '@whatwg-node/fetch';
|
|
4
|
+
import { abortSignalAny } from 'abort-signal-any';
|
|
4
5
|
import { ValueOrPromise } from 'value-or-promise';
|
|
5
6
|
import { extractFiles, isExtractableFile } from 'extract-files';
|
|
6
7
|
import { stripIgnoredCharacters, print } from 'graphql';
|
|
@@ -154,7 +155,7 @@ const DELIM = "\n\n";
|
|
|
154
155
|
function isReadableStream(value) {
|
|
155
156
|
return value && typeof value.getReader === "function";
|
|
156
157
|
}
|
|
157
|
-
function handleEventStreamResponse(
|
|
158
|
+
function handleEventStreamResponse(response, signal) {
|
|
158
159
|
const body = response.body;
|
|
159
160
|
if (!isReadableStream(body)) {
|
|
160
161
|
throw new Error(
|
|
@@ -170,7 +171,7 @@ function handleEventStreamResponse(signal, response) {
|
|
|
170
171
|
});
|
|
171
172
|
let currChunk = "";
|
|
172
173
|
async function pump() {
|
|
173
|
-
if (signal
|
|
174
|
+
if (signal?.aborted) {
|
|
174
175
|
await push(createResultForAbort(signal));
|
|
175
176
|
return stop();
|
|
176
177
|
}
|
|
@@ -323,13 +324,18 @@ function buildHTTPExecutor(options) {
|
|
|
323
324
|
Object.assign(headers, headersFromExtensions);
|
|
324
325
|
request.extensions = restExtensions;
|
|
325
326
|
}
|
|
326
|
-
|
|
327
|
+
const signals = [sharedSignal];
|
|
328
|
+
const signalFromRequest = request.signal || request.info?.signal;
|
|
329
|
+
if (signalFromRequest) {
|
|
330
|
+
if (signalFromRequest.aborted) {
|
|
331
|
+
return createResultForAbort(signalFromRequest.reason);
|
|
332
|
+
}
|
|
333
|
+
signals.push(signalFromRequest);
|
|
334
|
+
}
|
|
327
335
|
if (options?.timeout) {
|
|
328
|
-
|
|
329
|
-
sharedSignal,
|
|
330
|
-
AbortSignal.timeout(options.timeout)
|
|
331
|
-
]);
|
|
336
|
+
signals.push(AbortSignal.timeout(options.timeout));
|
|
332
337
|
}
|
|
338
|
+
const signal = abortSignalAny(signals);
|
|
333
339
|
const upstreamErrorExtensions = {
|
|
334
340
|
request: {
|
|
335
341
|
method
|
|
@@ -433,7 +439,7 @@ function buildHTTPExecutor(options) {
|
|
|
433
439
|
}
|
|
434
440
|
const contentType = fetchResult.headers.get("content-type");
|
|
435
441
|
if (contentType?.includes("text/event-stream")) {
|
|
436
|
-
return handleEventStreamResponse(
|
|
442
|
+
return handleEventStreamResponse(fetchResult, signal);
|
|
437
443
|
} else if (contentType?.includes("multipart/mixed")) {
|
|
438
444
|
return handleMultipartMixedResponse(fetchResult);
|
|
439
445
|
}
|
|
@@ -595,8 +601,8 @@ function coerceFetchError(e, {
|
|
|
595
601
|
extensions: upstreamErrorExtensions,
|
|
596
602
|
originalError: e
|
|
597
603
|
});
|
|
598
|
-
} else if (e.name === "AbortError" && signal
|
|
599
|
-
return createGraphQLErrorForAbort(signal
|
|
604
|
+
} else if (e.name === "AbortError" && signal?.reason) {
|
|
605
|
+
return createGraphQLErrorForAbort(signal?.reason, {
|
|
600
606
|
extensions: upstreamErrorExtensions
|
|
601
607
|
});
|
|
602
608
|
} else if (e.message) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/executor-http",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1-alpha-2b5980085d717f9d4c29c1052a95e3c6c05358e4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
6
6
|
"repository": {
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"@repeaterjs/repeater": "^3.0.4",
|
|
44
44
|
"@whatwg-node/disposablestack": "^0.0.5",
|
|
45
45
|
"@whatwg-node/fetch": "^0.10.1",
|
|
46
|
+
"abort-signal-any": "0.0.1-alpha-2b5980085d717f9d4c29c1052a95e3c6c05358e4",
|
|
46
47
|
"extract-files": "^11.0.0",
|
|
47
48
|
"meros": "^1.2.1",
|
|
48
49
|
"tslib": "^2.8.1",
|