`cacheTime` inconsistently set for existing queries
Bug: Inconsistent cacheTime updates in EntityTypeMap.write method
Description
The write method in EntityTypeMap.js inconsistently handles the cacheTime property when updating entities. While new entities correctly receive a cacheTime, updates to existing entities or their fields do not update the timestamp. This leads to incorrect cache invalidation behavior since the cache policy relies on cacheTime to determine staleness.
Current Behavior
- New entities receive a
cacheTimestamp - Updates to existing query field entries do not update
cacheTime - New field entries in existing entities do not receive a
cacheTime
For example, the entry for "bar" never expires for the following data, since it doesn't contain a cacheTime.
{
"ROOT_QUERY.configurationByCanonical":{
"dataId":"ROOT_QUERY",
"typename":"Query",
"fieldName":"configurationByCanonical",
"storeFieldNames":{
"__size":2,
"entries":{
"configurationByCanonical("{ "canonical":"foo" }")":{
"variables":"undefined",
"args":"undefined"
"cacheTime": 1739268658057
},
"configurationByCanonical("{ "canonical":"bar" }")":{
"variables":"undefined",
"args":"undefined"
},
}
}
Expected Behavior
Every write operation should update the cacheTime to ensure accurate cache invalidation:
- New entities should receive a
cacheTime(currently working) - Updates to existing query field entries should update
cacheTime - New field entries in existing entities should receive a
cacheTime
Impact
This bug can cause cache entries to remain stale longer than intended (indefinitely), as the invalidation policy cannot accurately determine when the data was last updated.