Apollo-ios: Cannot invalidate cache items

Created on 31 Aug 2018  Â·  2Comments  Â·  Source: apollographql/apollo-ios

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?

caching

Most helpful comment

Definitely something we need to look into

All 2 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

designatednerd picture designatednerd  Â·  3Comments

AnthonyMDev picture AnthonyMDev  Â·  4Comments

dchohfi picture dchohfi  Â·  4Comments

maxsz picture maxsz  Â·  4Comments

marcoreni picture marcoreni  Â·  3Comments