Skip to content

Instantly share code, notes, and snippets.

@DuncanFaulkner

DuncanFaulkner/deleteupdate.ts Secret

Created Mar 22, 2021
Embed
What would you like to do?
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