@graphql-mesh/transport-ws 1.0.1-alpha-5287411de2d9329a466af25c7829ad43fa009403 → 1.0.1-alpha-2ca260f847dfb52877d8a5293370a07035490661
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 +4 -2
- package/dist/index.cjs +36 -47
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +36 -43
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
# @graphql-mesh/transport-ws
|
2
2
|
|
3
|
-
## 1.0.1-alpha-
|
3
|
+
## 1.0.1-alpha-2ca260f847dfb52877d8a5293370a07035490661
|
4
4
|
|
5
5
|
### Patch Changes
|
6
6
|
|
7
|
+
- [#591](https://github.com/graphql-hive/gateway/pull/591) [`2ca260f`](https://github.com/graphql-hive/gateway/commit/2ca260f847dfb52877d8a5293370a07035490661) Thanks [@ardatan](https://github.com/ardatan)! - Avoid having an extra Client instantiation in the transport, and use the one in the executor
|
8
|
+
|
7
9
|
- Updated dependencies [[`7474f33`](https://github.com/graphql-hive/gateway/commit/7474f339ff952c04c1f6023212691ad38bca04c5)]:
|
8
|
-
- @graphql-tools/executor-graphql-ws@2.0.1-alpha-
|
10
|
+
- @graphql-tools/executor-graphql-ws@2.0.1-alpha-2ca260f847dfb52877d8a5293370a07035490661
|
9
11
|
|
10
12
|
## 1.0.0
|
11
13
|
|
package/dist/index.cjs
CHANGED
@@ -4,12 +4,6 @@ var crossHelpers = require('@graphql-mesh/cross-helpers');
|
|
4
4
|
var stringInterpolation = require('@graphql-mesh/string-interpolation');
|
5
5
|
var utils = require('@graphql-mesh/utils');
|
6
6
|
var executorGraphqlWs = require('@graphql-tools/executor-graphql-ws');
|
7
|
-
var graphqlWs = require('graphql-ws');
|
8
|
-
var WebSocket = require('isomorphic-ws');
|
9
|
-
|
10
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
11
|
-
|
12
|
-
var WebSocket__default = /*#__PURE__*/_interopDefault(WebSocket);
|
13
7
|
|
14
8
|
function switchProtocols(url) {
|
15
9
|
if (url.startsWith("https://")) {
|
@@ -21,7 +15,7 @@ function switchProtocols(url) {
|
|
21
15
|
return url;
|
22
16
|
}
|
23
17
|
var index = {
|
24
|
-
getSubgraphExecutor({ transportEntry, logger },
|
18
|
+
getSubgraphExecutor({ transportEntry, logger }, onClient) {
|
25
19
|
const wsExecutorMap = /* @__PURE__ */ new Map();
|
26
20
|
if (!transportEntry.location) {
|
27
21
|
throw new Error(
|
@@ -50,47 +44,42 @@ var index = {
|
|
50
44
|
let wsExecutor = wsExecutorMap.get(hash);
|
51
45
|
if (!wsExecutor) {
|
52
46
|
const executorLogger = logger?.child("GraphQL WS").child(hash);
|
53
|
-
wsExecutor =
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
}
|
69
|
-
|
70
|
-
|
71
|
-
}
|
72
|
-
|
73
|
-
|
74
|
-
}
|
75
|
-
|
76
|
-
|
77
|
-
}
|
78
|
-
|
79
|
-
|
80
|
-
}
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
executorLogger?.debug("closed", { event });
|
86
|
-
wsExecutorMap.delete(hash);
|
87
|
-
},
|
88
|
-
error(error) {
|
89
|
-
executorLogger?.debug("error", { error });
|
90
|
-
}
|
47
|
+
wsExecutor = executorGraphqlWs.buildGraphQLWSExecutor({
|
48
|
+
headers,
|
49
|
+
url: wsUrl,
|
50
|
+
lazy: true,
|
51
|
+
lazyCloseTimeout: 3e3,
|
52
|
+
...transportEntry.options,
|
53
|
+
connectionParams,
|
54
|
+
on: {
|
55
|
+
connecting(isRetry) {
|
56
|
+
executorLogger?.debug("connecting", { isRetry });
|
57
|
+
},
|
58
|
+
opened(socket) {
|
59
|
+
executorLogger?.debug("opened", { socket });
|
60
|
+
},
|
61
|
+
connected(socket, payload) {
|
62
|
+
executorLogger?.debug("connected", { socket, payload });
|
63
|
+
},
|
64
|
+
ping(received, payload) {
|
65
|
+
executorLogger?.debug("ping", { received, payload });
|
66
|
+
},
|
67
|
+
pong(received, payload) {
|
68
|
+
executorLogger?.debug("pong", { received, payload });
|
69
|
+
},
|
70
|
+
message(message) {
|
71
|
+
executorLogger?.debug("message", { message });
|
72
|
+
},
|
73
|
+
closed(event) {
|
74
|
+
executorLogger?.debug("closed", { event });
|
75
|
+
wsExecutorMap.delete(hash);
|
76
|
+
},
|
77
|
+
error(error) {
|
78
|
+
executorLogger?.debug("error", { error });
|
91
79
|
}
|
92
|
-
}
|
93
|
-
|
80
|
+
},
|
81
|
+
onClient
|
82
|
+
});
|
94
83
|
wsExecutorMap.set(hash, wsExecutor);
|
95
84
|
}
|
96
85
|
return wsExecutor(execReq);
|
package/dist/index.d.cts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import * as _graphql_mesh_transport_common from '@graphql-mesh/transport-common';
|
2
2
|
import { DisposableExecutor } from '@graphql-mesh/transport-common';
|
3
|
-
import { DisposableAsyncExecutor } from '@graphql-tools/utils';
|
4
3
|
import { Client } from 'graphql-ws';
|
5
4
|
|
6
5
|
interface WSTransportOptions {
|
@@ -12,7 +11,7 @@ interface WSTransportOptions {
|
|
12
11
|
connectionParams?: Record<string, string>;
|
13
12
|
}
|
14
13
|
declare const _default: {
|
15
|
-
getSubgraphExecutor({ transportEntry, logger }: _graphql_mesh_transport_common.TransportGetSubgraphExecutorOptions<WSTransportOptions>,
|
14
|
+
getSubgraphExecutor({ transportEntry, logger }: _graphql_mesh_transport_common.TransportGetSubgraphExecutorOptions<WSTransportOptions>, onClient?: (client: Client) => void): DisposableExecutor & AsyncDisposable;
|
16
15
|
};
|
17
16
|
|
18
17
|
export { type WSTransportOptions, _default as default };
|
package/dist/index.d.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import * as _graphql_mesh_transport_common from '@graphql-mesh/transport-common';
|
2
2
|
import { DisposableExecutor } from '@graphql-mesh/transport-common';
|
3
|
-
import { DisposableAsyncExecutor } from '@graphql-tools/utils';
|
4
3
|
import { Client } from 'graphql-ws';
|
5
4
|
|
6
5
|
interface WSTransportOptions {
|
@@ -12,7 +11,7 @@ interface WSTransportOptions {
|
|
12
11
|
connectionParams?: Record<string, string>;
|
13
12
|
}
|
14
13
|
declare const _default: {
|
15
|
-
getSubgraphExecutor({ transportEntry, logger }: _graphql_mesh_transport_common.TransportGetSubgraphExecutorOptions<WSTransportOptions>,
|
14
|
+
getSubgraphExecutor({ transportEntry, logger }: _graphql_mesh_transport_common.TransportGetSubgraphExecutorOptions<WSTransportOptions>, onClient?: (client: Client) => void): DisposableExecutor & AsyncDisposable;
|
16
15
|
};
|
17
16
|
|
18
17
|
export { type WSTransportOptions, _default as default };
|
package/dist/index.js
CHANGED
@@ -2,8 +2,6 @@ import { process } from '@graphql-mesh/cross-helpers';
|
|
2
2
|
import { getInterpolatedHeadersFactory } from '@graphql-mesh/string-interpolation';
|
3
3
|
import { makeAsyncDisposable, isDisposable, dispose } from '@graphql-mesh/utils';
|
4
4
|
import { buildGraphQLWSExecutor } from '@graphql-tools/executor-graphql-ws';
|
5
|
-
import { createClient } from 'graphql-ws';
|
6
|
-
import WebSocket from 'isomorphic-ws';
|
7
5
|
|
8
6
|
function switchProtocols(url) {
|
9
7
|
if (url.startsWith("https://")) {
|
@@ -15,7 +13,7 @@ function switchProtocols(url) {
|
|
15
13
|
return url;
|
16
14
|
}
|
17
15
|
var index = {
|
18
|
-
getSubgraphExecutor({ transportEntry, logger },
|
16
|
+
getSubgraphExecutor({ transportEntry, logger }, onClient) {
|
19
17
|
const wsExecutorMap = /* @__PURE__ */ new Map();
|
20
18
|
if (!transportEntry.location) {
|
21
19
|
throw new Error(
|
@@ -44,47 +42,42 @@ var index = {
|
|
44
42
|
let wsExecutor = wsExecutorMap.get(hash);
|
45
43
|
if (!wsExecutor) {
|
46
44
|
const executorLogger = logger?.child("GraphQL WS").child(hash);
|
47
|
-
wsExecutor =
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
}
|
63
|
-
|
64
|
-
|
65
|
-
}
|
66
|
-
|
67
|
-
|
68
|
-
}
|
69
|
-
|
70
|
-
|
71
|
-
}
|
72
|
-
|
73
|
-
|
74
|
-
}
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
executorLogger?.debug("closed", { event });
|
80
|
-
wsExecutorMap.delete(hash);
|
81
|
-
},
|
82
|
-
error(error) {
|
83
|
-
executorLogger?.debug("error", { error });
|
84
|
-
}
|
45
|
+
wsExecutor = buildGraphQLWSExecutor({
|
46
|
+
headers,
|
47
|
+
url: wsUrl,
|
48
|
+
lazy: true,
|
49
|
+
lazyCloseTimeout: 3e3,
|
50
|
+
...transportEntry.options,
|
51
|
+
connectionParams,
|
52
|
+
on: {
|
53
|
+
connecting(isRetry) {
|
54
|
+
executorLogger?.debug("connecting", { isRetry });
|
55
|
+
},
|
56
|
+
opened(socket) {
|
57
|
+
executorLogger?.debug("opened", { socket });
|
58
|
+
},
|
59
|
+
connected(socket, payload) {
|
60
|
+
executorLogger?.debug("connected", { socket, payload });
|
61
|
+
},
|
62
|
+
ping(received, payload) {
|
63
|
+
executorLogger?.debug("ping", { received, payload });
|
64
|
+
},
|
65
|
+
pong(received, payload) {
|
66
|
+
executorLogger?.debug("pong", { received, payload });
|
67
|
+
},
|
68
|
+
message(message) {
|
69
|
+
executorLogger?.debug("message", { message });
|
70
|
+
},
|
71
|
+
closed(event) {
|
72
|
+
executorLogger?.debug("closed", { event });
|
73
|
+
wsExecutorMap.delete(hash);
|
74
|
+
},
|
75
|
+
error(error) {
|
76
|
+
executorLogger?.debug("error", { error });
|
85
77
|
}
|
86
|
-
}
|
87
|
-
|
78
|
+
},
|
79
|
+
onClient
|
80
|
+
});
|
88
81
|
wsExecutorMap.set(hash, wsExecutor);
|
89
82
|
}
|
90
83
|
return wsExecutor(execReq);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@graphql-mesh/transport-ws",
|
3
|
-
"version": "1.0.1-alpha-
|
3
|
+
"version": "1.0.1-alpha-2ca260f847dfb52877d8a5293370a07035490661",
|
4
4
|
"type": "module",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -47,7 +47,7 @@
|
|
47
47
|
"@graphql-mesh/transport-common": "^0.7.27",
|
48
48
|
"@graphql-mesh/types": "^0.103.6",
|
49
49
|
"@graphql-mesh/utils": "^0.103.6",
|
50
|
-
"@graphql-tools/executor-graphql-ws": "2.0.1-alpha-
|
50
|
+
"@graphql-tools/executor-graphql-ws": "2.0.1-alpha-2ca260f847dfb52877d8a5293370a07035490661",
|
51
51
|
"@graphql-tools/utils": "^10.7.0",
|
52
52
|
"graphql-ws": "^6.0.3",
|
53
53
|
"isomorphic-ws": "^5.0.0",
|