Description
We are in a react native app and need to persist the api data to make it possible to use the app when being offline.
After fetching the data with a query, a graphql subscription is established to get streaming updates from the api, which will only deliver incremental changes.
I did implement this as described in the docs via onCacheEntryCreated
and update the local cache accordingly with updateCachedData
and this works fine for the very initial load when the store is completely empty.
But unfortunately as we persist the data, this will only be called once. When the app restarts and data gets rehydrated, the subscription will no longer trigger.
I think this is by design but really unfortunate in our scenario.
What we basically want is
- call the query every time the app restarts, gets in focus or reconnects to the internet. (This is somewhat working now)
- connect the graphql subscription when the first call succeeds.
How would you deal with this scenario?
Sidenote
I also followed your docs about Persistance and Rehydration and added the extractRehydrationInfo
as described, but I am not quite sure what this does, as the whole redux state is rehydrated anyway including the whole api slice.
Though we are not using redux-persist
but redux-storage, but I don't think this should matter.
We do not persist the subscriptions
object in the api slice though, since this causes a memory leak increasing cache subscriptions with every restart and refetchOnMountOrArgChange
not working properly.