Last active
February 22, 2020 18:39
-
-
Save seandearnaley/34cc8fb144cd55b6d91b92cfd94cca5d to your computer and use it in GitHub Desktop.
useRemoveCategory.ts old
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, { data }) => { | |
const { categories } = | |
cache.readQuery({ | |
query: GetCategoriesDocument, | |
}) || {}; | |
cache.writeQuery({ | |
query: GetCategoriesDocument, | |
data: { | |
categories: categories.filter( | |
(category: CategoryPartsFragment) => category.id !== id, | |
), | |
}, | |
}); | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment