Im using update after a mutation to update the store when a new comment is created. I also have a subscription for comments on this page.
Either one of these methods works as expected by itself. However when I have both, then the user who created the comment will see the comment on the page twice and get this error from React:
Warning: Encountered two children with the same key,
I think the reason for this is the mutation update and the subscription both return a new node, creating a duplicate entry. Is there a recommended solution to this? I couldn’t see anything in the docs but it doesn’t seem like an edge use case to me.
I could alter my subscription to ignore new comments if they are from the currently logged in user. Im surprised this is required though as I thought Apollo would figure this out. Maybe the batching means that the duplicates are returned at exactly the same time and thats whats confusing it?