@envelop/response-cache 3.0.0-alpha-e41b2ae.0 → 3.0.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.
@@ -6,10 +6,10 @@ const sha256Browser = (bytes) => {
6
6
  const hash = webCrypto.subtle.digest({ name: 'SHA-256' }, bytes);
7
7
  return new Promise((resolve, reject) => {
8
8
  Promise.resolve(hash)
9
- .then(function (result) {
9
+ .then(result => {
10
10
  resolve(new Uint8Array(result));
11
11
  })
12
- .catch(function (error) {
12
+ .catch(error => {
13
13
  reject(error);
14
14
  });
15
15
  });
package/cjs/plugin.js CHANGED
@@ -7,7 +7,7 @@ const utils_1 = require("@graphql-tools/utils");
7
7
  const graphql_1 = require("graphql");
8
8
  const fast_json_stable_stringify_1 = tslib_1.__importDefault(require("fast-json-stable-stringify"));
9
9
  const in_memory_cache_js_1 = require("./in-memory-cache.js");
10
- const hashSHA256_js_1 = require("./hashSHA256.js");
10
+ const hash_sha256_js_1 = require("./hash-sha256.js");
11
11
  const cache_document_str_js_1 = require("./cache-document-str.js");
12
12
  /**
13
13
  * Default function used for building the response cache key.
@@ -15,7 +15,7 @@ const cache_document_str_js_1 = require("./cache-document-str.js");
15
15
  */
16
16
  const defaultBuildResponseCacheKey = params => {
17
17
  var _a, _b, _c;
18
- return (0, hashSHA256_js_1.hashSHA256)([
18
+ return (0, hash_sha256_js_1.hashSHA256)([
19
19
  params.documentString,
20
20
  (_a = params.operationName) !== null && _a !== void 0 ? _a : '',
21
21
  (0, fast_json_stable_stringify_1.default)((_b = params.variableValues) !== null && _b !== void 0 ? _b : {}),
@@ -110,7 +110,7 @@ includeExtensionMetadata = typeof process !== 'undefined' ? process.env['NODE_EN
110
110
  if (fieldName === '__typename') {
111
111
  typenameCalled++;
112
112
  }
113
- if (fieldName === '__leave') {
113
+ if (fieldName === '__leave' &&
114
114
  /**
115
115
  * The visitResult function is called for each field in the selection set.
116
116
  * But visitResult function looks for __typename field visitor even if it is not there in the document
@@ -119,13 +119,11 @@ includeExtensionMetadata = typeof process !== 'undefined' ? process.env['NODE_EN
119
119
  *
120
120
  * Default call of __typename https://github.com/ardatan/graphql-tools/blob/master/packages/utils/src/visitResult.ts#L277
121
121
  * Call for the field node https://github.com/ardatan/graphql-tools/blob/master/packages/utils/src/visitResult.ts#L272
122
- */
123
- if (typenameCalled < 2) {
124
- return (root) => {
125
- delete root.__typename;
126
- return root;
127
- };
128
- }
122
+ */ typenameCalled < 2) {
123
+ return (root) => {
124
+ delete root.__typename;
125
+ return root;
126
+ };
129
127
  }
130
128
  }
131
129
  if (idFields.includes(fieldName)) {
@@ -3,10 +3,10 @@ const sha256Browser = (bytes) => {
3
3
  const hash = webCrypto.subtle.digest({ name: 'SHA-256' }, bytes);
4
4
  return new Promise((resolve, reject) => {
5
5
  Promise.resolve(hash)
6
- .then(function (result) {
6
+ .then(result => {
7
7
  resolve(new Uint8Array(result));
8
8
  })
9
- .catch(function (error) {
9
+ .catch(error => {
10
10
  reject(error);
11
11
  });
12
12
  });
package/esm/plugin.js CHANGED
@@ -3,7 +3,7 @@ import { visitResult } from '@graphql-tools/utils';
3
3
  import { visit, TypeInfo, visitWithTypeInfo, getOperationAST, Kind, } from 'graphql';
4
4
  import jsonStableStringify from 'fast-json-stable-stringify';
5
5
  import { createInMemoryCache } from './in-memory-cache.js';
6
- import { hashSHA256 } from './hashSHA256.js';
6
+ import { hashSHA256 } from './hash-sha256.js';
7
7
  import { defaultGetDocumentString, useCacheDocumentString } from './cache-document-str.js';
8
8
  /**
9
9
  * Default function used for building the response cache key.
@@ -104,7 +104,7 @@ includeExtensionMetadata = typeof process !== 'undefined' ? process.env['NODE_EN
104
104
  if (fieldName === '__typename') {
105
105
  typenameCalled++;
106
106
  }
107
- if (fieldName === '__leave') {
107
+ if (fieldName === '__leave' &&
108
108
  /**
109
109
  * The visitResult function is called for each field in the selection set.
110
110
  * But visitResult function looks for __typename field visitor even if it is not there in the document
@@ -113,13 +113,11 @@ includeExtensionMetadata = typeof process !== 'undefined' ? process.env['NODE_EN
113
113
  *
114
114
  * Default call of __typename https://github.com/ardatan/graphql-tools/blob/master/packages/utils/src/visitResult.ts#L277
115
115
  * Call for the field node https://github.com/ardatan/graphql-tools/blob/master/packages/utils/src/visitResult.ts#L272
116
- */
117
- if (typenameCalled < 2) {
118
- return (root) => {
119
- delete root.__typename;
120
- return root;
121
- };
122
- }
116
+ */ typenameCalled < 2) {
117
+ return (root) => {
118
+ delete root.__typename;
119
+ return root;
120
+ };
123
121
  }
124
122
  }
125
123
  if (idFields.includes(fieldName)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envelop/response-cache",
3
- "version": "3.0.0-alpha-e41b2ae.0",
3
+ "version": "3.0.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "@envelop/core": "^2.4.0",
File without changes