@graphql-mesh/transport-ws 0.3.7-alpha-20240925091941-d3b99a7b8a70851b6f1a190173f3996abf5168fc → 0.4.0-alpha-20240925213800-a670cc64ae334029cf574c9b8068a6dfbde4e4a3

Sign up to get free protection for your applications and to get access to all the features.
package/cjs/index.js CHANGED
@@ -21,6 +21,9 @@ exports.default = {
21
21
  const connectionParamsFactory = transportEntry.options.connectionParams
22
22
  ? (0, string_interpolation_1.getInterpolatedHeadersFactory)(transportEntry.options.connectionParams)
23
23
  : undefined;
24
+ const headersFactory = transportEntry.headers
25
+ ? (0, string_interpolation_1.getInterpolatedHeadersFactory)(Object.fromEntries(transportEntry.headers))
26
+ : undefined;
24
27
  const mergedExecutor = function mergedExecutor(execReq) {
25
28
  const connectionParams = connectionParamsFactory?.({
26
29
  env: cross_helpers_1.process.env,
@@ -28,7 +31,16 @@ exports.default = {
28
31
  context: execReq.context,
29
32
  info: execReq.info,
30
33
  });
31
- const hash = wsUrl + (connectionParams?.token ? '?token=' + connectionParams.token : '');
34
+ const headers = headersFactory?.({
35
+ env: cross_helpers_1.process.env,
36
+ root: execReq.rootValue,
37
+ context: execReq.context,
38
+ info: execReq.info,
39
+ });
40
+ let hash = wsUrl + (connectionParams?.token ? '?token=' + connectionParams.token : '');
41
+ if (headers) {
42
+ hash += `&headers=${JSON.stringify(headers)}`;
43
+ }
32
44
  let wsExecutor = wsExecutorMap.get(hash);
33
45
  if (!wsExecutor) {
34
46
  const executorLogger = logger.child('GraphQL WS').child(hash);
@@ -37,6 +49,7 @@ exports.default = {
37
49
  lazy: true,
38
50
  lazyCloseTimeout: 3_000,
39
51
  ...transportEntry.options,
52
+ headers,
40
53
  connectionParams,
41
54
  on: {
42
55
  connecting(isRetry) {
package/esm/index.js CHANGED
@@ -19,6 +19,9 @@ export default {
19
19
  const connectionParamsFactory = transportEntry.options.connectionParams
20
20
  ? getInterpolatedHeadersFactory(transportEntry.options.connectionParams)
21
21
  : undefined;
22
+ const headersFactory = transportEntry.headers
23
+ ? getInterpolatedHeadersFactory(Object.fromEntries(transportEntry.headers))
24
+ : undefined;
22
25
  const mergedExecutor = function mergedExecutor(execReq) {
23
26
  const connectionParams = connectionParamsFactory?.({
24
27
  env: process.env,
@@ -26,7 +29,16 @@ export default {
26
29
  context: execReq.context,
27
30
  info: execReq.info,
28
31
  });
29
- const hash = wsUrl + (connectionParams?.token ? '?token=' + connectionParams.token : '');
32
+ const headers = headersFactory?.({
33
+ env: process.env,
34
+ root: execReq.rootValue,
35
+ context: execReq.context,
36
+ info: execReq.info,
37
+ });
38
+ let hash = wsUrl + (connectionParams?.token ? '?token=' + connectionParams.token : '');
39
+ if (headers) {
40
+ hash += `&headers=${JSON.stringify(headers)}`;
41
+ }
30
42
  let wsExecutor = wsExecutorMap.get(hash);
31
43
  if (!wsExecutor) {
32
44
  const executorLogger = logger.child('GraphQL WS').child(hash);
@@ -35,6 +47,7 @@ export default {
35
47
  lazy: true,
36
48
  lazyCloseTimeout: 3_000,
37
49
  ...transportEntry.options,
50
+ headers,
38
51
  connectionParams,
39
52
  on: {
40
53
  connecting(isRetry) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-mesh/transport-ws",
3
- "version": "0.3.7-alpha-20240925091941-d3b99a7b8a70851b6f1a190173f3996abf5168fc",
3
+ "version": "0.4.0-alpha-20240925213800-a670cc64ae334029cf574c9b8068a6dfbde4e4a3",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "*",
@@ -11,7 +11,7 @@
11
11
  "@graphql-mesh/string-interpolation": "^0.5.6",
12
12
  "@graphql-mesh/transport-common": "^0.7.6",
13
13
  "@graphql-mesh/utils": "^0.102.5",
14
- "@graphql-tools/executor-graphql-ws": "1.2.1-alpha-20240925090257-6e5f8eaabf9d4300983f198ca6214ba632f151c0",
14
+ "@graphql-tools/executor-graphql-ws": "1.3.0-alpha-20240925200710-d61ee3efd7a824d2ae97ac731770da8ae3a913d0",
15
15
  "@graphql-tools/utils": "^10.5.3",
16
16
  "graphql-ws": "^5.16.0",
17
17
  "ws": "^8.18.0"