@envelop/parser-cache 5.0.0-alpha-d0d0776.0 → 5.0.0-alpha-5b6bfa8.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.
package/README.md CHANGED
@@ -13,17 +13,17 @@ yarn add @envelop/parser-cache
13
13
  ## Usage Example
14
14
 
15
15
  ```ts
16
- import { envelop } from '@envelop/core';
17
- import { useParserCache } from '@envelop/parser-cache';
16
+ import { envelop } from '@envelop/core'
17
+ import { useParserCache } from '@envelop/parser-cache'
18
18
 
19
19
  const getEnveloped = envelop({
20
20
  plugins: [
21
21
  // ... other plugins ...
22
22
  useParserCache({
23
23
  // options goes here
24
- }),
25
- ],
26
- });
24
+ })
25
+ ]
26
+ })
27
27
  ```
28
28
 
29
29
  ### API Reference
@@ -1,25 +1,22 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const graphql = require('graphql');
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);
11
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useParserCache = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const graphql_1 = require("@graphql-tools/graphql");
6
+ const lru_cache_1 = tslib_1.__importDefault(require("lru-cache"));
12
7
  const DEFAULT_MAX = 1000;
13
8
  const DEFAULT_TTL = 3600000;
14
9
  const useParserCache = (pluginOptions = {}) => {
15
10
  const documentCache = typeof pluginOptions.documentCache !== 'undefined'
16
11
  ? pluginOptions.documentCache
17
- : lru__default["default"](DEFAULT_MAX, DEFAULT_TTL);
18
- const errorCache = typeof pluginOptions.errorCache !== 'undefined' ? pluginOptions.errorCache : lru__default["default"](DEFAULT_MAX, DEFAULT_TTL);
12
+ : new lru_cache_1.default({ max: DEFAULT_MAX, maxAge: DEFAULT_TTL });
13
+ const errorCache = typeof pluginOptions.errorCache !== 'undefined'
14
+ ? pluginOptions.errorCache
15
+ : new lru_cache_1.default({ max: DEFAULT_MAX, maxAge: DEFAULT_TTL });
19
16
  return {
20
17
  onParse({ params, setParsedDocument }) {
21
18
  const { source } = params;
22
- const key = source instanceof graphql.Source ? source.body : source;
19
+ const key = source instanceof graphql_1.Source ? source.body : source;
23
20
  const cachedError = errorCache.get(key);
24
21
  if (cachedError !== undefined) {
25
22
  throw cachedError;
@@ -39,5 +36,4 @@ const useParserCache = (pluginOptions = {}) => {
39
36
  },
40
37
  };
41
38
  };
42
-
43
39
  exports.useParserCache = useParserCache;
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -1,13 +1,14 @@
1
- import { Source } from 'graphql';
2
- import lru from 'tiny-lru';
3
-
1
+ import { Source } from '@graphql-tools/graphql';
2
+ import LRU from 'lru-cache';
4
3
  const DEFAULT_MAX = 1000;
5
4
  const DEFAULT_TTL = 3600000;
6
- const useParserCache = (pluginOptions = {}) => {
5
+ export const useParserCache = (pluginOptions = {}) => {
7
6
  const documentCache = typeof pluginOptions.documentCache !== 'undefined'
8
7
  ? pluginOptions.documentCache
9
- : lru(DEFAULT_MAX, DEFAULT_TTL);
10
- const errorCache = typeof pluginOptions.errorCache !== 'undefined' ? pluginOptions.errorCache : lru(DEFAULT_MAX, DEFAULT_TTL);
8
+ : new LRU({ max: DEFAULT_MAX, maxAge: DEFAULT_TTL });
9
+ const errorCache = typeof pluginOptions.errorCache !== 'undefined'
10
+ ? pluginOptions.errorCache
11
+ : new LRU({ max: DEFAULT_MAX, maxAge: DEFAULT_TTL });
11
12
  return {
12
13
  onParse({ params, setParsedDocument }) {
13
14
  const { source } = params;
@@ -31,5 +32,3 @@ const useParserCache = (pluginOptions = {}) => {
31
32
  },
32
33
  };
33
34
  };
34
-
35
- export { useParserCache };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@envelop/parser-cache",
3
- "version": "5.0.0-alpha-d0d0776.0",
3
+ "version": "5.0.0-alpha-5b6bfa8.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "3.0.0-alpha-d0d0776.0",
7
- "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
6
+ "@envelop/core": "3.0.0-alpha-5b6bfa8.0",
7
+ "@graphql-tools/graphql": "0.1.0-alpha-33fb2950.0"
8
8
  },
9
9
  "dependencies": {
10
- "tiny-lru": "7.0.6"
10
+ "lru-cache": "^6.0.0"
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
@@ -16,33 +16,42 @@
16
16
  },
17
17
  "author": "Dotan Simha <dotansimha@gmail.com>",
18
18
  "license": "MIT",
19
- "main": "index.js",
20
- "module": "index.mjs",
21
- "typings": "index.d.ts",
19
+ "main": "cjs/index.js",
20
+ "module": "esm/index.js",
21
+ "typings": "typings/index.d.ts",
22
22
  "typescript": {
23
- "definition": "index.d.ts"
23
+ "definition": "typings/index.d.ts"
24
24
  },
25
+ "type": "module",
25
26
  "exports": {
26
27
  ".": {
27
28
  "require": {
28
- "default": "./index.js",
29
- "types": "./index.d.ts"
29
+ "types": "./typings/index.d.ts",
30
+ "default": "./cjs/index.js"
30
31
  },
31
32
  "import": {
32
- "default": "./index.mjs",
33
- "types": "./index.d.ts"
33
+ "types": "./typings/index.d.ts",
34
+ "default": "./esm/index.js"
35
+ },
36
+ "default": {
37
+ "types": "./typings/index.d.ts",
38
+ "default": "./esm/index.js"
34
39
  }
35
40
  },
36
41
  "./*": {
37
42
  "require": {
38
- "default": "./*.js",
39
- "types": "./*.d.ts"
43
+ "types": "./typings/*.d.ts",
44
+ "default": "./cjs/*.js"
40
45
  },
41
46
  "import": {
42
- "default": "./*.mjs",
43
- "types": "./*.d.ts"
47
+ "types": "./typings/*.d.ts",
48
+ "default": "./esm/*.js"
49
+ },
50
+ "default": {
51
+ "types": "./typings/*.d.ts",
52
+ "default": "./esm/*.js"
44
53
  }
45
54
  },
46
55
  "./package.json": "./package.json"
47
56
  }
48
- }
57
+ }
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from '@envelop/core';
2
- import { DocumentNode } from 'graphql';
2
+ import { DocumentNode } from '@graphql-tools/graphql';
3
3
  interface Cache<T> {
4
4
  get(key: string): T | undefined;
5
5
  set(key: string, value: T): void;