@graphql-tools/url-loader 7.13.7 → 7.13.8-alpha-20220812093637-a8293ed7
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/event-stream/addCancelToResponseStream.js +26 -0
- package/cjs/event-stream/handleEventStreamResponse.js +9 -2
- package/cjs/handleMultipartMixedResponse.js +7 -2
- package/cjs/index.js +25 -16
- package/esm/event-stream/addCancelToResponseStream.js +21 -0
- package/esm/event-stream/handleEventStreamResponse.js +9 -2
- package/esm/handleMultipartMixedResponse.js +7 -2
- package/esm/index.js +25 -16
- package/package.json +3 -3
- package/typings/{addCancelToResponseStream.d.cts → event-stream/addCancelToResponseStream.d.cts} +1 -0
- package/typings/{addCancelToResponseStream.d.ts → event-stream/addCancelToResponseStream.d.ts} +1 -0
- package/typings/event-stream/handleEventStreamResponse.d.cts +1 -1
- package/typings/event-stream/handleEventStreamResponse.d.ts +1 -1
- package/typings/handleMultipartMixedResponse.d.cts +1 -1
- package/typings/handleMultipartMixedResponse.d.ts +1 -1
- package/typings/index.d.cts +1 -1
- package/typings/index.d.ts +1 -1
- package/cjs/addCancelToResponseStream.js +0 -12
- package/esm/addCancelToResponseStream.js +0 -8
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addCancelToResponseStream = exports.cancelNeeded = void 0;
|
|
4
|
+
const utils_1 = require("@graphql-tools/utils");
|
|
5
|
+
function cancelNeeded() {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
if ((_b = (_a = globalThis.process) === null || _a === void 0 ? void 0 : _a.versions) === null || _b === void 0 ? void 0 : _b.node) {
|
|
8
|
+
const [nodeMajorStr, nodeMinorStr] = process.versions.node.split('.');
|
|
9
|
+
const nodeMajor = parseInt(nodeMajorStr);
|
|
10
|
+
const nodeMinor = parseInt(nodeMinorStr);
|
|
11
|
+
if (nodeMajor > 16 || (nodeMajor === 16 && nodeMinor >= 5)) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
exports.cancelNeeded = cancelNeeded;
|
|
19
|
+
function addCancelToResponseStream(resultStream, controller) {
|
|
20
|
+
return (0, utils_1.withCancel)(resultStream, () => {
|
|
21
|
+
if (!controller.signal.aborted) {
|
|
22
|
+
controller.abort();
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.addCancelToResponseStream = addCancelToResponseStream;
|
|
@@ -4,11 +4,12 @@ exports.handleEventStreamResponse = exports.isReadableStream = void 0;
|
|
|
4
4
|
const utils_1 = require("@graphql-tools/utils");
|
|
5
5
|
const handleAsyncIterable_js_1 = require("./handleAsyncIterable.js");
|
|
6
6
|
const handleReadableStream_js_1 = require("./handleReadableStream.js");
|
|
7
|
+
const addCancelToResponseStream_js_1 = require("./addCancelToResponseStream.js");
|
|
7
8
|
function isReadableStream(value) {
|
|
8
9
|
return value && typeof value.getReader === 'function';
|
|
9
10
|
}
|
|
10
11
|
exports.isReadableStream = isReadableStream;
|
|
11
|
-
async function handleEventStreamResponse(response) {
|
|
12
|
+
async function handleEventStreamResponse(response, controller) {
|
|
12
13
|
// node-fetch returns body as a promise so we need to resolve it
|
|
13
14
|
const body = response.body;
|
|
14
15
|
if (body) {
|
|
@@ -16,7 +17,13 @@ async function handleEventStreamResponse(response) {
|
|
|
16
17
|
return (0, handleReadableStream_js_1.handleReadableStream)(body);
|
|
17
18
|
}
|
|
18
19
|
if ((0, utils_1.isAsyncIterable)(body)) {
|
|
19
|
-
|
|
20
|
+
const resultStream = (0, handleAsyncIterable_js_1.handleAsyncIterable)(body);
|
|
21
|
+
if (controller) {
|
|
22
|
+
return (0, addCancelToResponseStream_js_1.addCancelToResponseStream)(resultStream, controller);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return resultStream;
|
|
26
|
+
}
|
|
20
27
|
}
|
|
21
28
|
}
|
|
22
29
|
throw new Error('Response body is expected to be a readable stream but got; ' + (0, utils_1.inspect)(body));
|
|
@@ -5,10 +5,11 @@ const node_1 = require("meros/node");
|
|
|
5
5
|
const browser_1 = require("meros/browser");
|
|
6
6
|
const utils_1 = require("@graphql-tools/utils");
|
|
7
7
|
const merge_1 = require("dset/merge");
|
|
8
|
+
const addCancelToResponseStream_js_1 = require("./event-stream/addCancelToResponseStream.js");
|
|
8
9
|
function isIncomingMessage(body) {
|
|
9
10
|
return body != null && typeof body === 'object' && 'pipe' in body;
|
|
10
11
|
}
|
|
11
|
-
async function handleMultipartMixedResponse(response) {
|
|
12
|
+
async function handleMultipartMixedResponse(response, controller) {
|
|
12
13
|
const body = await response.body;
|
|
13
14
|
const contentType = response.headers.get('content-type') || '';
|
|
14
15
|
let asyncIterator;
|
|
@@ -25,7 +26,7 @@ async function handleMultipartMixedResponse(response) {
|
|
|
25
26
|
asyncIterator = (await (0, browser_1.meros)(response));
|
|
26
27
|
}
|
|
27
28
|
const executionResult = {};
|
|
28
|
-
|
|
29
|
+
const resultStream = (0, utils_1.mapAsyncIterator)(asyncIterator, (part) => {
|
|
29
30
|
if (part.json) {
|
|
30
31
|
const chunk = part.body;
|
|
31
32
|
if (chunk.path) {
|
|
@@ -48,5 +49,9 @@ async function handleMultipartMixedResponse(response) {
|
|
|
48
49
|
return executionResult;
|
|
49
50
|
}
|
|
50
51
|
});
|
|
52
|
+
if (controller) {
|
|
53
|
+
return (0, addCancelToResponseStream_js_1.addCancelToResponseStream)(resultStream, controller);
|
|
54
|
+
}
|
|
55
|
+
return resultStream;
|
|
51
56
|
}
|
|
52
57
|
exports.handleMultipartMixedResponse = handleMultipartMixedResponse;
|
package/cjs/index.js
CHANGED
|
@@ -16,7 +16,7 @@ const defaultAsyncFetch_js_1 = require("./defaultAsyncFetch.js");
|
|
|
16
16
|
const defaultSyncFetch_js_1 = require("./defaultSyncFetch.js");
|
|
17
17
|
const handleMultipartMixedResponse_js_1 = require("./handleMultipartMixedResponse.js");
|
|
18
18
|
const handleEventStreamResponse_js_1 = require("./event-stream/handleEventStreamResponse.js");
|
|
19
|
-
const addCancelToResponseStream_js_1 = require("./addCancelToResponseStream.js");
|
|
19
|
+
const addCancelToResponseStream_js_1 = require("./event-stream/addCancelToResponseStream.js");
|
|
20
20
|
const fetch_1 = require("@whatwg-node/fetch");
|
|
21
21
|
const utils_js_1 = require("./utils.js");
|
|
22
22
|
const asyncImport = (moduleName) => Promise.resolve().then(() => tslib_1.__importStar(require(moduleName)));
|
|
@@ -67,6 +67,14 @@ class UrlLoader {
|
|
|
67
67
|
(0, utils_1.isAsyncIterable)(v) ||
|
|
68
68
|
(v === null || v === void 0 ? void 0 : v.then) ||
|
|
69
69
|
typeof (v === null || v === void 0 ? void 0 : v.arrayBuffer) === 'function'));
|
|
70
|
+
if (files.size === 0) {
|
|
71
|
+
return JSON.stringify({
|
|
72
|
+
query,
|
|
73
|
+
variables,
|
|
74
|
+
operationName,
|
|
75
|
+
extensions,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
70
78
|
const map = {};
|
|
71
79
|
const uploads = [];
|
|
72
80
|
let currIndex = 0;
|
|
@@ -92,9 +100,7 @@ class UrlLoader {
|
|
|
92
100
|
// If Blob
|
|
93
101
|
}
|
|
94
102
|
else if ((0, utils_js_1.isBlob)(upload)) {
|
|
95
|
-
|
|
96
|
-
form.append(indexStr, new fetch_1.File([arrayBuffer], filename, { type: upload.type }), filename);
|
|
97
|
-
});
|
|
103
|
+
form.append(indexStr, upload, filename);
|
|
98
104
|
}
|
|
99
105
|
else if ((0, utils_js_1.isGraphQLUpload)(upload)) {
|
|
100
106
|
const stream = upload.createReadStream();
|
|
@@ -151,14 +157,14 @@ class UrlLoader {
|
|
|
151
157
|
});
|
|
152
158
|
const executor = (request) => {
|
|
153
159
|
var _a, _b;
|
|
154
|
-
const controller = new fetch_1.AbortController();
|
|
160
|
+
const controller = (0, addCancelToResponseStream_js_1.cancelNeeded)() ? new fetch_1.AbortController() : undefined;
|
|
155
161
|
let method = defaultMethod;
|
|
156
162
|
const operationAst = (0, utils_1.getOperationASTFromRequest)(request);
|
|
157
163
|
const operationType = operationAst.operation;
|
|
158
164
|
if ((options === null || options === void 0 ? void 0 : options.useGETForQueries) && operationType === 'query') {
|
|
159
165
|
method = 'GET';
|
|
160
166
|
}
|
|
161
|
-
let accept = 'application/json
|
|
167
|
+
let accept = 'application/json';
|
|
162
168
|
if (operationType === 'subscription' || (0, graphql_live_query_1.isLiveQueryOperationDefinitionNode)(operationAst)) {
|
|
163
169
|
method = 'GET';
|
|
164
170
|
accept = 'text/event-stream';
|
|
@@ -177,8 +183,8 @@ class UrlLoader {
|
|
|
177
183
|
let timeoutId;
|
|
178
184
|
if (options === null || options === void 0 ? void 0 : options.timeout) {
|
|
179
185
|
timeoutId = setTimeout(() => {
|
|
180
|
-
if (!controller.signal.aborted) {
|
|
181
|
-
controller.abort();
|
|
186
|
+
if (!(controller === null || controller === void 0 ? void 0 : controller.signal.aborted)) {
|
|
187
|
+
controller === null || controller === void 0 ? void 0 : controller.abort();
|
|
182
188
|
}
|
|
183
189
|
}, options.timeout);
|
|
184
190
|
}
|
|
@@ -194,17 +200,20 @@ class UrlLoader {
|
|
|
194
200
|
method: 'GET',
|
|
195
201
|
...(credentials != null ? { credentials } : {}),
|
|
196
202
|
headers,
|
|
197
|
-
signal: controller.signal,
|
|
203
|
+
signal: controller === null || controller === void 0 ? void 0 : controller.signal,
|
|
198
204
|
});
|
|
199
205
|
case 'POST':
|
|
200
206
|
if (options === null || options === void 0 ? void 0 : options.multipart) {
|
|
201
207
|
return new value_or_promise_1.ValueOrPromise(() => this.createFormDataFromVariables(requestBody))
|
|
202
|
-
.then(
|
|
208
|
+
.then(body => fetch(endpoint, {
|
|
203
209
|
method: 'POST',
|
|
204
210
|
...(credentials != null ? { credentials } : {}),
|
|
205
|
-
body
|
|
206
|
-
headers
|
|
207
|
-
|
|
211
|
+
body,
|
|
212
|
+
headers: {
|
|
213
|
+
...headers,
|
|
214
|
+
...(typeof body === 'string' ? { 'content-type': 'application/json' } : {}),
|
|
215
|
+
},
|
|
216
|
+
signal: controller === null || controller === void 0 ? void 0 : controller.signal,
|
|
208
217
|
}))
|
|
209
218
|
.resolve();
|
|
210
219
|
}
|
|
@@ -217,7 +226,7 @@ class UrlLoader {
|
|
|
217
226
|
'content-type': 'application/json',
|
|
218
227
|
...headers,
|
|
219
228
|
},
|
|
220
|
-
signal: controller.signal,
|
|
229
|
+
signal: controller === null || controller === void 0 ? void 0 : controller.signal,
|
|
221
230
|
});
|
|
222
231
|
}
|
|
223
232
|
}
|
|
@@ -232,10 +241,10 @@ class UrlLoader {
|
|
|
232
241
|
}
|
|
233
242
|
const contentType = fetchResult.headers.get('content-type');
|
|
234
243
|
if (contentType === null || contentType === void 0 ? void 0 : contentType.includes('text/event-stream')) {
|
|
235
|
-
return (0, handleEventStreamResponse_js_1.handleEventStreamResponse)(fetchResult
|
|
244
|
+
return (0, handleEventStreamResponse_js_1.handleEventStreamResponse)(fetchResult, controller);
|
|
236
245
|
}
|
|
237
246
|
else if (contentType === null || contentType === void 0 ? void 0 : contentType.includes('multipart/mixed')) {
|
|
238
|
-
return (0, handleMultipartMixedResponse_js_1.handleMultipartMixedResponse)(fetchResult
|
|
247
|
+
return (0, handleMultipartMixedResponse_js_1.handleMultipartMixedResponse)(fetchResult, controller);
|
|
239
248
|
}
|
|
240
249
|
return fetchResult.text();
|
|
241
250
|
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { withCancel } from '@graphql-tools/utils';
|
|
2
|
+
export function cancelNeeded() {
|
|
3
|
+
var _a, _b;
|
|
4
|
+
if ((_b = (_a = globalThis.process) === null || _a === void 0 ? void 0 : _a.versions) === null || _b === void 0 ? void 0 : _b.node) {
|
|
5
|
+
const [nodeMajorStr, nodeMinorStr] = process.versions.node.split('.');
|
|
6
|
+
const nodeMajor = parseInt(nodeMajorStr);
|
|
7
|
+
const nodeMinor = parseInt(nodeMinorStr);
|
|
8
|
+
if (nodeMajor > 16 || (nodeMajor === 16 && nodeMinor >= 5)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
export function addCancelToResponseStream(resultStream, controller) {
|
|
16
|
+
return withCancel(resultStream, () => {
|
|
17
|
+
if (!controller.signal.aborted) {
|
|
18
|
+
controller.abort();
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { inspect, isAsyncIterable } from '@graphql-tools/utils';
|
|
2
2
|
import { handleAsyncIterable } from './handleAsyncIterable.js';
|
|
3
3
|
import { handleReadableStream } from './handleReadableStream.js';
|
|
4
|
+
import { addCancelToResponseStream } from './addCancelToResponseStream.js';
|
|
4
5
|
export function isReadableStream(value) {
|
|
5
6
|
return value && typeof value.getReader === 'function';
|
|
6
7
|
}
|
|
7
|
-
export async function handleEventStreamResponse(response) {
|
|
8
|
+
export async function handleEventStreamResponse(response, controller) {
|
|
8
9
|
// node-fetch returns body as a promise so we need to resolve it
|
|
9
10
|
const body = response.body;
|
|
10
11
|
if (body) {
|
|
@@ -12,7 +13,13 @@ export async function handleEventStreamResponse(response) {
|
|
|
12
13
|
return handleReadableStream(body);
|
|
13
14
|
}
|
|
14
15
|
if (isAsyncIterable(body)) {
|
|
15
|
-
|
|
16
|
+
const resultStream = handleAsyncIterable(body);
|
|
17
|
+
if (controller) {
|
|
18
|
+
return addCancelToResponseStream(resultStream, controller);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return resultStream;
|
|
22
|
+
}
|
|
16
23
|
}
|
|
17
24
|
}
|
|
18
25
|
throw new Error('Response body is expected to be a readable stream but got; ' + inspect(body));
|
|
@@ -2,10 +2,11 @@ import { meros as merosIncomingMessage } from 'meros/node';
|
|
|
2
2
|
import { meros as merosReadableStream } from 'meros/browser';
|
|
3
3
|
import { mapAsyncIterator } from '@graphql-tools/utils';
|
|
4
4
|
import { dset } from 'dset/merge';
|
|
5
|
+
import { addCancelToResponseStream } from './event-stream/addCancelToResponseStream.js';
|
|
5
6
|
function isIncomingMessage(body) {
|
|
6
7
|
return body != null && typeof body === 'object' && 'pipe' in body;
|
|
7
8
|
}
|
|
8
|
-
export async function handleMultipartMixedResponse(response) {
|
|
9
|
+
export async function handleMultipartMixedResponse(response, controller) {
|
|
9
10
|
const body = await response.body;
|
|
10
11
|
const contentType = response.headers.get('content-type') || '';
|
|
11
12
|
let asyncIterator;
|
|
@@ -22,7 +23,7 @@ export async function handleMultipartMixedResponse(response) {
|
|
|
22
23
|
asyncIterator = (await merosReadableStream(response));
|
|
23
24
|
}
|
|
24
25
|
const executionResult = {};
|
|
25
|
-
|
|
26
|
+
const resultStream = mapAsyncIterator(asyncIterator, (part) => {
|
|
26
27
|
if (part.json) {
|
|
27
28
|
const chunk = part.body;
|
|
28
29
|
if (chunk.path) {
|
|
@@ -45,4 +46,8 @@ export async function handleMultipartMixedResponse(response) {
|
|
|
45
46
|
return executionResult;
|
|
46
47
|
}
|
|
47
48
|
});
|
|
49
|
+
if (controller) {
|
|
50
|
+
return addCancelToResponseStream(resultStream, controller);
|
|
51
|
+
}
|
|
52
|
+
return resultStream;
|
|
48
53
|
}
|
package/esm/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import { defaultAsyncFetch } from './defaultAsyncFetch.js';
|
|
|
12
12
|
import { defaultSyncFetch } from './defaultSyncFetch.js';
|
|
13
13
|
import { handleMultipartMixedResponse } from './handleMultipartMixedResponse.js';
|
|
14
14
|
import { handleEventStreamResponse } from './event-stream/handleEventStreamResponse.js';
|
|
15
|
-
import {
|
|
15
|
+
import { cancelNeeded } from './event-stream/addCancelToResponseStream.js';
|
|
16
16
|
import { AbortController, FormData, File } from '@whatwg-node/fetch';
|
|
17
17
|
import { isBlob, isGraphQLUpload, isPromiseLike, LEGACY_WS } from './utils.js';
|
|
18
18
|
const asyncImport = (moduleName) => import(moduleName);
|
|
@@ -63,6 +63,14 @@ export class UrlLoader {
|
|
|
63
63
|
isAsyncIterable(v) ||
|
|
64
64
|
(v === null || v === void 0 ? void 0 : v.then) ||
|
|
65
65
|
typeof (v === null || v === void 0 ? void 0 : v.arrayBuffer) === 'function'));
|
|
66
|
+
if (files.size === 0) {
|
|
67
|
+
return JSON.stringify({
|
|
68
|
+
query,
|
|
69
|
+
variables,
|
|
70
|
+
operationName,
|
|
71
|
+
extensions,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
66
74
|
const map = {};
|
|
67
75
|
const uploads = [];
|
|
68
76
|
let currIndex = 0;
|
|
@@ -88,9 +96,7 @@ export class UrlLoader {
|
|
|
88
96
|
// If Blob
|
|
89
97
|
}
|
|
90
98
|
else if (isBlob(upload)) {
|
|
91
|
-
|
|
92
|
-
form.append(indexStr, new File([arrayBuffer], filename, { type: upload.type }), filename);
|
|
93
|
-
});
|
|
99
|
+
form.append(indexStr, upload, filename);
|
|
94
100
|
}
|
|
95
101
|
else if (isGraphQLUpload(upload)) {
|
|
96
102
|
const stream = upload.createReadStream();
|
|
@@ -147,14 +153,14 @@ export class UrlLoader {
|
|
|
147
153
|
});
|
|
148
154
|
const executor = (request) => {
|
|
149
155
|
var _a, _b;
|
|
150
|
-
const controller = new AbortController();
|
|
156
|
+
const controller = cancelNeeded() ? new AbortController() : undefined;
|
|
151
157
|
let method = defaultMethod;
|
|
152
158
|
const operationAst = getOperationASTFromRequest(request);
|
|
153
159
|
const operationType = operationAst.operation;
|
|
154
160
|
if ((options === null || options === void 0 ? void 0 : options.useGETForQueries) && operationType === 'query') {
|
|
155
161
|
method = 'GET';
|
|
156
162
|
}
|
|
157
|
-
let accept = 'application/json
|
|
163
|
+
let accept = 'application/json';
|
|
158
164
|
if (operationType === 'subscription' || isLiveQueryOperationDefinitionNode(operationAst)) {
|
|
159
165
|
method = 'GET';
|
|
160
166
|
accept = 'text/event-stream';
|
|
@@ -173,8 +179,8 @@ export class UrlLoader {
|
|
|
173
179
|
let timeoutId;
|
|
174
180
|
if (options === null || options === void 0 ? void 0 : options.timeout) {
|
|
175
181
|
timeoutId = setTimeout(() => {
|
|
176
|
-
if (!controller.signal.aborted) {
|
|
177
|
-
controller.abort();
|
|
182
|
+
if (!(controller === null || controller === void 0 ? void 0 : controller.signal.aborted)) {
|
|
183
|
+
controller === null || controller === void 0 ? void 0 : controller.abort();
|
|
178
184
|
}
|
|
179
185
|
}, options.timeout);
|
|
180
186
|
}
|
|
@@ -190,17 +196,20 @@ export class UrlLoader {
|
|
|
190
196
|
method: 'GET',
|
|
191
197
|
...(credentials != null ? { credentials } : {}),
|
|
192
198
|
headers,
|
|
193
|
-
signal: controller.signal,
|
|
199
|
+
signal: controller === null || controller === void 0 ? void 0 : controller.signal,
|
|
194
200
|
});
|
|
195
201
|
case 'POST':
|
|
196
202
|
if (options === null || options === void 0 ? void 0 : options.multipart) {
|
|
197
203
|
return new ValueOrPromise(() => this.createFormDataFromVariables(requestBody))
|
|
198
|
-
.then(
|
|
204
|
+
.then(body => fetch(endpoint, {
|
|
199
205
|
method: 'POST',
|
|
200
206
|
...(credentials != null ? { credentials } : {}),
|
|
201
|
-
body
|
|
202
|
-
headers
|
|
203
|
-
|
|
207
|
+
body,
|
|
208
|
+
headers: {
|
|
209
|
+
...headers,
|
|
210
|
+
...(typeof body === 'string' ? { 'content-type': 'application/json' } : {}),
|
|
211
|
+
},
|
|
212
|
+
signal: controller === null || controller === void 0 ? void 0 : controller.signal,
|
|
204
213
|
}))
|
|
205
214
|
.resolve();
|
|
206
215
|
}
|
|
@@ -213,7 +222,7 @@ export class UrlLoader {
|
|
|
213
222
|
'content-type': 'application/json',
|
|
214
223
|
...headers,
|
|
215
224
|
},
|
|
216
|
-
signal: controller.signal,
|
|
225
|
+
signal: controller === null || controller === void 0 ? void 0 : controller.signal,
|
|
217
226
|
});
|
|
218
227
|
}
|
|
219
228
|
}
|
|
@@ -228,10 +237,10 @@ export class UrlLoader {
|
|
|
228
237
|
}
|
|
229
238
|
const contentType = fetchResult.headers.get('content-type');
|
|
230
239
|
if (contentType === null || contentType === void 0 ? void 0 : contentType.includes('text/event-stream')) {
|
|
231
|
-
return handleEventStreamResponse(fetchResult
|
|
240
|
+
return handleEventStreamResponse(fetchResult, controller);
|
|
232
241
|
}
|
|
233
242
|
else if (contentType === null || contentType === void 0 ? void 0 : contentType.includes('multipart/mixed')) {
|
|
234
|
-
return handleMultipartMixedResponse(fetchResult
|
|
243
|
+
return handleMultipartMixedResponse(fetchResult, controller);
|
|
235
244
|
}
|
|
236
245
|
return fetchResult.text();
|
|
237
246
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/url-loader",
|
|
3
|
-
"version": "7.13.
|
|
3
|
+
"version": "7.13.8-alpha-20220812093637-a8293ed7",
|
|
4
4
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@graphql-tools/delegate": "9.0.3",
|
|
11
11
|
"@graphql-tools/utils": "8.10.0",
|
|
12
|
-
"@graphql-tools/wrap": "9.0.
|
|
12
|
+
"@graphql-tools/wrap": "9.0.4-alpha-20220812093637-a8293ed7",
|
|
13
13
|
"@ardatan/sync-fetch": "0.0.1",
|
|
14
14
|
"@n1ru4l/graphql-live-query": "^0.10.0",
|
|
15
15
|
"@types/ws": "^8.0.0",
|
|
16
|
-
"@whatwg-node/fetch": "^0.2.
|
|
16
|
+
"@whatwg-node/fetch": "^0.2.9",
|
|
17
17
|
"dset": "^3.1.2",
|
|
18
18
|
"extract-files": "^11.0.0",
|
|
19
19
|
"graphql-ws": "^5.4.1",
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ExecutionResult } from 'graphql';
|
|
2
2
|
export declare function isReadableStream(value: any): value is ReadableStream;
|
|
3
|
-
export declare function handleEventStreamResponse(response: Response): Promise<AsyncIterable<ExecutionResult>>;
|
|
3
|
+
export declare function handleEventStreamResponse(response: Response, controller?: AbortController): Promise<AsyncIterable<ExecutionResult>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ExecutionResult } from 'graphql';
|
|
2
2
|
export declare function isReadableStream(value: any): value is ReadableStream;
|
|
3
|
-
export declare function handleEventStreamResponse(response: Response): Promise<AsyncIterable<ExecutionResult>>;
|
|
3
|
+
export declare function handleEventStreamResponse(response: Response, controller?: AbortController): Promise<AsyncIterable<ExecutionResult>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ExecutionResult } from 'graphql';
|
|
2
|
-
export declare function handleMultipartMixedResponse(response: Response): Promise<
|
|
2
|
+
export declare function handleMultipartMixedResponse(response: Response, controller?: AbortController): Promise<AsyncIterable<ExecutionResult<import("graphql/jsutils/ObjMap").ObjMap<unknown>, import("graphql/jsutils/ObjMap").ObjMap<unknown>> | undefined>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ExecutionResult } from 'graphql';
|
|
2
|
-
export declare function handleMultipartMixedResponse(response: Response): Promise<
|
|
2
|
+
export declare function handleMultipartMixedResponse(response: Response, controller?: AbortController): Promise<AsyncIterable<ExecutionResult<import("graphql/jsutils/ObjMap").ObjMap<unknown>, import("graphql/jsutils/ObjMap").ObjMap<unknown>> | undefined>>;
|
package/typings/index.d.cts
CHANGED
|
@@ -120,7 +120,7 @@ export declare class UrlLoader implements Loader<LoadFromUrlOptions> {
|
|
|
120
120
|
variables: TVariables;
|
|
121
121
|
operationName?: string;
|
|
122
122
|
extensions?: any;
|
|
123
|
-
}): FormData | Promise<FormData>;
|
|
123
|
+
}): string | FormData | Promise<FormData>;
|
|
124
124
|
prepareGETUrl({ baseUrl, query, variables, operationName, extensions, }: {
|
|
125
125
|
baseUrl: string;
|
|
126
126
|
query: string;
|
package/typings/index.d.ts
CHANGED
|
@@ -120,7 +120,7 @@ export declare class UrlLoader implements Loader<LoadFromUrlOptions> {
|
|
|
120
120
|
variables: TVariables;
|
|
121
121
|
operationName?: string;
|
|
122
122
|
extensions?: any;
|
|
123
|
-
}): FormData | Promise<FormData>;
|
|
123
|
+
}): string | FormData | Promise<FormData>;
|
|
124
124
|
prepareGETUrl({ baseUrl, query, variables, operationName, extensions, }: {
|
|
125
125
|
baseUrl: string;
|
|
126
126
|
query: string;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addCancelToResponseStream = void 0;
|
|
4
|
-
const utils_1 = require("@graphql-tools/utils");
|
|
5
|
-
function addCancelToResponseStream(resultStream, controller) {
|
|
6
|
-
return (0, utils_1.withCancel)(resultStream, () => {
|
|
7
|
-
if (!controller.signal.aborted) {
|
|
8
|
-
controller.abort();
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
exports.addCancelToResponseStream = addCancelToResponseStream;
|