Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop treating dangling references differently from empty objects. (#6365
) Question: When cache.read{Query,Fragment} encounters a dangling reference (one that does not currently refer to any normalized entity object in the cache), should the cache behave as if the (nonexistent) target of the reference was an empty object, and report any requested fields as missing, or should the cache generate some other kind of error that reflects the the absence of the whole object? I think we could answer this question either way, but I'm leaning towards the first option. Note: it's normal for the cache to end up with dangling references when whole entity objects are evicted, or when a reference is created (e.g. by toReference) without writing any data into the cache. Cleaning up dangling references is a tricky problem, requiring application-level reasoning, and not even always desirable, since the data could always come back into the cache later, restoring the validity of the reference. Previously, I thought it would be helpful to distinguish between the absence of an entity object and the object simply being empty, but I no longer think this distinction (which only affected the wording of the MissingFieldError description) matters very much, and we can simplify everything by adopting the following policy: > During cache reads, a dangling Reference should behave as much as possible like a Reference to an entity object that happens to contain zero fields. I'm optimistic this policy may help with issues like #6325. At the very least, this policy means there's now only one flavor of MissingFieldError, which should reduce confusion.
- Loading branch information