Skip to content

Instantly share code, notes, and snippets.

@seandearnaley
Last active February 22, 2020 18:39
Show Gist options
  • Save seandearnaley/34cc8fb144cd55b6d91b92cfd94cca5d to your computer and use it in GitHub Desktop.
Save seandearnaley/34cc8fb144cd55b6d91b92cfd94cca5d to your computer and use it in GitHub Desktop.
useRemoveCategory.ts old
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