@graphql-tools/url-loader 7.13.3-alpha-33fb2950.0 → 7.13.3
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/handleReadableStream.js +15 -2
- package/cjs/index.js +2 -6
- package/esm/event-stream/handleReadableStream.js +15 -2
- package/esm/index.js +2 -6
- package/package.json +8 -6
- package/typings/event-stream/handleEventStreamResponse.d.ts +1 -1
- package/typings/event-stream/handleReadableStream.d.ts +2 -2
- package/typings/handleMultipartMixedResponse.d.ts +2 -2
- package/typings/index.d.ts +1 -1
|
@@ -10,7 +10,9 @@ function handleReadableStream(readableStream) {
|
|
|
10
10
|
const reader = readableStream.getReader();
|
|
11
11
|
let completed = false;
|
|
12
12
|
function pump() {
|
|
13
|
-
return reader
|
|
13
|
+
return reader
|
|
14
|
+
.read()
|
|
15
|
+
.then(({ done, value }) => {
|
|
14
16
|
if (completed) {
|
|
15
17
|
return;
|
|
16
18
|
}
|
|
@@ -36,13 +38,24 @@ function handleReadableStream(readableStream) {
|
|
|
36
38
|
else {
|
|
37
39
|
pump();
|
|
38
40
|
}
|
|
41
|
+
})
|
|
42
|
+
.catch(e => {
|
|
43
|
+
// canceling a request in browsers throws an error,
|
|
44
|
+
// ignore it to avoid uncaught promise exceptions
|
|
45
|
+
if (!completed)
|
|
46
|
+
throw e;
|
|
39
47
|
});
|
|
40
48
|
}
|
|
41
49
|
pump();
|
|
42
50
|
return {
|
|
43
51
|
unsubscribe: () => {
|
|
44
|
-
reader.cancel();
|
|
45
52
|
completed = true;
|
|
53
|
+
reader.cancel().catch(e => {
|
|
54
|
+
// canceling a request in browsers throws an error,
|
|
55
|
+
// ignore it to avoid uncaught promise exceptions
|
|
56
|
+
if (!completed)
|
|
57
|
+
throw e;
|
|
58
|
+
});
|
|
46
59
|
},
|
|
47
60
|
};
|
|
48
61
|
},
|
package/cjs/index.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.UrlLoader = exports.SubscriptionProtocol = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
/* eslint-disable no-case-declarations */
|
|
6
6
|
/// <reference lib="dom" />
|
|
7
|
-
const graphql_1 = require("
|
|
7
|
+
const graphql_1 = require("graphql");
|
|
8
8
|
const utils_1 = require("@graphql-tools/utils");
|
|
9
9
|
const wrap_1 = require("@graphql-tools/wrap");
|
|
10
10
|
const graphql_ws_1 = require("graphql-ws");
|
|
@@ -159,7 +159,6 @@ class UrlLoader {
|
|
|
159
159
|
method = 'GET';
|
|
160
160
|
}
|
|
161
161
|
let accept = 'application/json, multipart/mixed';
|
|
162
|
-
// @ts-expect-error Uses graphql-js so it doesn't like us
|
|
163
162
|
if (operationType === 'subscription' || (0, graphql_live_query_1.isLiveQueryOperationDefinitionNode)(operationAst)) {
|
|
164
163
|
method = 'GET';
|
|
165
164
|
accept = 'text/event-stream';
|
|
@@ -308,9 +307,7 @@ class UrlLoader {
|
|
|
308
307
|
variables: variables,
|
|
309
308
|
operationName,
|
|
310
309
|
extensions,
|
|
311
|
-
},
|
|
312
|
-
// @ts-expect-error Uses graphql-js so it doesn't like us
|
|
313
|
-
observer);
|
|
310
|
+
}, observer);
|
|
314
311
|
return {
|
|
315
312
|
unsubscribe,
|
|
316
313
|
};
|
|
@@ -496,7 +493,6 @@ class UrlLoader {
|
|
|
496
493
|
function getExecutorByRequest(request) {
|
|
497
494
|
const operationAst = (0, utils_1.getOperationASTFromRequest)(request);
|
|
498
495
|
if (operationAst.operation === 'subscription' ||
|
|
499
|
-
// @ts-expect-error Uses graphql-js so it doesn't like us
|
|
500
496
|
(0, graphql_live_query_1.isLiveQueryOperationDefinitionNode)(operationAst, request.variables)) {
|
|
501
497
|
return subscriptionExecutor$;
|
|
502
498
|
}
|
|
@@ -7,7 +7,9 @@ export function handleReadableStream(readableStream) {
|
|
|
7
7
|
const reader = readableStream.getReader();
|
|
8
8
|
let completed = false;
|
|
9
9
|
function pump() {
|
|
10
|
-
return reader
|
|
10
|
+
return reader
|
|
11
|
+
.read()
|
|
12
|
+
.then(({ done, value }) => {
|
|
11
13
|
if (completed) {
|
|
12
14
|
return;
|
|
13
15
|
}
|
|
@@ -33,13 +35,24 @@ export function handleReadableStream(readableStream) {
|
|
|
33
35
|
else {
|
|
34
36
|
pump();
|
|
35
37
|
}
|
|
38
|
+
})
|
|
39
|
+
.catch(e => {
|
|
40
|
+
// canceling a request in browsers throws an error,
|
|
41
|
+
// ignore it to avoid uncaught promise exceptions
|
|
42
|
+
if (!completed)
|
|
43
|
+
throw e;
|
|
36
44
|
});
|
|
37
45
|
}
|
|
38
46
|
pump();
|
|
39
47
|
return {
|
|
40
48
|
unsubscribe: () => {
|
|
41
|
-
reader.cancel();
|
|
42
49
|
completed = true;
|
|
50
|
+
reader.cancel().catch(e => {
|
|
51
|
+
// canceling a request in browsers throws an error,
|
|
52
|
+
// ignore it to avoid uncaught promise exceptions
|
|
53
|
+
if (!completed)
|
|
54
|
+
throw e;
|
|
55
|
+
});
|
|
43
56
|
},
|
|
44
57
|
};
|
|
45
58
|
},
|
package/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-case-declarations */
|
|
2
2
|
/// <reference lib="dom" />
|
|
3
|
-
import { print, buildASTSchema, buildSchema } from '
|
|
3
|
+
import { print, buildASTSchema, buildSchema } from 'graphql';
|
|
4
4
|
import { observableToAsyncIterable, isAsyncIterable, parseGraphQLSDL, getOperationASTFromRequest, } from '@graphql-tools/utils';
|
|
5
5
|
import { introspectSchema, wrapSchema } from '@graphql-tools/wrap';
|
|
6
6
|
import { createClient } from 'graphql-ws';
|
|
@@ -155,7 +155,6 @@ export class UrlLoader {
|
|
|
155
155
|
method = 'GET';
|
|
156
156
|
}
|
|
157
157
|
let accept = 'application/json, multipart/mixed';
|
|
158
|
-
// @ts-expect-error Uses graphql-js so it doesn't like us
|
|
159
158
|
if (operationType === 'subscription' || isLiveQueryOperationDefinitionNode(operationAst)) {
|
|
160
159
|
method = 'GET';
|
|
161
160
|
accept = 'text/event-stream';
|
|
@@ -304,9 +303,7 @@ export class UrlLoader {
|
|
|
304
303
|
variables: variables,
|
|
305
304
|
operationName,
|
|
306
305
|
extensions,
|
|
307
|
-
},
|
|
308
|
-
// @ts-expect-error Uses graphql-js so it doesn't like us
|
|
309
|
-
observer);
|
|
306
|
+
}, observer);
|
|
310
307
|
return {
|
|
311
308
|
unsubscribe,
|
|
312
309
|
};
|
|
@@ -492,7 +489,6 @@ export class UrlLoader {
|
|
|
492
489
|
function getExecutorByRequest(request) {
|
|
493
490
|
const operationAst = getOperationASTFromRequest(request);
|
|
494
491
|
if (operationAst.operation === 'subscription' ||
|
|
495
|
-
// @ts-expect-error Uses graphql-js so it doesn't like us
|
|
496
492
|
isLiveQueryOperationDefinitionNode(operationAst, request.variables)) {
|
|
497
493
|
return subscriptionExecutor$;
|
|
498
494
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/url-loader",
|
|
3
|
-
"version": "7.13.3
|
|
3
|
+
"version": "7.13.3",
|
|
4
4
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
|
+
"peerDependencies": {
|
|
7
|
+
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
|
|
8
|
+
},
|
|
6
9
|
"dependencies": {
|
|
7
|
-
"@graphql-tools/delegate": "8.8.
|
|
8
|
-
"@graphql-tools/utils": "8.9.
|
|
9
|
-
"@graphql-tools/wrap": "8.5.
|
|
10
|
+
"@graphql-tools/delegate": "8.8.1",
|
|
11
|
+
"@graphql-tools/utils": "8.9.0",
|
|
12
|
+
"@graphql-tools/wrap": "8.5.1",
|
|
10
13
|
"@ardatan/sync-fetch": "0.0.1",
|
|
11
|
-
"@graphql-
|
|
12
|
-
"@n1ru4l/graphql-live-query": "^0.9.0",
|
|
14
|
+
"@n1ru4l/graphql-live-query": "^0.10.0",
|
|
13
15
|
"@types/ws": "^8.0.0",
|
|
14
16
|
"@whatwg-node/fetch": "^0.2.4",
|
|
15
17
|
"dset": "^3.1.2",
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ExecutionResult } from '
|
|
1
|
+
import { ExecutionResult } from 'graphql';
|
|
2
2
|
export declare function isReadableStream(value: any): value is ReadableStream;
|
|
3
3
|
export declare function handleEventStreamResponse(response: Response): Promise<AsyncIterable<ExecutionResult>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ExecutionResult } from '
|
|
2
|
-
export declare function handleReadableStream(readableStream: ReadableStream<Uint8Array>): AsyncIterableIterator<ExecutionResult<import("
|
|
1
|
+
import { ExecutionResult } from 'graphql';
|
|
2
|
+
export declare function handleReadableStream(readableStream: ReadableStream<Uint8Array>): AsyncIterableIterator<ExecutionResult<import("graphql/jsutils/ObjMap").ObjMap<unknown>, import("graphql/jsutils/ObjMap").ObjMap<unknown>>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ExecutionResult } from '
|
|
2
|
-
export declare function handleMultipartMixedResponse(response: Response): Promise<AsyncIterableIterator<ExecutionResult<import("
|
|
1
|
+
import type { ExecutionResult } from 'graphql';
|
|
2
|
+
export declare function handleMultipartMixedResponse(response: Response): Promise<AsyncIterableIterator<ExecutionResult<import("graphql/jsutils/ObjMap").ObjMap<unknown>, import("graphql/jsutils/ObjMap").ObjMap<unknown>> | undefined>>;
|
package/typings/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="ws" />
|
|
2
2
|
/// <reference lib="dom" />
|
|
3
|
-
import { IntrospectionOptions } from '
|
|
3
|
+
import { IntrospectionOptions } from 'graphql';
|
|
4
4
|
import { AsyncExecutor, Executor, SyncExecutor, Source, Loader, BaseLoaderOptions } from '@graphql-tools/utils';
|
|
5
5
|
import { ClientOptions } from 'graphql-ws';
|
|
6
6
|
import WebSocket from 'isomorphic-ws';
|