-
Notifications
You must be signed in to change notification settings - Fork 749
Description
Question
Currently, SchemaConfiguration.cacheKeyInfo supports returning only a single CacheKeyInfo instance per object. As a result, each object can be cached using only one cache key. This works perfectly fine when reading cached objects using ApolloStore.withinReadTransaction { transaction in transaction.readObject(...) }
However, would it be possible to somehow support multiple cache keys per object?
I’ve experimented with a custom NormalizedCache that manually splits and joins the cache key strings to work around this limitation, but the approach feels like a hack and is not reliable at all.
Background
In our GraphQL schema some models have multiple unique identifiers. For example, a User has both an id and an urn. Due to legacy reasons, different parts of our application reference users by either id or urn.
Because the cache can only recognize one of these keys, we often have cache misses. This forces us to query the GraphQL endpoint even though technically the User object does exist in the cache.