@graphql-tools/executor-common 2.0.0 → 2.0.1-alpha-20261125132121-e13508215f675f75a5a460d3469b856471abf677

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 ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultPrintFn = void 0;
4
+ exports.serializeExecutionRequest = serializeExecutionRequest;
5
+ const graphql_1 = require("graphql");
6
+ const core_1 = require("@envelop/core");
7
+ function stripAndPrint(document) {
8
+ return (0, graphql_1.stripIgnoredCharacters)((0, graphql_1.print)(document));
9
+ }
10
+ const defaultPrintFn = function defaultPrintFn(document) {
11
+ return (0, core_1.getDocumentString)(document, stripAndPrint);
12
+ };
13
+ exports.defaultPrintFn = defaultPrintFn;
14
+ function serializeExecutionRequest({ executionRequest, excludeQuery, printFn = exports.defaultPrintFn, }) {
15
+ return {
16
+ query: excludeQuery ? undefined : printFn(executionRequest.document),
17
+ variables: (executionRequest.variables && Object.keys(executionRequest.variables).length) > 0
18
+ ? executionRequest.variables
19
+ : undefined,
20
+ operationName: executionRequest.operationName ? executionRequest.operationName : undefined,
21
+ extensions: executionRequest.extensions && Object.keys(executionRequest.extensions).length > 0
22
+ ? executionRequest.extensions
23
+ : undefined,
24
+ };
25
+ }
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
package/esm/index.js ADDED
@@ -0,0 +1,20 @@
1
+ import { print, stripIgnoredCharacters } from 'graphql';
2
+ import { getDocumentString } from '@envelop/core';
3
+ function stripAndPrint(document) {
4
+ return stripIgnoredCharacters(print(document));
5
+ }
6
+ export const defaultPrintFn = function defaultPrintFn(document) {
7
+ return getDocumentString(document, stripAndPrint);
8
+ };
9
+ export function serializeExecutionRequest({ executionRequest, excludeQuery, printFn = defaultPrintFn, }) {
10
+ return {
11
+ query: excludeQuery ? undefined : printFn(executionRequest.document),
12
+ variables: (executionRequest.variables && Object.keys(executionRequest.variables).length) > 0
13
+ ? executionRequest.variables
14
+ : undefined,
15
+ operationName: executionRequest.operationName ? executionRequest.operationName : undefined,
16
+ extensions: executionRequest.extensions && Object.keys(executionRequest.extensions).length > 0
17
+ ? executionRequest.extensions
18
+ : undefined,
19
+ };
20
+ }
package/package.json CHANGED
@@ -1,50 +1,61 @@
1
1
  {
2
2
  "name": "@graphql-tools/executor-common",
3
- "version": "2.0.0",
4
- "type": "module",
5
- "description": "A set of utils for faster development of GraphQL tools",
3
+ "version": "2.0.1-alpha-20261125132121-e13508215f675f75a5a460d3469b856471abf677",
4
+ "description": "Shared utilities for GraphQL executors",
5
+ "sideEffects": false,
6
+ "peerDependencies": {
7
+ "graphql": "^16.0.0 || ^17.0.0"
8
+ },
9
+ "dependencies": {
10
+ "@envelop/core": "^6.0.1",
11
+ "@graphql-tools/utils": "^13.2.2"
12
+ },
6
13
  "repository": {
7
14
  "type": "git",
8
- "url": "git+https://github.com/graphql-hive/gateway.git",
9
- "directory": "packages/executors/graphql-ws"
15
+ "url": "ardatan/graphql-mesh",
16
+ "directory": "packages/executors/common"
10
17
  },
11
18
  "author": "Arda TANRIKULU <ardatanrikulu@gmail.com>",
12
19
  "license": "MIT",
13
20
  "engines": {
14
- "node": ">=22.15.0"
21
+ "node": ">=22.18.0"
22
+ },
23
+ "main": "cjs/index.js",
24
+ "module": "esm/index.js",
25
+ "typings": "typings/index.d.ts",
26
+ "typescript": {
27
+ "definition": "typings/index.d.ts"
15
28
  },
16
- "main": "./dist/index.js",
17
- "types": "./dist/index.d.ts",
29
+ "type": "module",
18
30
  "exports": {
19
31
  ".": {
20
32
  "require": {
21
- "types": "./dist/index.d.cts",
22
- "default": "./dist/index.cjs"
33
+ "types": "./typings/index.d.cts",
34
+ "default": "./cjs/index.js"
23
35
  },
24
36
  "import": {
25
- "types": "./dist/index.d.ts",
26
- "default": "./dist/index.js"
37
+ "types": "./typings/index.d.ts",
38
+ "default": "./esm/index.js"
39
+ },
40
+ "default": {
41
+ "types": "./typings/index.d.ts",
42
+ "default": "./esm/index.js"
43
+ }
44
+ },
45
+ "./*": {
46
+ "require": {
47
+ "types": "./typings/*.d.cts",
48
+ "default": "./cjs/*.js"
49
+ },
50
+ "import": {
51
+ "types": "./typings/*.d.ts",
52
+ "default": "./esm/*.js"
53
+ },
54
+ "default": {
55
+ "types": "./typings/*.d.ts",
56
+ "default": "./esm/*.js"
27
57
  }
28
58
  },
29
59
  "./package.json": "./package.json"
30
- },
31
- "files": [
32
- "dist"
33
- ],
34
- "scripts": {
35
- "build": "pkgroll --clean-dist",
36
- "prepack": "yarn build"
37
- },
38
- "peerDependencies": {
39
- "graphql": "^16.0.0 || ^17.0.0"
40
- },
41
- "dependencies": {
42
- "@envelop/core": "^6.0.1",
43
- "@graphql-tools/utils": "^13.2.2"
44
- },
45
- "devDependencies": {
46
- "graphql": "^17.1.0",
47
- "pkgroll": "2.29.1"
48
- },
49
- "sideEffects": false
60
+ }
50
61
  }
