Fix Apollo mutations update hooks to follow the immutability patters
In Apollo 2.6 there is a new option available helping us to enforce the immutability on update
hooks. I.e. instead of
data.comments.push(newComment);
client.writeQuery({
query: CommentQuery,
data,
});
we should have
client.writeQuery({
query: CommentQuery,
data: {
...data,
comments: [
...data.comments,
newComment,
],
},
});
The reasoning behind following an immutability pattern is explained in this article