In an Apollo based Webapp, the user is provided the functionality to change the identifier of an entity - that’s the 'id` identifier filed in graphql defs - using a server api.
At the moment of that operation, current Apollo in-memory-cache already contains a number of references about the updating-id-entity in many contexts:
- main cached entity reference (at root of
- various references in different other entities (via
all those references would brake, as well as any query watch involving the updating-entity-id
Query watching issues can be resolved applicatively.
about the cache, I didn’t find any built-in feature for this use-case,
so I was wondering if I could manage that manually…
I would manually modify the
cache.data.data object :
- clone the top-level entity renaming the top level prop-name accordingly to the new id
- delete the original
- scan the whole cache obj for any
__refand change the value accordingly
Any issue with this approach?
am I missing somenthin?
how likely a future lib upgrade may brake-change?
is there a cleaner approach?