Skip to content

Instantly share code, notes, and snippets.

@DuncanFaulkner
Created March 22, 2021 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DuncanFaulkner/05c8b5ae1f2c9385aa1889dae0bed09e to your computer and use it in GitHub Desktop.
Save DuncanFaulkner/05c8b5ae1f2c9385aa1889dae0bed09e to your computer and use it in GitHub Desktop.
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