Last active
February 22, 2020 18:40
-
-
Save seandearnaley/68325da7533459fed9337eaf2fc851fe to your computer and use it in GitHub Desktop.
useRemoveCategory.ts beta 36
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
const removeCategory = (id: string) => | |
removeCategoryMutation({ | |
variables: { | |
id, | |
}, | |
update: cache => { | |
cache.modify('ROOT_QUERY', { | |
categories(categories: Reference[], { readField }) { | |
return categories.filter( | |
category => id !== readField('id', category), | |
); | |
}, | |
}); | |
// evict this item from the in memory cache | |
cache.evict(`Category:${id}`); | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment