Skip to content

Instantly share code, notes, and snippets.

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