Created
October 23, 2018 00:52
-
-
Save martinseanhunt/88514975f79da055d601175976045c00 to your computer and use it in GitHub Desktop.
A helper function to delete paginated data from the Apollo cache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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