I have a mutation that returns a new object that I want to add to an array of objects that is part of a graph in a parameterized root query. I have multiple root queries by the same name but have different parameters. I need to add the new “comment” object into comments array within the correct cached “post”. I searched and found apollo-augmented-hooks but I’m not sure how to use it, especially to add it to the array that is within that cached object.
commentsConnection:{"where":{"post":{"id":"05122322-e7e2-412e-9ad1-3013808b89f3"}}}
The “CommentsConnection” object for that key has a __typename and an “edges” array of “CommentEdge”. I want to add a new comment into that “edges” array:
commentsConnection:{"where":{"post":{"id":"05122322-e7e2-412e-9ad1-3013808b89f3"}}}:
{
"__typename": "CommentsConnection",
"edges": [
{
"__typename": "CommentEdge",
"node": {
"__ref": "Comment:d76c3549-daae-4ac0-bf4b-6a089f2c4346"
}
},
{
"__typename": "CommentEdge",
"node": {
"__ref": "Comment:af46fdf9-041b-4457-b255-28851cfd8879"
}
}
],
"pageInfo": {
"__typename": "PageInfo",
"endCursor": "YXJyYXljb25uZWN0aW9uOjI=",
"hasNextPage": true,
"hasPreviousPage": false,
"startCursor": ""
}
}
I attached a screenshot of my cache for reference.
I’m new to Apollo, so I really appreciate the help!