@@ -1,28 +1,27 @@
1
- import { ExecutionRequest } from '@graphql-tools/utils';
2
- import { DocumentNode } from 'graphql';
3
-
4
- declare const defaultPrintFn: (document: DocumentNode) => string;
1
+ import { type DocumentNode } from 'graphql';
2
+ import type { ExecutionRequest } from '@graphql-tools/utils';
3
+ export declare const defaultPrintFn: (document: DocumentNode) => string;
5
4
  interface ExecutionRequestToGraphQLParams {
6
5
  executionRequest: ExecutionRequest;
7
6
  excludeQuery?: boolean;
8
7
  printFn?: typeof defaultPrintFn;
9
8
  }
10
- interface SerializedExecutionRequest {
9
+ export interface SerializedExecutionRequest {
11
10
  query?: string | undefined;
12
11
  variables?: Record<string, any>;
13
12
  operationName?: string;
14
13
  extensions?: Record<string, any>;
15
14
  }
16
- declare function serializeExecutionRequest(opts: Omit<ExecutionRequestToGraphQLParams, 'excludeQuery'> & {
15
+ export declare function serializeExecutionRequest(opts: Omit<ExecutionRequestToGraphQLParams, 'excludeQuery'> & {
17
16
  excludeQuery: true;
18
17
  }): Omit<SerializedExecutionRequest, 'query'>;
19
- declare function serializeExecutionRequest(opts: Omit<ExecutionRequestToGraphQLParams, 'excludeQuery'> & {
18
+ export declare function serializeExecutionRequest(opts: Omit<ExecutionRequestToGraphQLParams, 'excludeQuery'> & {
20
19
  excludeQuery?: false;
21
20
  }): Omit<SerializedExecutionRequest, 'query'> & {
22
21
  query: string;
23
22
  };
24
- declare function serializeExecutionRequest(opts: ExecutionRequestToGraphQLParams): SerializedExecutionRequest;
25
- interface UpstreamErrorExtensions {
23
+ export declare function serializeExecutionRequest(opts: ExecutionRequestToGraphQLParams): SerializedExecutionRequest;
24
+ export interface UpstreamErrorExtensions {
26
25
  [attributeName: string]: unknown;
27
26
  code?: string;
28
27
  serviceName?: string;
@@ -38,5 +37,4 @@ interface UpstreamErrorExtensions {
38
37
  body?: unknown;
39
38
  };
40
39
  }
41
-
42
- export { type SerializedExecutionRequest, type UpstreamErrorExtensions, defaultPrintFn, serializeExecutionRequest };
40
+ export {};
@@ -1,28 +1,27 @@
1
- import { ExecutionRequest } from '@graphql-tools/utils';
2
- import { DocumentNode } from 'graphql';
3
-
4
- declare const defaultPrintFn: (document: DocumentNode) => string;
1
+ import { type DocumentNode } from 'graphql';
2
+ import type { ExecutionRequest } from '@graphql-tools/utils';
3
+ export declare const defaultPrintFn: (document: DocumentNode) => string;
5
4
  interface ExecutionRequestToGraphQLParams {
6
5
  executionRequest: ExecutionRequest;
7
6
  excludeQuery?: boolean;
8
7
  printFn?: typeof defaultPrintFn;
9
8
  }
10
- interface SerializedExecutionRequest {
9
+ export interface SerializedExecutionRequest {
11
10
  query?: string | undefined;
12
11
  variables?: Record<string, any>;
13
12
  operationName?: string;
14
13
  extensions?: Record<string, any>;
15
14
  }
16
- declare function serializeExecutionRequest(opts: Omit<ExecutionRequestToGraphQLParams, 'excludeQuery'> & {
15
+ export declare function serializeExecutionRequest(opts: Omit<ExecutionRequestToGraphQLParams, 'excludeQuery'> & {
17
16
  excludeQuery: true;
18
17
  }): Omit<SerializedExecutionRequest, 'query'>;
19
- declare function serializeExecutionRequest(opts: Omit<ExecutionRequestToGraphQLParams, 'excludeQuery'> & {
18
+ export declare function serializeExecutionRequest(opts: Omit<ExecutionRequestToGraphQLParams, 'excludeQuery'> & {
20
19
  excludeQuery?: false;
21
20
  }): Omit<SerializedExecutionRequest, 'query'> & {
22
21
  query: string;
23
22
  };
24
- declare function serializeExecutionRequest(opts: ExecutionRequestToGraphQLParams): SerializedExecutionRequest;
25
- interface UpstreamErrorExtensions {
23
+ export declare function serializeExecutionRequest(opts: ExecutionRequestToGraphQLParams): SerializedExecutionRequest;
24
+ export interface UpstreamErrorExtensions {
26
25
  [attributeName: string]: unknown;
27
26
  code?: string;
28
27
  serviceName?: string;
@@ -38,5 +37,4 @@ interface UpstreamErrorExtensions {
38
37
  body?: unknown;
39
38
  };
40
39
  }
41
-
42
- export { type SerializedExecutionRequest, type UpstreamErrorExtensions, defaultPrintFn, serializeExecutionRequest };
40
+ export {};
package/CHANGELOG.md DELETED
@@ -1,203 +0,0 @@
1
- # @graphql-tools/executor-common
2
-
3
- ## 2.0.0
4
- ### Major Changes
5
-
6
-
7
-
8
- - [#2670](https://github.com/graphql-hive/gateway/pull/2670) [`1204709`](https://github.com/graphql-hive/gateway/commit/12047092208631559c48d147d861815d63d953c2) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Drop GraphQL v15 (and older) support. Only GraphQL v16 and v17 are supported now.
9
-
10
- Upgrade to `graphql@^16` or `graphql@^17`. Hive Gateway packages require `graphql@^16.9.0` or later.
11
-
12
- `@graphql-tools/stitch` no longer reads legacy `#` comment descriptions (`commentDescriptions`, removed in GraphQL v16) from type definitions; use string descriptions (`"""..."""`) instead.
13
-
14
-
15
- - [#2670](https://github.com/graphql-hive/gateway/pull/2670) [`1204709`](https://github.com/graphql-hive/gateway/commit/12047092208631559c48d147d861815d63d953c2) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Drop Node.js 20 support. The minimum supported Node.js version is now 22.15.0.
16
-
17
- Upgrade to Node.js 22.15.0 or later.
18
-
19
-
20
- - [#2670](https://github.com/graphql-hive/gateway/pull/2670) [`1204709`](https://github.com/graphql-hive/gateway/commit/12047092208631559c48d147d861815d63d953c2) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Align with GraphQL Yoga 6 / GraphQL Tools majors / whatwg-node: stop using removed helpers.
21
-
22
- | Removed | Replacement |
23
- | --- | --- |
24
- | `createGraphQLError` | `new GraphQLError(...)` |
25
- | `YogaLogger` / `createLogger` / `yoga.logger` | `Logger` / `yoga.log` |
26
- | `crypto` from `@whatwg-node/fetch` | platform `crypto` (Node >=22.15); Gateway still exposes it on `fetchAPI` for Yoga 5 peers |
27
- | `mapMaybePromise` and related utils re-exports | `@whatwg-node/promise-helpers` (`handleMaybePromise`, …) |
28
- | `createDeferred` / `createDeferredPromise` | `Promise.withResolvers()` |
29
-
30
- See [graphql-tools#8515](https://github.com/ardatan/graphql-tools/pull/8515) and [yoga#4623](https://github.com/graphql-hive/graphql-yoga/pull/4623).
31
-
32
- ## 1.1.1
33
- ### Patch Changes
34
-
35
-
36
-
37
- - [`e288224`](https://github.com/graphql-hive/gateway/commit/e28822460e2189e3b1e112bf2ad9072d68c01f90) Thanks [@enisdenjo](https://github.com/enisdenjo)! - dependencies updates:
38
-
39
- - Updated dependency [`@graphql-tools/utils@^12.1.0` ↗︎](https://www.npmjs.com/package/@graphql-tools/utils/v/12.1.0) (from `^12.0.1`, in `dependencies`)
40
-
41
- ## 1.1.0
42
- ### Minor Changes
43
-
44
-
45
-
46
- - [#2604](https://github.com/graphql-hive/gateway/pull/2604) [`ee4cc07`](https://github.com/graphql-hive/gateway/commit/ee4cc07097926293a8628c075a264e272cad8830) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Support GraphQL 16 with @graphql-tools/utils v12
47
-
48
- Preserves GraphQL 16 compatibility while upgrading to `@graphql-tools/utils` v12, `@graphql-tools/executor` v2, and the compatible `@graphql-tools/schema` and `@graphql-tools/merge` releases. Consumers now receive consistent resolver and execution request types without conflicts between different GraphQL Tools versions.
49
-
50
- Stitched and delegated operations handle the new executor variable result shape correctly, including variables used by directives. Resolver execution also supports the executor's cancellation and asynchronous work helpers while remaining compatible with the GraphQL 16 `GraphQLResolveInfo` API.
51
-
52
- ### Patch Changes
53
-
54
-
55
-
56
- - [#2604](https://github.com/graphql-hive/gateway/pull/2604) [`ee4cc07`](https://github.com/graphql-hive/gateway/commit/ee4cc07097926293a8628c075a264e272cad8830) Thanks [@enisdenjo](https://github.com/enisdenjo)! - dependencies updates:
57
-
58
- - Updated dependency [`@graphql-tools/utils@^12.0.1` ↗︎](https://www.npmjs.com/package/@graphql-tools/utils/v/12.0.1) (from `^11.0.0`, in `dependencies`)
59
-
60
- ## 1.0.6
61
- ### Patch Changes
62
-
63
-
64
-
65
- - [#1842](https://github.com/graphql-hive/gateway/pull/1842) [`93aa767`](https://github.com/graphql-hive/gateway/commit/93aa76755afc93085280646fb7cb14e6d02b4a7f) Thanks [@dependabot](https://github.com/apps/dependabot)! - dependencies updates:
66
-
67
- - Updated dependency [`@graphql-tools/utils@^11.0.0` ↗︎](https://www.npmjs.com/package/@graphql-tools/utils/v/11.0.0) (from `^10.10.3`, in `dependencies`)
68
-
69
- ## 1.0.5
70
- ### Patch Changes
71
-
72
-
73
-
74
- - [#1691](https://github.com/graphql-hive/gateway/pull/1691) [`7ecaf7e`](https://github.com/graphql-hive/gateway/commit/7ecaf7e8f658c4e4c1a91d1e8db3c1a8ceca51cb) Thanks [@dependabot](https://github.com/apps/dependabot)! - dependencies updates:
75
-
76
- - Updated dependency [`@graphql-tools/utils@^10.10.3` ↗︎](https://www.npmjs.com/package/@graphql-tools/utils/v/10.10.3) (from `^10.10.1`, in `dependencies`)
77
-
78
- ## 1.0.4
79
- ### Patch Changes
80
-
81
-
82
-
83
- - [#1608](https://github.com/graphql-hive/gateway/pull/1608) [`9c789fb`](https://github.com/graphql-hive/gateway/commit/9c789fb11f6de80e781ff056cb5b98c548938bea) Thanks [@ardatan](https://github.com/ardatan)! - dependencies updates:
84
-
85
- - Updated dependency [`@graphql-tools/utils@^10.10.1` ↗︎](https://www.npmjs.com/package/@graphql-tools/utils/v/10.10.1) (from `^10.9.1`, in `dependencies`)
86
-
87
-
88
- - [#1662](https://github.com/graphql-hive/gateway/pull/1662) [`27789de`](https://github.com/graphql-hive/gateway/commit/27789de7967cb5299d471c00434591f309b978ff) Thanks [@ardatan](https://github.com/ardatan)! - dependencies updates:
89
-
90
- - Updated dependency [`@graphql-tools/utils@^10.10.1` ↗︎](https://www.npmjs.com/package/@graphql-tools/utils/v/10.10.1) (from `^10.10.0`, in `dependencies`)
91
-
92
-
93
- - [#1672](https://github.com/graphql-hive/gateway/pull/1672) [`3f6b99d`](https://github.com/graphql-hive/gateway/commit/3f6b99d152cbcc17d4ec3c97bc48dae452982151) Thanks [@dependabot](https://github.com/apps/dependabot)! - dependencies updates:
94
-
95
- - Updated dependency [`@envelop/core@^5.4.0` ↗︎](https://www.npmjs.com/package/@envelop/core/v/5.4.0) (from `^5.3.2`, in `dependencies`)
96
-
97
- ## 1.0.3
98
- ### Patch Changes
99
-
100
-
101
-
102
- - [#1654](https://github.com/graphql-hive/gateway/pull/1654) [`efed5e0`](https://github.com/graphql-hive/gateway/commit/efed5e0c257edcacb51dae7f670c2026a747a851) Thanks [@dependabot](https://github.com/apps/dependabot)! - dependencies updates:
103
-
104
- - Updated dependency [`@graphql-tools/utils@^10.10.0` ↗︎](https://www.npmjs.com/package/@graphql-tools/utils/v/10.10.0) (from `^10.9.1`, in `dependencies`)
105
-
106
- ## 1.0.2
107
- ### Patch Changes
108
-
109
-
110
-
111
- - [#1524](https://github.com/graphql-hive/gateway/pull/1524) [`d7b48a7`](https://github.com/graphql-hive/gateway/commit/d7b48a778344145478f0d3e1e1e188124181f0f2) Thanks [@enisdenjo](https://github.com/enisdenjo)! - dependencies updates:
112
-
113
- - Updated dependency [`@envelop/core@^5.3.2` ↗︎](https://www.npmjs.com/package/@envelop/core/v/5.3.2) (from `^5.3.1`, in `dependencies`)
114
-
115
- ## 1.0.1
116
- ### Patch Changes
117
-
118
-
119
-
120
- - [#1452](https://github.com/graphql-hive/gateway/pull/1452) [`b0e5568`](https://github.com/graphql-hive/gateway/commit/b0e55688d4fc22d0bfbf664de52e78e9642d7014) Thanks [@dependabot](https://github.com/apps/dependabot)! - dependencies updates:
121
-
122
- - Updated dependency [`@envelop/core@^5.3.1` ↗︎](https://www.npmjs.com/package/@envelop/core/v/5.3.1) (from `^5.3.0`, in `dependencies`)
123
-
124
- ## 1.0.0
125
- ### Major Changes
126
-
127
-
128
-
129
- - [#956](https://github.com/graphql-hive/gateway/pull/956) [`46d2661`](https://github.com/graphql-hive/gateway/commit/46d26615c2c3c5f936c1d1bca1d03b025c1ce86a) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - Drop Node 18 support
130
-
131
- Least supported Node version is now v20.
132
-
133
- ## 0.0.6
134
-
135
- ### Patch Changes
136
-
137
- - [#1358](https://github.com/graphql-hive/gateway/pull/1358) [`8e37851`](https://github.com/graphql-hive/gateway/commit/8e3785194d97edbe82c7fce316104b81bb0362f1) Thanks [@dependabot](https://github.com/apps/dependabot)! - dependencies updates:
138
- - Updated dependency [`@graphql-tools/utils@^10.9.1` ↗︎](https://www.npmjs.com/package/@graphql-tools/utils/v/10.9.1) (from `^10.9.0`, in `dependencies`)
139
-
140
- ## 0.0.5
141
-
142
- ### Patch Changes
143
-
144
- - [#1321](https://github.com/graphql-hive/gateway/pull/1321) [`6215001`](https://github.com/graphql-hive/gateway/commit/6215001b1d650ad865331661532bcc4f7bad6b40) Thanks [@dependabot](https://github.com/apps/dependabot)! - dependencies updates:
145
- - Updated dependency [`@envelop/core@^5.3.0` ↗︎](https://www.npmjs.com/package/@envelop/core/v/5.3.0) (from `^5.2.3`, in `dependencies`)
146
-
147
- - [#1344](https://github.com/graphql-hive/gateway/pull/1344) [`a71236d`](https://github.com/graphql-hive/gateway/commit/a71236d6ba356741bc85fe27757bea45576dcf1a) Thanks [@dependabot](https://github.com/apps/dependabot)! - dependencies updates:
148
- - Updated dependency [`@graphql-tools/utils@^10.9.0` ↗︎](https://www.npmjs.com/package/@graphql-tools/utils/v/10.9.0) (from `^10.8.1`, in `dependencies`)
149
-
150
- ## 0.0.4
151
-
152
- ### Patch Changes
153
-
154
- - [#706](https://github.com/graphql-hive/gateway/pull/706) [`e393337`](https://github.com/graphql-hive/gateway/commit/e393337ecb40beffb79748b19b5aa8f2fd9197b7) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - dependencies updates:
155
- - Updated dependency [`@envelop/core@^5.2.3` ↗︎](https://www.npmjs.com/package/@envelop/core/v/5.2.3) (from `^5.1.0`, in `dependencies`)
156
-
157
- ## 0.0.3
158
-
159
- ### Patch Changes
160
-
161
- - [#696](https://github.com/graphql-hive/gateway/pull/696) [`a289faa`](https://github.com/graphql-hive/gateway/commit/a289faae1469eb46f1458be341d21909fe5f8f8f) Thanks [@ardatan](https://github.com/ardatan)! - dependencies updates:
162
- - Updated dependency [`@envelop/core@^5.1.0` ↗︎](https://www.npmjs.com/package/@envelop/core/v/5.1.0) (from `^5.0.2`, in `dependencies`)
163
-
164
- ## 0.0.2
165
-
166
- ### Patch Changes
167
-
168
- - [#620](https://github.com/graphql-hive/gateway/pull/620) [`d72209a`](https://github.com/graphql-hive/gateway/commit/d72209ad82ec53689f93ce5d81bfa52493919ad9) Thanks [@renovate](https://github.com/apps/renovate)! - dependencies updates:
169
- - Updated dependency [`@graphql-tools/utils@^10.8.1` ↗︎](https://www.npmjs.com/package/@graphql-tools/utils/v/10.8.1) (from `^10.7.0`, in `dependencies`)
170
-
171
- ## 0.0.1
172
-
173
- ### Patch Changes
174
-
175
- - [#381](https://github.com/graphql-hive/gateway/pull/381) [`55eb1b4`](https://github.com/graphql-hive/gateway/commit/55eb1b4d14aec7b3e6c7bcf9f596bc01192d022c) Thanks [@ardatan](https://github.com/ardatan)! - This is a bugfix with some internal changes, no user action is needed. This bugfix and improvement is done to improve the stability of some components of the gateway;
176
-
177
- Like HMAC Upstream Signature plugin, different components of the gateway were using different ways of serializing the execution request.
178
- 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.
179
- For example, it was working as expected in Proxy mode, but not working as expected in Federation Gateway mode.
180
-
181
- 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.
182
-
183
- For example instead of using `print`, you should use `defaultPrintFn` that memoizes `print` operation and also used the string version of it parsed before by Envelop/Yoga.
184
-
185
- ```diff
186
- -import { print } from 'graphql';
187
- -const query = print(parsedQuery);
188
- +import { defaultPrintFn } from '@graphql-tools/executor-common';
189
- +const query = defaultPrintFn(parsedQuery);
190
- ```
191
-
192
- Or instead of creating objects from `ExecutionRequest`, use `serializeExecutionRequest` helper.
193
-
194
- ```diff
195
- -const serializedRequest = {
196
- - query: print(executionRequest.document),
197
- - variables: executionRequest.variables,
198
- - operationName: executionRequest.operationName,
199
- - extensions: executionRequest.extensions,
200
- -};
201
- +import { serializeExecutionRequest } from '@graphql-tools/executor-common';
202
- +const serializedRequest = serializeExecutionRequest(executionRequest);
203
- ```
package/dist/index.cjs DELETED
@@ -1,26 +0,0 @@
1
- 'use strict';
2
-
3
- var core = require('@envelop/core');
4
- var graphql = require('graphql');
5
-
6
- function stripAndPrint(document) {
7
- return graphql.stripIgnoredCharacters(graphql.print(document));
8
- }
9
- const defaultPrintFn = function defaultPrintFn2(document) {
10
- return core.getDocumentString(document, stripAndPrint);
11
- };
12
- function serializeExecutionRequest({
13
- executionRequest,
14
- excludeQuery,
15
- printFn = defaultPrintFn
16
- }) {
17
- return {
18
- query: excludeQuery ? void 0 : printFn(executionRequest.document),
19
- variables: (executionRequest.variables && Object.keys(executionRequest.variables).length) > 0 ? executionRequest.variables : void 0,
20
- operationName: executionRequest.operationName ? executionRequest.operationName : void 0,
21
- extensions: executionRequest.extensions && Object.keys(executionRequest.extensions).length > 0 ? executionRequest.extensions : void 0
22
- };
23
- }
24
-
25
- exports.defaultPrintFn = defaultPrintFn;
26
- exports.serializeExecutionRequest = serializeExecutionRequest;
package/dist/index.js DELETED
@@ -1,23 +0,0 @@
1
- import { getDocumentString } from '@envelop/core';
2
- import { stripIgnoredCharacters, print } from 'graphql';
3
-
4
- function stripAndPrint(document) {
5
- return stripIgnoredCharacters(print(document));
6
- }
7
- const defaultPrintFn = function defaultPrintFn2(document) {
8
- return getDocumentString(document, stripAndPrint);
9
- };
10
- function serializeExecutionRequest({
11
- executionRequest,
12
- excludeQuery,
13
- printFn = defaultPrintFn
14
- }) {
15
- return {
16
- query: excludeQuery ? void 0 : printFn(executionRequest.document),
17
- variables: (executionRequest.variables && Object.keys(executionRequest.variables).length) > 0 ? executionRequest.variables : void 0,
18
- operationName: executionRequest.operationName ? executionRequest.operationName : void 0,
19
- extensions: executionRequest.extensions && Object.keys(executionRequest.extensions).length > 0 ? executionRequest.extensions : void 0
20
- };
21
- }
22
-
23
- export { defaultPrintFn, serializeExecutionRequest };