What keyFields value does Apollo Client v3 InMemoryCache use for objects without id or _id?
0 reputation · 18 Feb 2024, 10:40 UTC
I am configuring Apollo Client v3 InMemoryCache and need to know how cache identity is assigned when a normalized object has neither an id nor an _id field. The documented fallback chain suggests id first, then _id, then storage under the parent path only, but it is unclear whether a custom keyFields policy returning an empty array changes that fallback or produces an unstable key.
This matters for cache-first reads and writeFragment calls where server responses may omit identifiers for embedded entities. Version assumption: @apollo/client v3 with addTypename enabled by default.
Does an empty keyFields array fall back to id and _id, or does the object remain unnormalized? Which read path governs this behavior when the object appears nested inside another entity?