react-graphql-github-apollo icon indicating copy to clipboard operation
react-graphql-github-apollo copied to clipboard

Show new comment in UI

Open johnnyoshika opened this issue 6 years ago • 1 comments

When a new comment is added, it now displays in the UI. It uses optimistic UI to immediately render the new comment, then updates based on the GraphQL mutation response. This fulfills this exercise:

https://www.robinwieruch.de/react-graphql-apollo-tutorial#exercise-commenting-feature

Improve the AddComment component with the optimistic UI feature (perhaps read again the Apollo documentation about the optimistic UI with a list of items). A comment should show up in the list of comments, even if the request is pending.

Known issues

Missing author.login

The author's login isn't being fetched, so during the optimistic UI rendering and before the server responds to the addComment mutation, the author's login is displayed as me.

During optimistic UI:

image

After server response

image


Paginating after new comment insertion

Update 2020-01-18: this has been fixed. See comment below. When paginating after a new comment is inserted, and when the newly inserted comment returns from the server through pagination, this results in an ID conflict: image This also results in a duplicate comment, even through they have the same ID.

To reproduce:

  • Insert a new comment
  • Keep clicking More Comments until the newly inserted comment appears a second time

Can you please suggest how we can remedy this problem?

johnnyoshika avatar Jan 11 '20 04:01 johnnyoshika

Note: the pagination problem after a new comment is added has been fixed with this commit: https://github.com/the-road-to-graphql/react-graphql-github-apollo/pull/29/commits/b20e7a133c9e56a63e7fb537bafaf4c2285fd7d1

johnnyoshika avatar Jan 18 '20 20:01 johnnyoshika