@envelop/parser-cache 4.4.0-alpha-0969daf.0 → 4.4.0-alpha-35741fe.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 +2 -2
  2. package/index.mjs +3 -3
  3. package/package.json +2 -2
package/index.js CHANGED
@@ -3,15 +3,15 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const core = require('@envelop/core');
6
- const graphql = require('graphql');
7
6
 
8
7
  const useParserCache = (pluginOptions = {}) => {
9
8
  const documentCache = typeof pluginOptions.documentCache !== 'undefined' ? pluginOptions.documentCache : core.getInMemoryLRUCache();
10
9
  const errorCache = typeof pluginOptions.errorCache !== 'undefined' ? pluginOptions.errorCache : core.getInMemoryLRUCache();
11
10
  return {
12
11
  onParse({ params, setParsedDocument }) {
12
+ var _a;
13
13
  const { source } = params;
14
- const key = source instanceof graphql.Source ? source.body : source;
14
+ const key = core.isSourceObject(source) ? source.body : (_a = params.source) === null || _a === void 0 ? void 0 : _a.toString();
15
15
  const cachedError = errorCache.get(key);
16
16
  if (cachedError !== undefined) {
17
17
  throw cachedError;
package/index.mjs CHANGED
@@ -1,13 +1,13 @@
1
- import { getInMemoryLRUCache } from '@envelop/core';
2
- import { Source } from 'graphql';
1
+ import { getInMemoryLRUCache, isSourceObject } from '@envelop/core';
3
2
 
4
3
  const useParserCache = (pluginOptions = {}) => {
5
4
  const documentCache = typeof pluginOptions.documentCache !== 'undefined' ? pluginOptions.documentCache : getInMemoryLRUCache();
6
5
  const errorCache = typeof pluginOptions.errorCache !== 'undefined' ? pluginOptions.errorCache : getInMemoryLRUCache();
7
6
  return {
8
7
  onParse({ params, setParsedDocument }) {
8
+ var _a;
9
9
  const { source } = params;
10
- const key = source instanceof Source ? source.body : source;
10
+ const key = isSourceObject(source) ? source.body : (_a = params.source) === null || _a === void 0 ? void 0 : _a.toString();
11
11
  const cachedError = errorCache.get(key);
12
12
  if (cachedError !== undefined) {
13
13
  throw cachedError;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@envelop/parser-cache",
3
- "version": "4.4.0-alpha-0969daf.0",
3
+ "version": "4.4.0-alpha-35741fe.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "2.4.0-alpha-0969daf.0",
6
+ "@envelop/core": "2.4.0-alpha-35741fe.0",
7
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
8
8
  },
9
9
  "repository": {