Skip to content

Instantly share code, notes, and snippets.

@martinseanhunt
Created October 23, 2018 00:52
Show Gist options
  • Save martinseanhunt/88514975f79da055d601175976045c00 to your computer and use it in GitHub Desktop.
Save martinseanhunt/88514975f79da055d601175976045c00 to your computer and use it in GitHub Desktop.
A helper function to delete paginated data from the Apollo cache
export default cache => {
// Loop through all the data in our cache
// And delete any items that start with "ListItem"
// This empties the cache of all of our list items and
// forces a refetch of the data.
Object.keys(cache.data.data).forEach(key =>
key.match(/^ListItem/) && cache.data.delete(key)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment