@envelop/validation-cache 4.7.0 → 4.7.1-alpha-20220901205925-b1fd44a9

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,10 +13,15 @@ yarn add @envelop/validation-cache
13
13
  ## Usage Example
14
14
 
15
15
  ```ts
16
+ import { parse, validate, execute, subscribe } from 'graphql'
16
17
  import { envelop } from '@envelop/core'
17
18
  import { useValidationCache } from '@envelop/validation-cache'
18
19
 
19
20
  const getEnveloped = envelop({
21
+ parse,
22
+ validate,
23
+ execute,
24
+ subscribe,
20
25
  plugins: [
21
26
  // ... other plugins ...
22
27
  useValidationCache({
package/cjs/index.js CHANGED
@@ -16,25 +16,24 @@ const useValidationCache = (pluginOptions = {}) => {
16
16
  });
17
17
  return {
18
18
  onSchemaChange() {
19
- var _a, _b;
20
19
  if (resultCache.reset) {
21
- (_a = resultCache.reset) === null || _a === void 0 ? void 0 : _a.call(resultCache);
20
+ resultCache.reset?.();
22
21
  }
23
22
  else if ('clear' in resultCache) {
24
- (_b = resultCache.clear) === null || _b === void 0 ? void 0 : _b.call(resultCache);
23
+ resultCache.clear?.();
25
24
  }
26
25
  },
27
26
  onParse({ params, extendContext }) {
28
27
  extendContext({ [rawDocumentSymbol]: params.source.toString() });
29
28
  },
30
29
  onValidate({ params, context, setResult }) {
31
- var _a;
32
- const key = (_a = context[rawDocumentSymbol]) !== null && _a !== void 0 ? _a : (0, graphql_1.print)(params.documentAST);
30
+ const key = context[rawDocumentSymbol] ?? (0, graphql_1.print)(params.documentAST);
33
31
  const cachedResult = resultCache.get(key);
34
32
  if (cachedResult !== undefined) {
35
33
  setResult(cachedResult);
36
34
  }
37
35
  return ({ result }) => {
36
+ // @ts-expect-error TODO: not sure how we will make it dev friendly
38
37
  resultCache.set(key, result);
39
38
  };
40
39
  },
package/esm/index.js CHANGED
@@ -12,25 +12,24 @@ export const useValidationCache = (pluginOptions = {}) => {
12
12
  });
13
13
  return {
14
14
  onSchemaChange() {
15
- var _a, _b;
16
15
  if (resultCache.reset) {
17
- (_a = resultCache.reset) === null || _a === void 0 ? void 0 : _a.call(resultCache);
16
+ resultCache.reset?.();
18
17
  }
19
18
  else if ('clear' in resultCache) {
20
- (_b = resultCache.clear) === null || _b === void 0 ? void 0 : _b.call(resultCache);
19
+ resultCache.clear?.();
21
20
  }
22
21
  },
23
22
  onParse({ params, extendContext }) {
24
23
  extendContext({ [rawDocumentSymbol]: params.source.toString() });
25
24
  },
26
25
  onValidate({ params, context, setResult }) {
27
- var _a;
28
- const key = (_a = context[rawDocumentSymbol]) !== null && _a !== void 0 ? _a : print(params.documentAST);
26
+ const key = context[rawDocumentSymbol] ?? print(params.documentAST);
29
27
  const cachedResult = resultCache.get(key);
30
28
  if (cachedResult !== undefined) {
31
29
  setResult(cachedResult);
32
30
  }
33
31
  return ({ result }) => {
32
+ // @ts-expect-error TODO: not sure how we will make it dev friendly
34
33
  resultCache.set(key, result);
35
34
  };
36
35
  },
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@envelop/validation-cache",
3
- "version": "4.7.0",
3
+ "version": "4.7.1-alpha-20220901205925-b1fd44a9",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "^2.6.0",
6
+ "@envelop/core": "2.6.1-alpha-20220901205925-b1fd44a9",
7
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
8
8
  },
9
9
  "dependencies": {