@envelop/validation-cache 5.0.0-alpha-4ba70ab.0 → 5.0.0-alpha-d0d0776.0

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.
Files changed (3) hide show
  1. package/index.js +7 -6
  2. package/index.mjs +1 -2
  3. package/package.json +19 -7
package/index.js CHANGED
@@ -2,16 +2,18 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
5
  const graphql = require('graphql');
8
- const lru = _interopDefault(require('tiny-lru'));
6
+ const lru = require('tiny-lru');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ const lru__default = /*#__PURE__*/_interopDefaultLegacy(lru);
9
11
 
10
12
  const DEFAULT_MAX = 1000;
11
13
  const DEFAULT_TTL = 3600000;
12
14
  const rawDocumentSymbol = Symbol('rawDocument');
13
15
  const useValidationCache = (pluginOptions = {}) => {
14
- const resultCache = typeof pluginOptions.cache !== 'undefined' ? pluginOptions.cache : lru(DEFAULT_MAX, DEFAULT_TTL);
16
+ const resultCache = typeof pluginOptions.cache !== 'undefined' ? pluginOptions.cache : lru__default["default"](DEFAULT_MAX, DEFAULT_TTL);
15
17
  return {
16
18
  onSchemaChange() {
17
19
  resultCache.clear();
@@ -20,8 +22,7 @@ const useValidationCache = (pluginOptions = {}) => {
20
22
  extendContext({ [rawDocumentSymbol]: params.source.toString() });
21
23
  },
22
24
  onValidate({ params, context, setResult }) {
23
- var _a;
24
- const key = (_a = context[rawDocumentSymbol]) !== null && _a !== void 0 ? _a : graphql.print(params.documentAST);
25
+ const key = context[rawDocumentSymbol] ?? graphql.print(params.documentAST);
25
26
  const cachedResult = resultCache.get(key);
26
27
  if (cachedResult !== undefined) {
27
28
  setResult(cachedResult);
package/index.mjs CHANGED
@@ -14,8 +14,7 @@ const useValidationCache = (pluginOptions = {}) => {
14
14
  extendContext({ [rawDocumentSymbol]: params.source.toString() });
15
15
  },
16
16
  onValidate({ params, context, setResult }) {
17
- var _a;
18
- const key = (_a = context[rawDocumentSymbol]) !== null && _a !== void 0 ? _a : print(params.documentAST);
17
+ const key = context[rawDocumentSymbol] ?? print(params.documentAST);
19
18
  const cachedResult = resultCache.get(key);
20
19
  if (cachedResult !== undefined) {
21
20
  setResult(cachedResult);
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@envelop/validation-cache",
3
- "version": "5.0.0-alpha-4ba70ab.0",
3
+ "version": "5.0.0-alpha-d0d0776.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "2.1.0-alpha-4ba70ab.0",
6
+ "@envelop/core": "3.0.0-alpha-d0d0776.0",
7
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
8
8
  },
9
9
  "dependencies": {
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "https://github.com/dotansimha/envelop.git",
14
+ "url": "https://github.com/n1ru4l/envelop.git",
15
15
  "directory": "packages/plugins/validation-cache"
16
16
  },
17
17
  "author": "Dotan Simha <dotansimha@gmail.com>",
@@ -24,12 +24,24 @@
24
24
  },
25
25
  "exports": {
26
26
  ".": {
27
- "require": "./index.js",
28
- "import": "./index.mjs"
27
+ "require": {
28
+ "default": "./index.js",
29
+ "types": "./index.d.ts"
30
+ },
31
+ "import": {
32
+ "default": "./index.mjs",
33
+ "types": "./index.d.ts"
34
+ }
29
35
  },
30
36
  "./*": {
31
- "require": "./*.js",
32
- "import": "./*.mjs"
37
+ "require": {
38
+ "default": "./*.js",
39
+ "types": "./*.d.ts"
40
+ },
41
+ "import": {
42
+ "default": "./*.mjs",
43
+ "types": "./*.d.ts"
44
+ }
33
45
  },
34
46
  "./package.json": "./package.json"
35
47
  }