1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Remove warning when upvoting a post in apollo examples (#2190)

* Fix apollo warning and error when upvoting post

* Fix apollo warning and error when upvoting post in apollo-redux example as well
This commit is contained in:
Adam Soffer 2017-06-08 13:26:40 -04:00 committed by Tim Neutkens
parent b7de7a5733
commit 5d71434121
2 changed files with 6 additions and 0 deletions

View file

@ -33,6 +33,7 @@ const upvotePost = gql`
mutation updatePost($id: ID!, $votes: Int) { mutation updatePost($id: ID!, $votes: Int) {
updatePost(id: $id, votes: $votes) { updatePost(id: $id, votes: $votes) {
id id
__typename
votes votes
} }
} }
@ -43,7 +44,9 @@ export default graphql(upvotePost, {
upvote: (id, votes) => mutate({ upvote: (id, votes) => mutate({
variables: { id, votes }, variables: { id, votes },
optimisticResponse: { optimisticResponse: {
__typename: 'Mutation',
updatePost: { updatePost: {
__typename: 'Post',
id: ownProps.id, id: ownProps.id,
votes: ownProps.votes + 1 votes: ownProps.votes + 1
} }

View file

@ -33,6 +33,7 @@ const upvotePost = gql`
mutation updatePost($id: ID!, $votes: Int) { mutation updatePost($id: ID!, $votes: Int) {
updatePost(id: $id, votes: $votes) { updatePost(id: $id, votes: $votes) {
id id
__typename
votes votes
} }
} }
@ -43,7 +44,9 @@ export default graphql(upvotePost, {
upvote: (id, votes) => mutate({ upvote: (id, votes) => mutate({
variables: { id, votes }, variables: { id, votes },
optimisticResponse: { optimisticResponse: {
__typename: 'Mutation',
updatePost: { updatePost: {
__typename: 'Post',
id: ownProps.id, id: ownProps.id,
votes: ownProps.votes + 1 votes: ownProps.votes + 1
} }