-
-
Save DuncanFaulkner/57a6c3120a51bee911e226a88df5dd5e to your computer and use it in GitHub Desktop.
add update
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
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