Skip to content

Instantly share code, notes, and snippets.

@DuncanFaulkner
Created March 22, 2021 20:31
Embed
What would you like to do?
update entire set
const [mutate] = useMutation<
CompleteAllCourses.CompleteCourses
>(
COMPLETE_ALL_COURSES,
{
update (cache, { data }) {
const completedCourses = data?.completeAllCourses.courses;
const allCourses = cache.readQuery<GetAllCourses>({
query: GET_ALL_COURSES
});
cache.writeQuery({
query: GET_ALL_COURSES,
data: {
courses: allcourses.map((t) => !!completedCourses
.find((completed) => completed.id === t.id)
}
})
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment