Currently there is no way to remove an item from a cache. This is a pretty common use case where we call a delete mutation, which returns with just a success bool or something, and we want to trigger watchers on other parts of the app which are showing lists which contain the deleted item.
Current workaround is to re-fetch the list which contained the item, but this tends to make code kind of messy and slow since we need to nest a fetch within a mutation and make sure they both succeed before allowing the user to continue.
I've implemented this in https://github.com/apollographql/apollo-ios/pull/361 which seems to work. Note that it's kind of slow since I need to search through the cache to find all references to a given key, but it's better than having to re-request the list (IMHO).
Thoughts?
Hi @ashiemke – we're looking for a way to remove (cascade delete) data from SQLiteNormalizedCache. This looks like it would help?
You mention above that it is slow. Slowness would be okay for us, but probably only if it is non blocking. I'm not clear if this deletion would block Apollo from performing other lookups in the cache?
Thank you.
Definitely something we need to look into
Most helpful comment
Definitely something we need to look into