Skip to content

Commit 8d08c31

Browse files
committed
- Add author.id to optimisticResponse (#30)
1 parent 8c65120 commit 8d08c31

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/components/AddReview.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import StarIcon from 'material-ui-icons/Star'
77
import StarBorderIcon from 'material-ui-icons/StarBorder'
88
import gql from 'graphql-tag'
99
import { graphql } from 'react-apollo'
10+
import pick from 'lodash/pick'
1011

1112
import { validateReview } from '../lib/validators'
1213
import { REVIEWS_QUERY, REVIEW_ENTRY } from '../graphql/Review'
@@ -125,12 +126,13 @@ const withMutation = graphql(ADD_REVIEW_MUTATION, {
125126
stars,
126127
createdAt: new Date(),
127128
favorited: false,
128-
author: {
129-
__typename: 'User',
130-
name: user.name,
131-
photo: user.photo,
132-
username: user.username
133-
}
129+
author: pick(user, [
130+
'__typename',
131+
'id',
132+
'name',
133+
'photo',
134+
'username'
135+
])
134136
}
135137
},
136138
update: (store, { data: { createReview: newReview } }) => {

src/lib/withAuth.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ initAuthHelpers({
3232
const USER_QUERY = gql`
3333
query UserQuery {
3434
currentUser {
35+
id
3536
firstName
3637
name
3738
username

0 commit comments

Comments
 (0)