@graphql-tools/executor-http 1.2.1 → 1.2.2-alpha-01a86000440fc91c6376fb49202a4534b4bc5697
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 +6 -0
- package/dist/index.cjs +19 -7
- package/dist/index.js +20 -8
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @graphql-tools/executor-http
|
|
2
2
|
|
|
3
|
+
## 1.2.2-alpha-01a86000440fc91c6376fb49202a4534b4bc5697
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#367](https://github.com/graphql-hive/gateway/pull/367) [`01a8600`](https://github.com/graphql-hive/gateway/commit/01a86000440fc91c6376fb49202a4534b4bc5697) Thanks [@ardatan](https://github.com/ardatan)! - Fix Retry / Timeout combination
|
|
8
|
+
|
|
3
9
|
## 1.2.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -129,8 +129,18 @@ function createAbortErrorReason() {
|
|
|
129
129
|
return new Error("Executor was disposed.");
|
|
130
130
|
}
|
|
131
131
|
function createGraphQLErrorForAbort(reason, extensions) {
|
|
132
|
+
if (reason instanceof graphql.GraphQLError) {
|
|
133
|
+
return reason;
|
|
134
|
+
}
|
|
135
|
+
if (reason?.name === "TimeoutError") {
|
|
136
|
+
return utils.createGraphQLError(reason.message, {
|
|
137
|
+
extensions,
|
|
138
|
+
originalError: reason
|
|
139
|
+
});
|
|
140
|
+
}
|
|
132
141
|
return utils.createGraphQLError("The operation was aborted. reason: " + reason, {
|
|
133
|
-
extensions
|
|
142
|
+
extensions,
|
|
143
|
+
originalError: reason
|
|
134
144
|
});
|
|
135
145
|
}
|
|
136
146
|
function createResultForAbort(reason, extensions) {
|
|
@@ -341,8 +351,7 @@ function buildHTTPExecutor(options) {
|
|
|
341
351
|
const upstreamErrorExtensions = {
|
|
342
352
|
request: {
|
|
343
353
|
method
|
|
344
|
-
}
|
|
345
|
-
response: {}
|
|
354
|
+
}
|
|
346
355
|
};
|
|
347
356
|
const query = printFn(request.document);
|
|
348
357
|
let serializeFn = function serialize() {
|
|
@@ -427,6 +436,7 @@ function buildHTTPExecutor(options) {
|
|
|
427
436
|
}
|
|
428
437
|
}
|
|
429
438
|
}).then((fetchResult) => {
|
|
439
|
+
upstreamErrorExtensions.response ||= {};
|
|
430
440
|
upstreamErrorExtensions.response.status = fetchResult.status;
|
|
431
441
|
upstreamErrorExtensions.response.statusText = fetchResult.statusText;
|
|
432
442
|
Object.defineProperty(upstreamErrorExtensions.response, "headers", {
|
|
@@ -448,6 +458,7 @@ function buildHTTPExecutor(options) {
|
|
|
448
458
|
return fetchResult.text();
|
|
449
459
|
}).then((result) => {
|
|
450
460
|
if (typeof result === "string") {
|
|
461
|
+
upstreamErrorExtensions.response ||= {};
|
|
451
462
|
upstreamErrorExtensions.response.body = result;
|
|
452
463
|
if (result) {
|
|
453
464
|
try {
|
|
@@ -603,10 +614,11 @@ function coerceFetchError(e, {
|
|
|
603
614
|
extensions: upstreamErrorExtensions,
|
|
604
615
|
originalError: e
|
|
605
616
|
});
|
|
606
|
-
} else if (e.name === "AbortError"
|
|
607
|
-
return createGraphQLErrorForAbort(
|
|
608
|
-
|
|
609
|
-
|
|
617
|
+
} else if (e.name === "AbortError") {
|
|
618
|
+
return createGraphQLErrorForAbort(
|
|
619
|
+
signal?.reason || e,
|
|
620
|
+
upstreamErrorExtensions
|
|
621
|
+
);
|
|
610
622
|
} else if (e.message) {
|
|
611
623
|
return utils.createGraphQLError(e.message, {
|
|
612
624
|
extensions: upstreamErrorExtensions,
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { DisposableSymbols } from '@whatwg-node/disposablestack';
|
|
|
4
4
|
import { File, FormData, TextEncoder, crypto, TextDecoder, fetch } from '@whatwg-node/fetch';
|
|
5
5
|
import { ValueOrPromise } from 'value-or-promise';
|
|
6
6
|
import { extractFiles, isExtractableFile } from 'extract-files';
|
|
7
|
-
import { stripIgnoredCharacters, print } from 'graphql';
|
|
7
|
+
import { stripIgnoredCharacters, print, GraphQLError } from 'graphql';
|
|
8
8
|
import { Repeater } from '@repeaterjs/repeater';
|
|
9
9
|
import { meros as meros$1 } from 'meros/browser';
|
|
10
10
|
import { meros } from 'meros/node';
|
|
@@ -127,8 +127,18 @@ function createAbortErrorReason() {
|
|
|
127
127
|
return new Error("Executor was disposed.");
|
|
128
128
|
}
|
|
129
129
|
function createGraphQLErrorForAbort(reason, extensions) {
|
|
130
|
+
if (reason instanceof GraphQLError) {
|
|
131
|
+
return reason;
|
|
132
|
+
}
|
|
133
|
+
if (reason?.name === "TimeoutError") {
|
|
134
|
+
return createGraphQLError(reason.message, {
|
|
135
|
+
extensions,
|
|
136
|
+
originalError: reason
|
|
137
|
+
});
|
|
138
|
+
}
|
|
130
139
|
return createGraphQLError("The operation was aborted. reason: " + reason, {
|
|
131
|
-
extensions
|
|
140
|
+
extensions,
|
|
141
|
+
originalError: reason
|
|
132
142
|
});
|
|
133
143
|
}
|
|
134
144
|
function createResultForAbort(reason, extensions) {
|
|
@@ -339,8 +349,7 @@ function buildHTTPExecutor(options) {
|
|
|
339
349
|
const upstreamErrorExtensions = {
|
|
340
350
|
request: {
|
|
341
351
|
method
|
|
342
|
-
}
|
|
343
|
-
response: {}
|
|
352
|
+
}
|
|
344
353
|
};
|
|
345
354
|
const query = printFn(request.document);
|
|
346
355
|
let serializeFn = function serialize() {
|
|
@@ -425,6 +434,7 @@ function buildHTTPExecutor(options) {
|
|
|
425
434
|
}
|
|
426
435
|
}
|
|
427
436
|
}).then((fetchResult) => {
|
|
437
|
+
upstreamErrorExtensions.response ||= {};
|
|
428
438
|
upstreamErrorExtensions.response.status = fetchResult.status;
|
|
429
439
|
upstreamErrorExtensions.response.statusText = fetchResult.statusText;
|
|
430
440
|
Object.defineProperty(upstreamErrorExtensions.response, "headers", {
|
|
@@ -446,6 +456,7 @@ function buildHTTPExecutor(options) {
|
|
|
446
456
|
return fetchResult.text();
|
|
447
457
|
}).then((result) => {
|
|
448
458
|
if (typeof result === "string") {
|
|
459
|
+
upstreamErrorExtensions.response ||= {};
|
|
449
460
|
upstreamErrorExtensions.response.body = result;
|
|
450
461
|
if (result) {
|
|
451
462
|
try {
|
|
@@ -601,10 +612,11 @@ function coerceFetchError(e, {
|
|
|
601
612
|
extensions: upstreamErrorExtensions,
|
|
602
613
|
originalError: e
|
|
603
614
|
});
|
|
604
|
-
} else if (e.name === "AbortError"
|
|
605
|
-
return createGraphQLErrorForAbort(
|
|
606
|
-
|
|
607
|
-
|
|
615
|
+
} else if (e.name === "AbortError") {
|
|
616
|
+
return createGraphQLErrorForAbort(
|
|
617
|
+
signal?.reason || e,
|
|
618
|
+
upstreamErrorExtensions
|
|
619
|
+
);
|
|
608
620
|
} else if (e.message) {
|
|
609
621
|
return createGraphQLError(e.message, {
|
|
610
622
|
extensions: upstreamErrorExtensions,
|
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.2-alpha-01a86000440fc91c6376fb49202a4534b4bc5697",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
6
6
|
"repository": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@types/extract-files": "8.1.3",
|
|
55
55
|
"@whatwg-node/disposablestack": "^0.0.5",
|
|
56
56
|
"graphql": "^16.9.0",
|
|
57
|
-
"graphql-yoga": "^5.10.
|
|
57
|
+
"graphql-yoga": "^5.10.6",
|
|
58
58
|
"pkgroll": "2.5.1"
|
|
59
59
|
},
|
|
60
60
|
"sideEffects": false
|