Skip to content

Instantly share code, notes, and snippets.

@DuncanFaulkner

DuncanFaulkner/addupdate.ts Secret

Created Mar 22, 2021
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