Commit 5d714341 authored by Adam Soffer's avatar Adam Soffer Committed by Tim Neutkens

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
parent b7de7a57
...@@ -33,6 +33,7 @@ const upvotePost = gql` ...@@ -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, { ...@@ -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
} }
......
...@@ -33,6 +33,7 @@ const upvotePost = gql` ...@@ -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, { ...@@ -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
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment