Skip to content

Commit 5946dea

Browse files
committed
Optimistically update comments list with new comment
1 parent ec6d2ce commit 5946dea

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/Comment/CommentAdd/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,23 @@ class CommentAdd extends Component {
8080
<Mutation
8181
mutation={ADD_COMMENT}
8282
variables={{ body: value, subjectId: issue.id }}
83+
optimisticResponse={{
84+
addComment: {
85+
__typename: 'Mutation',
86+
commentEdge: {
87+
__typename: 'IssueCommentEdge',
88+
node: {
89+
__typename: 'IssueComment',
90+
id: new Date().getTime() + '',
91+
author: {
92+
__typename: 'User',
93+
login: 'me'
94+
},
95+
bodyHTML: value
96+
}
97+
}
98+
}
99+
}}
83100
update={(client, data) => updateComments({
84101
repositoryOwner,
85102
repositoryName,

0 commit comments

Comments
 (0)