@graphql-tools/executor-common 0.0.0 → 0.0.1-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 ADDED
@@ -0,0 +1,11 @@
1
+ # @graphql-tools/executor-common
2
+
3
+ ## 0.0.1-alpha-3df7faeea69a8bf7e4423f5661c1cb8974232f19
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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.
8
+ 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.
9
+ For example, it was working as expected in Proxy mode, but not working as expected in Federation Gateway mode.
10
+
11
+ 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.
package/dist/index.cjs CHANGED
@@ -7,7 +7,7 @@ var graphql = require('graphql');
7
7
  const defaultPrintFn = utils.memoize1(function defaultPrintFn2(document) {
8
8
  return graphql.stripIgnoredCharacters(core.getDocumentString(document, graphql.print));
9
9
  });
10
- function executionRequestToGraphQLParams({
10
+ function serializeExecutionRequest({
11
11
  executionRequest,
12
12
  excludeQuery,
13
13
  printFn = defaultPrintFn
@@ -21,4 +21,4 @@ function executionRequestToGraphQLParams({
21
21
  }
22
22
 
23
23
  exports.defaultPrintFn = defaultPrintFn;
24
- exports.executionRequestToGraphQLParams = executionRequestToGraphQLParams;
24
+ exports.serializeExecutionRequest = serializeExecutionRequest;
package/dist/index.d.cts CHANGED
@@ -7,20 +7,20 @@ interface ExecutionRequestToGraphQLParams {
7
7
  excludeQuery?: boolean;
8
8
  printFn?: typeof defaultPrintFn;
9
9
  }
10
- interface GraphQLParams {
10
+ interface SerializedExecutionRequest {
11
11
  query?: string | undefined;
12
12
  variables?: Record<string, any>;
13
13
  operationName?: string;
14
14
  extensions?: Record<string, any>;
15
15
  }
16
- declare function executionRequestToGraphQLParams(opts: Omit<ExecutionRequestToGraphQLParams, 'excludeQuery'> & {
16
+ declare function serializeExecutionRequest(opts: Omit<ExecutionRequestToGraphQLParams, 'excludeQuery'> & {
17
17
  excludeQuery: true;
18
- }): Omit<GraphQLParams, 'query'>;
19
- declare function executionRequestToGraphQLParams(opts: Omit<ExecutionRequestToGraphQLParams, 'excludeQuery'> & {
18
+ }): Omit<SerializedExecutionRequest, 'query'>;
19
+ declare function serializeExecutionRequest(opts: Omit<ExecutionRequestToGraphQLParams, 'excludeQuery'> & {
20
20
  excludeQuery?: false;
21
- }): Omit<GraphQLParams, 'query'> & {
21
+ }): Omit<SerializedExecutionRequest, 'query'> & {
22
22
  query: string;
23
23
  };
24
- declare function executionRequestToGraphQLParams(opts: ExecutionRequestToGraphQLParams): GraphQLParams;
24
+ declare function serializeExecutionRequest(opts: ExecutionRequestToGraphQLParams): SerializedExecutionRequest;
25
25
 
26
- export { type GraphQLParams, defaultPrintFn, executionRequestToGraphQLParams };
26
+ export { type SerializedExecutionRequest, defaultPrintFn, serializeExecutionRequest };
package/dist/index.d.ts CHANGED
@@ -7,20 +7,20 @@ interface ExecutionRequestToGraphQLParams {
7
7
  excludeQuery?: boolean;
8
8
  printFn?: typeof defaultPrintFn;
9
9
  }
10
- interface GraphQLParams {
10
+ interface SerializedExecutionRequest {
11
11
  query?: string | undefined;
12
12
  variables?: Record<string, any>;
13
13
  operationName?: string;
14
14
  extensions?: Record<string, any>;
15
15
  }
16
- declare function executionRequestToGraphQLParams(opts: Omit<ExecutionRequestToGraphQLParams, 'excludeQuery'> & {
16
+ declare function serializeExecutionRequest(opts: Omit<ExecutionRequestToGraphQLParams, 'excludeQuery'> & {
17
17
  excludeQuery: true;
18
- }): Omit<GraphQLParams, 'query'>;
19
- declare function executionRequestToGraphQLParams(opts: Omit<ExecutionRequestToGraphQLParams, 'excludeQuery'> & {
18
+ }): Omit<SerializedExecutionRequest, 'query'>;
19
+ declare function serializeExecutionRequest(opts: Omit<ExecutionRequestToGraphQLParams, 'excludeQuery'> & {
20
20
  excludeQuery?: false;
21
- }): Omit<GraphQLParams, 'query'> & {
21
+ }): Omit<SerializedExecutionRequest, 'query'> & {
22
22
  query: string;
23
23
  };
24
- declare function executionRequestToGraphQLParams(opts: ExecutionRequestToGraphQLParams): GraphQLParams;
24
+ declare function serializeExecutionRequest(opts: ExecutionRequestToGraphQLParams): SerializedExecutionRequest;
25
25
 
26
- export { type GraphQLParams, defaultPrintFn, executionRequestToGraphQLParams };
26
+ export { type SerializedExecutionRequest, defaultPrintFn, serializeExecutionRequest };
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { stripIgnoredCharacters, print } from 'graphql';
5
5
  const defaultPrintFn = memoize1(function defaultPrintFn2(document) {
6
6
  return stripIgnoredCharacters(getDocumentString(document, print));
7
7
  });
8
- function executionRequestToGraphQLParams({
8
+ function serializeExecutionRequest({
9
9
  executionRequest,
10
10
  excludeQuery,
11
11
  printFn = defaultPrintFn
@@ -18,4 +18,4 @@ function executionRequestToGraphQLParams({
18
18
  };
19
19
  }
20
20
 
21
- export { defaultPrintFn, executionRequestToGraphQLParams };
21
+ export { defaultPrintFn, serializeExecutionRequest };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/executor-common",
3
- "version": "0.0.0",
3
+ "version": "0.0.1-alpha-3df7faeea69a8bf7e4423f5661c1cb8974232f19",
4
4
  "type": "module",
5
5
  "description": "A set of utils for faster development of GraphQL tools",
6
6
  "repository": {