Open madmax141 opened 4 years ago
For anyone also experiencing this and wanting to be sure the cache is 100% cleared, the workaround i've discovered is directly mutation the redux store of appsync, then calling clearStore
. this ensures that the metadata info doesn't get rehydrated and you have a truly clear cache. Directly mutating a redux store definitely isn't ideal so it would still be nice to have an official solution to this
apolloClient.store.cache.store.getState()['appsync-metadata'].snapshot.cache = {}
apolloClient.clearStore()
There seems to be a bug in the implementation of clearStore. through normal use of my application, the
appsync-metadata
key inlocalStorage
eventually becomes populated with a snapshot (apparent copy) of the cache (this appears to happen after an arbitrary mutation). However, when callingclearStore
on the apollo client, which I do when logging out, this snapshot remains while theappsync
key is correctly cleared.I would expect the
appsync-metadata
key to be also cleared when callingclearStore
, I cannot find any way to set theappsync-metadata
key to its initial state, but its very important for me to clear all cache data when users log out.using the latest version of appsync (4.0.1), but also this failed with previous major versions. this happens in all major browsers.
NOTE: i'm not sure if this is intended behavior or not, I would be curious to know why, if thats the case
State when first logging in:
State when a mutation is made, note the snapshot key in appsync-metadata having the
cache
key populatedState after calling
clearStore
on the apollo client, noteappsync
storage key is correctly set to an empty object however theappsync-metadata
key remains unchanged, with the cache object still populated: