@nerdwallet/apollo-cache-policies
Advanced tools
@@ -0,1 +1,5 @@ | ||
2.0.1 (Dan Reynolds) | ||
* Fix issue with custom Query type keyArgs preventing TTLs from evicting entities | ||
2.0.0 (Dan Reynolds) | ||
@@ -2,0 +6,0 @@ |
@@ -105,3 +105,3 @@ "use strict"; | ||
if (typename) { | ||
const storeFieldName = cache.policies.getStoreFieldName({ | ||
const storeFieldNameForEntity = cache.policies.getStoreFieldName({ | ||
typename, | ||
@@ -112,14 +112,28 @@ fieldName, | ||
}); | ||
const queryTypename = cache.policies.rootTypenamesById[dataId]; | ||
const storeFieldNameForQuery = cache.policies.getStoreFieldName({ | ||
typename: queryTypename, | ||
fieldName, | ||
field, | ||
variables, | ||
}); | ||
const renewalPolicy = invalidationPolicyManager.getRenewalPolicyForType(typename); | ||
if (renewalPolicy === types_1.RenewalPolicy.AccessAndWrite || | ||
renewalPolicy === types_1.RenewalPolicy.AccessOnly) { | ||
entityTypeMap.renewEntity(dataId, storeFieldName); | ||
entityTypeMap.renewEntity(dataId, storeFieldNameForEntity); | ||
entityTypeMap.renewEntity(dataId, storeFieldNameForQuery); | ||
} | ||
const evicted = invalidationPolicyManager.runReadPolicy({ | ||
const evictedByStoreFieldNameForEntity = invalidationPolicyManager.runReadPolicy({ | ||
typename, | ||
dataId, | ||
fieldName, | ||
storeFieldName | ||
storeFieldName: storeFieldNameForEntity, | ||
}); | ||
if (evicted) { | ||
const evictedByStoreFieldNameForQuery = invalidationPolicyManager.runReadPolicy({ | ||
typename, | ||
dataId, | ||
fieldName, | ||
storeFieldName: storeFieldNameForQuery, | ||
}); | ||
if (evictedByStoreFieldNameForEntity || evictedByStoreFieldNameForQuery) { | ||
delete result[fieldName]; | ||
@@ -126,0 +140,0 @@ return false; |
@@ -22,3 +22,2 @@ "use strict"; | ||
const subscribe = obsQuery.subscribe.bind(obsQuery); | ||
// TODO: Setup an unsubscribe handler that removes the field from the type policies list after. | ||
obsQuery.subscribe = (observer) => { | ||
@@ -25,0 +24,0 @@ // This check is modeled after the Zen Observable observer check: |
{ | ||
"name": "@nerdwallet/apollo-cache-policies", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "An extension to the InMemoryCache from Apollo that adds additional cache policies.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -343,4 +343,4 @@  | ||
In this example, we use the `readReferenceWhere` API to construct a type policy that returns all entities of the `Employee` type in the cache with a field `team` matching the value `Banking`. Any number of fields can be used as filters and queries for this type policy will automatically update whenever an employee is created or mutated. | ||
In this example, we use the `readReferenceWhere` API to construct a type policy that returns all entities of the `Employee` type in the cache with a field `team` matching the value `Banking`. Any number of fields can be used as filters and queries for this type policy will automatically update whenever an employee entity is added, created removed from the cache. | ||
</details> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
269236
0.49%2373
0.55%