-
-
Save DuncanFaulkner/05c8b5ae1f2c9385aa1889dae0bed09e to your computer and use it in GitHub Desktop.
update entire set
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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