Closed lochawala closed 3 years ago
Hi @lochawala, this should solve your problem https://www.apollographql.com/docs/react/v2.6/caching/cache-interaction/#resetting-the-store
HI @morrys, Thanks, It's work's
HI @morrys
I have one another question how can i clear indexDB offline store data when it's successfully sync?
Please check attach screenshot for batter idea
Hi @lochawala, I didn't quite understand the question. When offline mutations are performed they are deleted from the offline store.
Hi @morrys Yes, it's an expected behaviour but in my case, it's not deleted from an offline store
Can you give me your offline options configuration?
client.setOfflineOptions({
manualExecution: false, // optional
link: link, //optional
start: async (mutations) => { //optional
console.log("start offline", mutations)
return mutations;
},
finish: async (mutations, error) => { //optional
console.log("finish offline", error, mutations)
},
onExecute: async (mutation) => { //optional
console.log("onExecute offline", mutation)
return mutation;
},
onComplete: async (options) => { //optional
console.log("onComplete offline", options)
onMutationCompleteHandler(client, options.response); // here in this function call client.writeQuery
},
onDiscard: async (options) => { //optional
console.log("onDiscard offline", options)
return true;
},
onPublish: async (offlinePayload) => { //optional
console.log("offlinePayload", offlinePayload)
return offlinePayload
}
});
The problem is in onComplete function. You must return true to delete mutation in offline store :)
Oh yes Thanks @morrys for pointing me out now it's work's
How can i clear IndexedDB when user logout or clear existing user data from indexDB and store new login user data?