@graphql-tools/executor-graphql-ws 1.3.6 → 1.3.7-alpha-3df7faeea69a8bf7e4423f5661c1cb8974232f19

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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # @graphql-tools/executor-graphql-ws
2
2
 
3
+ ## 1.3.7-alpha-3df7faeea69a8bf7e4423f5661c1cb8974232f19
4
+
5
+ ### Patch Changes
6
+
7
+ - [#381](https://github.com/graphql-hive/gateway/pull/381) [`e31d79c`](https://github.com/graphql-hive/gateway/commit/e31d79c704014d5180074bdb3ce11dcd1675eb58) Thanks [@ardatan](https://github.com/ardatan)! - dependencies updates:
8
+
9
+ - Added dependency [`@graphql-tools/executor-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-tools/executor-common/v/workspace:^) (to `dependencies`)
10
+
11
+ - [#381](https://github.com/graphql-hive/gateway/pull/381) [`73dbe3a`](https://github.com/graphql-hive/gateway/commit/73dbe3a2dabb6b84105c4dac3586696daa3d4fcb) Thanks [@ardatan](https://github.com/ardatan)! - Like HMAC Upstream Signature plugin, different components of the gateway were using different ways of serializing the execution request.
12
+ Some of them were ignoring `variables` if it is empty, some of not, this was causing the signature generation to be different for the same query.
13
+ For example, it was working as expected in Proxy mode, but not working as expected in Federation Gateway mode.
14
+
15
+ With this change, now we have a shared helper to serialize the upstream execution request with a memoized `print` function for query AST etc to have a consistent serialization so consistent signature generation for HMAC.
16
+
17
+ - Updated dependencies [[`73dbe3a`](https://github.com/graphql-hive/gateway/commit/73dbe3a2dabb6b84105c4dac3586696daa3d4fcb)]:
18
+ - @graphql-tools/executor-common@0.0.1-alpha-3df7faeea69a8bf7e4423f5661c1cb8974232f19
19
+
3
20
  ## 1.3.6
4
21
 
5
22
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
+ var executorCommon = require('@graphql-tools/executor-common');
3
4
  var utils = require('@graphql-tools/utils');
4
5
  var disposablestack = require('@whatwg-node/disposablestack');
5
- var graphql = require('graphql');
6
6
  var graphqlWs = require('graphql-ws');
7
7
  var WebSocket = require('isomorphic-ws');
8
8
 
@@ -10,14 +10,13 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
10
 
11
11
  var WebSocket__default = /*#__PURE__*/_interopDefault(WebSocket);
12
12
 
13
- const defaultPrintFn = utils.memoize1(graphql.print);
14
13
  function isClient(client) {
15
14
  return "subscribe" in client;
16
15
  }
17
16
  function buildGraphQLWSExecutor(clientOptionsOrClient) {
18
17
  let graphqlWSClient;
19
18
  let executorConnectionParams = {};
20
- let printFn = defaultPrintFn;
19
+ let printFn = executorCommon.defaultPrintFn;
21
20
  if (isClient(clientOptionsOrClient)) {
22
21
  graphqlWSClient = clientOptionsOrClient;
23
22
  } else {
@@ -46,9 +45,6 @@ function buildGraphQLWSExecutor(clientOptionsOrClient) {
46
45
  }
47
46
  const executor = function GraphQLWSExecutor(executionRequest) {
48
47
  const {
49
- document,
50
- variables,
51
- operationName,
52
48
  extensions,
53
49
  operationType = utils.getOperationASTFromRequest(executionRequest).operation,
54
50
  info,
@@ -60,13 +56,9 @@ function buildGraphQLWSExecutor(clientOptionsOrClient) {
60
56
  extensions["connectionParams"]
61
57
  );
62
58
  }
63
- const query = printFn(document);
64
- const iterableIterator = graphqlWSClient.iterate({
65
- query,
66
- variables,
67
- operationName,
68
- extensions
69
- });
59
+ const iterableIterator = graphqlWSClient.iterate(
60
+ executorCommon.serializeExecutionRequest({ executionRequest, printFn })
61
+ );
70
62
  if (iterableIterator.return && signal) {
71
63
  utils.registerAbortSignalListener(signal, () => {
72
64
  iterableIterator.return?.();
package/dist/index.js CHANGED
@@ -1,10 +1,9 @@
1
- import { memoize1, getOperationASTFromRequest, registerAbortSignalListener } from '@graphql-tools/utils';
1
+ import { serializeExecutionRequest, defaultPrintFn } from '@graphql-tools/executor-common';
2
+ import { getOperationASTFromRequest, registerAbortSignalListener } from '@graphql-tools/utils';
2
3
  import { DisposableSymbols } from '@whatwg-node/disposablestack';
3
- import { print } from 'graphql';
4
4
  import { createClient } from 'graphql-ws';
5
5
  import WebSocket from 'isomorphic-ws';
6
6
 
7
- const defaultPrintFn = memoize1(print);
8
7
  function isClient(client) {
9
8
  return "subscribe" in client;
10
9
  }
@@ -40,9 +39,6 @@ function buildGraphQLWSExecutor(clientOptionsOrClient) {
40
39
  }
41
40
  const executor = function GraphQLWSExecutor(executionRequest) {
42
41
  const {
43
- document,
44
- variables,
45
- operationName,
46
42
  extensions,
47
43
  operationType = getOperationASTFromRequest(executionRequest).operation,
48
44
  info,
@@ -54,13 +50,9 @@ function buildGraphQLWSExecutor(clientOptionsOrClient) {
54
50
  extensions["connectionParams"]
55
51
  );
56
52
  }
57
- const query = printFn(document);
58
- const iterableIterator = graphqlWSClient.iterate({
59
- query,
60
- variables,
61
- operationName,
62
- extensions
63
- });
53
+ const iterableIterator = graphqlWSClient.iterate(
54
+ serializeExecutionRequest({ executionRequest, printFn })
55
+ );
64
56
  if (iterableIterator.return && signal) {
65
57
  registerAbortSignalListener(signal, () => {
66
58
  iterableIterator.return?.();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/executor-graphql-ws",
3
- "version": "1.3.6",
3
+ "version": "1.3.7-alpha-3df7faeea69a8bf7e4423f5661c1cb8974232f19",
4
4
  "type": "module",
5
5
  "description": "A set of utils for faster development of GraphQL tools",
6
6
  "repository": {
@@ -39,6 +39,7 @@
39
39
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
40
40
  },
41
41
  "dependencies": {
42
+ "@graphql-tools/executor-common": "0.0.1-alpha-3df7faeea69a8bf7e4423f5661c1cb8974232f19",
42
43
  "@graphql-tools/utils": "^10.7.0",
43
44
  "@whatwg-node/disposablestack": "^0.0.5",
44
45
  "graphql-ws": "^5.14.0",