update(cache, { data }) {
cache.modify({
fields: {
getCommentsByPostId(existingComments = []) {
if (data.comment) {
return [data.comment, ...existingComments]
}
return existingComments
},
},
})
cache.modify({
// find the ID
id: cache.identify({ id: data.comment.postId, __typename: 'Post' }),
// update the fields you need to
fields: {
commentCount(oldCount, { readField, toReference }) {
return oldCount + 1
},
},
})
},
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (1)
Hello ! Don't hesitate to put colors on your
codeblock
like this example for have to have a better understanding of your code 😎