@graphql-tools/executor-common 0.0.4 → 0.0.5-alpha-5c304a6911bf81bf710f865b4fbc9ad0d842b8ac
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 +8 -0
- package/dist/index.cjs +22 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +18 -4
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @graphql-tools/executor-common
|
|
2
2
|
|
|
3
|
+
## 0.0.5-alpha-5c304a6911bf81bf710f865b4fbc9ad0d842b8ac
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1053](https://github.com/graphql-hive/gateway/pull/1053) [`5c304a6`](https://github.com/graphql-hive/gateway/commit/5c304a6911bf81bf710f865b4fbc9ad0d842b8ac) Thanks [@enisdenjo](https://github.com/enisdenjo)! - dependencies updates:
|
|
8
|
+
|
|
9
|
+
- Added dependency [`react-fast-compare@^3.2.2` ↗︎](https://www.npmjs.com/package/react-fast-compare/v/3.2.2) (to `dependencies`)
|
|
10
|
+
|
|
3
11
|
## 0.0.4
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var core = require('@envelop/core');
|
|
4
|
-
var utils = require('@graphql-tools/utils');
|
|
5
4
|
var graphql = require('graphql');
|
|
5
|
+
var fastCompare = require('react-fast-compare');
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var fastCompare__default = /*#__PURE__*/_interopDefault(fastCompare);
|
|
10
|
+
|
|
11
|
+
const documentNodesCache = /* @__PURE__ */ new Map();
|
|
12
|
+
function defaultPrintFn(document) {
|
|
13
|
+
for (const [cachedDocument, documentString2] of documentNodesCache) {
|
|
14
|
+
if (fastCompare__default.default(document, cachedDocument)) {
|
|
15
|
+
return documentString2;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const documentString = graphql.stripIgnoredCharacters(
|
|
19
|
+
core.getDocumentString(document, graphql.print)
|
|
20
|
+
);
|
|
21
|
+
documentNodesCache.set(document, documentString);
|
|
22
|
+
if (documentNodesCache.size > 10) {
|
|
23
|
+
const firstDocument = documentNodesCache.keys().next().value;
|
|
24
|
+
documentNodesCache.delete(firstDocument);
|
|
25
|
+
}
|
|
26
|
+
return documentString;
|
|
27
|
+
}
|
|
10
28
|
function serializeExecutionRequest({
|
|
11
29
|
executionRequest,
|
|
12
30
|
excludeQuery,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ExecutionRequest } from '@graphql-tools/utils';
|
|
2
2
|
import { DocumentNode } from 'graphql';
|
|
3
3
|
|
|
4
|
-
declare
|
|
4
|
+
declare function defaultPrintFn(document: DocumentNode): string;
|
|
5
5
|
interface ExecutionRequestToGraphQLParams {
|
|
6
6
|
executionRequest: ExecutionRequest;
|
|
7
7
|
excludeQuery?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ExecutionRequest } from '@graphql-tools/utils';
|
|
2
2
|
import { DocumentNode } from 'graphql';
|
|
3
3
|
|
|
4
|
-
declare
|
|
4
|
+
declare function defaultPrintFn(document: DocumentNode): string;
|
|
5
5
|
interface ExecutionRequestToGraphQLParams {
|
|
6
6
|
executionRequest: ExecutionRequest;
|
|
7
7
|
excludeQuery?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import { getDocumentString } from '@envelop/core';
|
|
2
|
-
import { memoize1 } from '@graphql-tools/utils';
|
|
3
2
|
import { stripIgnoredCharacters, print } from 'graphql';
|
|
3
|
+
import fastCompare from 'react-fast-compare';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const documentNodesCache = /* @__PURE__ */ new Map();
|
|
6
|
+
function defaultPrintFn(document) {
|
|
7
|
+
for (const [cachedDocument, documentString2] of documentNodesCache) {
|
|
8
|
+
if (fastCompare(document, cachedDocument)) {
|
|
9
|
+
return documentString2;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const documentString = stripIgnoredCharacters(
|
|
13
|
+
getDocumentString(document, print)
|
|
14
|
+
);
|
|
15
|
+
documentNodesCache.set(document, documentString);
|
|
16
|
+
if (documentNodesCache.size > 10) {
|
|
17
|
+
const firstDocument = documentNodesCache.keys().next().value;
|
|
18
|
+
documentNodesCache.delete(firstDocument);
|
|
19
|
+
}
|
|
20
|
+
return documentString;
|
|
21
|
+
}
|
|
8
22
|
function serializeExecutionRequest({
|
|
9
23
|
executionRequest,
|
|
10
24
|
excludeQuery,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/executor-common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5-alpha-5c304a6911bf81bf710f865b4fbc9ad0d842b8ac",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
6
6
|
"repository": {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"node": ">=18.0.0"
|
|
15
15
|
},
|
|
16
16
|
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
17
18
|
"exports": {
|
|
18
19
|
".": {
|
|
19
20
|
"require": {
|
|
@@ -27,7 +28,6 @@
|
|
|
27
28
|
},
|
|
28
29
|
"./package.json": "./package.json"
|
|
29
30
|
},
|
|
30
|
-
"types": "./dist/index.d.ts",
|
|
31
31
|
"files": [
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
@@ -40,11 +40,12 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@envelop/core": "^5.2.3",
|
|
43
|
-
"@graphql-tools/utils": "^10.8.1"
|
|
43
|
+
"@graphql-tools/utils": "^10.8.1",
|
|
44
|
+
"react-fast-compare": "^3.2.2"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"graphql": "^16.9.0",
|
|
47
|
-
"pkgroll": "2.
|
|
48
|
+
"pkgroll": "2.12.1"
|
|
48
49
|
},
|
|
49
50
|
"sideEffects": false
|
|
50
51
|
}
|