Skip to content

Instantly share code, notes, and snippets.

@DuncanFaulkner
Created March 22, 2021 20:41
Embed
What would you like to do?
add update
ADD_COURSE,
{
update (cache, { data }) {
const newCourseFromResponse = data?.addCourse.course;
const existingCourses = cache.readQuery<GetAllCourses>({
query: GET_ALL_COURSES,
});
if (existingCourses && newCourseFromResponse) {
cache.writeQuery({
query: GET_ALL_COURSES,
data: {
toCourses: [
...existingCourses?.courses,
newCourseFromResponse,
],
},
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment