Skip to content

Instantly share code, notes, and snippets.

@DuncanFaulkner
Created March 22, 2021 20:37
Show Gist options
  • Save DuncanFaulkner/e3f4fac2a17ce6aa01c480bb191c8b73 to your computer and use it in GitHub Desktop.
Save DuncanFaulkner/e3f4fac2a17ce6aa01c480bb191c8b73 to your computer and use it in GitHub Desktop.
delete
DELETE_COURSE,
{
update (cache, el) {
const deletedId = el.data?.deleteCourse.course?.id
const allCourses = cache.readQuery<GetAllCourses>({ query: GET_ALL_COURSES });
cache.writeQuery({
query: GET_ALL_COURSES,
data: {
todos: allCourses?.courses.filter((t) => t?.id !== deletedId)
}
});
cache.evict({ id: el.data?.deleteCourse.course?.id })
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment