@envelop/response-cache 8.0.0 → 8.0.1
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/cjs/plugin.js +13 -6
- package/esm/plugin.js +13 -6
- package/package.json +2 -2
package/cjs/plugin.js
CHANGED
|
@@ -226,9 +226,11 @@ function useResponseCache({ cache = (0, in_memory_cache_js_1.createInMemoryCache
|
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
function invalidateCache(result, setResult) {
|
|
229
|
-
|
|
229
|
+
let changed = false;
|
|
230
230
|
if (result.data) {
|
|
231
|
+
result = { ...result };
|
|
231
232
|
result.data = removeMetadataFieldsFromResult(result.data, onEntity);
|
|
233
|
+
changed = true;
|
|
232
234
|
}
|
|
233
235
|
const cacheInstance = cacheFactory(onExecuteParams.args.contextValue);
|
|
234
236
|
if (cacheInstance == null) {
|
|
@@ -236,11 +238,16 @@ function useResponseCache({ cache = (0, in_memory_cache_js_1.createInMemoryCache
|
|
|
236
238
|
console.warn('[useResponseCache] Cache instance is not available for the context. Skipping invalidation.');
|
|
237
239
|
return;
|
|
238
240
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
241
|
+
if (identifier.size > 0) {
|
|
242
|
+
cacheInstance.invalidate(identifier.values());
|
|
243
|
+
if (includeExtensionMetadata) {
|
|
244
|
+
return setResult(resultWithMetadata(result, {
|
|
245
|
+
invalidatedEntities: Array.from(identifier.values()),
|
|
246
|
+
}));
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (changed) {
|
|
250
|
+
setResult(result);
|
|
244
251
|
}
|
|
245
252
|
}
|
|
246
253
|
if (invalidateViaMutation !== false) {
|
package/esm/plugin.js
CHANGED
|
@@ -217,9 +217,11 @@ export function useResponseCache({ cache = createInMemoryCache(), ttl: globalTtl
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
function invalidateCache(result, setResult) {
|
|
220
|
-
|
|
220
|
+
let changed = false;
|
|
221
221
|
if (result.data) {
|
|
222
|
+
result = { ...result };
|
|
222
223
|
result.data = removeMetadataFieldsFromResult(result.data, onEntity);
|
|
224
|
+
changed = true;
|
|
223
225
|
}
|
|
224
226
|
const cacheInstance = cacheFactory(onExecuteParams.args.contextValue);
|
|
225
227
|
if (cacheInstance == null) {
|
|
@@ -227,11 +229,16 @@ export function useResponseCache({ cache = createInMemoryCache(), ttl: globalTtl
|
|
|
227
229
|
console.warn('[useResponseCache] Cache instance is not available for the context. Skipping invalidation.');
|
|
228
230
|
return;
|
|
229
231
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
232
|
+
if (identifier.size > 0) {
|
|
233
|
+
cacheInstance.invalidate(identifier.values());
|
|
234
|
+
if (includeExtensionMetadata) {
|
|
235
|
+
return setResult(resultWithMetadata(result, {
|
|
236
|
+
invalidatedEntities: Array.from(identifier.values()),
|
|
237
|
+
}));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (changed) {
|
|
241
|
+
setResult(result);
|
|
235
242
|
}
|
|
236
243
|
}
|
|
237
244
|
if (invalidateViaMutation !== false) {
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envelop/response-cache",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
7
|
-
"@envelop/core": "^5.3.
|
|
7
|
+
"@envelop/core": "^5.3.1"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@graphql-tools/utils": "^10.0.3",
|