@graphql-tools/executor-graphql-ws 1.0.1 → 1.0.2-rc-20230703110329-e4ebb77f
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/index.js +8 -38
- package/esm/index.js +8 -38
- package/package.json +5 -6
package/cjs/index.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.buildGraphQLWSExecutor = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const utils_1 = require("@graphql-tools/utils");
|
|
6
|
-
const repeater_1 = require("@repeaterjs/repeater");
|
|
7
6
|
const graphql_1 = require("graphql");
|
|
8
7
|
const graphql_ws_1 = require("graphql-ws");
|
|
9
8
|
const isomorphic_ws_1 = tslib_1.__importDefault(require("isomorphic-ws"));
|
|
@@ -28,45 +27,16 @@ function buildGraphQLWSExecutor(clientOptionsOrClient) {
|
|
|
28
27
|
return function GraphQLWSExecutor(executionRequest) {
|
|
29
28
|
const { document, variables, operationName, extensions, operationType = (0, utils_1.getOperationASTFromRequest)(executionRequest).operation, } = executionRequest;
|
|
30
29
|
const query = (0, graphql_1.print)(document);
|
|
30
|
+
const iterableIterator = graphqlWSClient.iterate({
|
|
31
|
+
query,
|
|
32
|
+
variables,
|
|
33
|
+
operationName,
|
|
34
|
+
extensions,
|
|
35
|
+
});
|
|
31
36
|
if (operationType === 'subscription') {
|
|
32
|
-
return
|
|
33
|
-
const unsubscribe = graphqlWSClient.subscribe({
|
|
34
|
-
query,
|
|
35
|
-
variables,
|
|
36
|
-
operationName,
|
|
37
|
-
extensions,
|
|
38
|
-
}, {
|
|
39
|
-
next(data) {
|
|
40
|
-
return push(data);
|
|
41
|
-
},
|
|
42
|
-
error(error) {
|
|
43
|
-
return stop(error);
|
|
44
|
-
},
|
|
45
|
-
complete() {
|
|
46
|
-
return stop();
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
return stop.finally(unsubscribe);
|
|
50
|
-
});
|
|
37
|
+
return iterableIterator;
|
|
51
38
|
}
|
|
52
|
-
return
|
|
53
|
-
const unsubscribe = graphqlWSClient.subscribe({
|
|
54
|
-
query,
|
|
55
|
-
variables,
|
|
56
|
-
operationName,
|
|
57
|
-
extensions,
|
|
58
|
-
}, {
|
|
59
|
-
next(data) {
|
|
60
|
-
return resolve(data);
|
|
61
|
-
},
|
|
62
|
-
error(error) {
|
|
63
|
-
return reject(error);
|
|
64
|
-
},
|
|
65
|
-
complete() {
|
|
66
|
-
unsubscribe();
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
});
|
|
39
|
+
return iterableIterator.next().then(({ value }) => value);
|
|
70
40
|
};
|
|
71
41
|
}
|
|
72
42
|
exports.buildGraphQLWSExecutor = buildGraphQLWSExecutor;
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getOperationASTFromRequest } from '@graphql-tools/utils';
|
|
2
|
-
import { Repeater } from '@repeaterjs/repeater';
|
|
3
2
|
import { print } from 'graphql';
|
|
4
3
|
import { createClient } from 'graphql-ws';
|
|
5
4
|
import WebSocket from 'isomorphic-ws';
|
|
@@ -24,44 +23,15 @@ export function buildGraphQLWSExecutor(clientOptionsOrClient) {
|
|
|
24
23
|
return function GraphQLWSExecutor(executionRequest) {
|
|
25
24
|
const { document, variables, operationName, extensions, operationType = getOperationASTFromRequest(executionRequest).operation, } = executionRequest;
|
|
26
25
|
const query = print(document);
|
|
26
|
+
const iterableIterator = graphqlWSClient.iterate({
|
|
27
|
+
query,
|
|
28
|
+
variables,
|
|
29
|
+
operationName,
|
|
30
|
+
extensions,
|
|
31
|
+
});
|
|
27
32
|
if (operationType === 'subscription') {
|
|
28
|
-
return
|
|
29
|
-
const unsubscribe = graphqlWSClient.subscribe({
|
|
30
|
-
query,
|
|
31
|
-
variables,
|
|
32
|
-
operationName,
|
|
33
|
-
extensions,
|
|
34
|
-
}, {
|
|
35
|
-
next(data) {
|
|
36
|
-
return push(data);
|
|
37
|
-
},
|
|
38
|
-
error(error) {
|
|
39
|
-
return stop(error);
|
|
40
|
-
},
|
|
41
|
-
complete() {
|
|
42
|
-
return stop();
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
return stop.finally(unsubscribe);
|
|
46
|
-
});
|
|
33
|
+
return iterableIterator;
|
|
47
34
|
}
|
|
48
|
-
return
|
|
49
|
-
const unsubscribe = graphqlWSClient.subscribe({
|
|
50
|
-
query,
|
|
51
|
-
variables,
|
|
52
|
-
operationName,
|
|
53
|
-
extensions,
|
|
54
|
-
}, {
|
|
55
|
-
next(data) {
|
|
56
|
-
return resolve(data);
|
|
57
|
-
},
|
|
58
|
-
error(error) {
|
|
59
|
-
return reject(error);
|
|
60
|
-
},
|
|
61
|
-
complete() {
|
|
62
|
-
unsubscribe();
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
});
|
|
35
|
+
return iterableIterator.next().then(({ value }) => value);
|
|
66
36
|
};
|
|
67
37
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/executor-graphql-ws",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2-rc-20230703110329-e4ebb77f",
|
|
4
4
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
@@ -8,11 +8,10 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@types/ws": "^8.0.0",
|
|
11
|
-
"ws": "8.13.0",
|
|
12
|
-
"isomorphic-ws": "5.0.0",
|
|
13
|
-
"@graphql-tools/utils": "
|
|
14
|
-
"
|
|
15
|
-
"graphql-ws": "5.14.0",
|
|
11
|
+
"ws": "^8.13.0",
|
|
12
|
+
"isomorphic-ws": "^5.0.0",
|
|
13
|
+
"@graphql-tools/utils": "10.0.2-rc-20230703110329-e4ebb77f",
|
|
14
|
+
"graphql-ws": "^5.14.0",
|
|
16
15
|
"tslib": "^2.4.0"
|
|
17
16
|
},
|
|
18
17
|
"repository": {
|