Skip to content

Commit 3a1ba3a

Browse files
committed
- Add author.id to optimisticResponse (#30)
1 parent 63ebf0a commit 3a1ba3a

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/components/ReviewForm.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import StarBorderIcon from 'material-ui-icons/StarBorder'
88
import gql from 'graphql-tag'
99
import { graphql, compose } from 'react-apollo'
1010
import classNames from 'classnames'
11+
import pick from 'lodash/pick'
1112

1213
import { validateReview } from '../lib/validators'
1314
import { REVIEWS_QUERY, REVIEW_ENTRY } from '../graphql/Review'
@@ -146,12 +147,13 @@ const withAddReview = graphql(ADD_REVIEW_MUTATION, {
146147
stars,
147148
createdAt: new Date(),
148149
favorited: false,
149-
author: {
150-
__typename: 'User',
151-
name: user.name,
152-
photo: user.photo,
153-
username: user.username
154-
}
150+
author: pick(user, [
151+
'__typename',
152+
'id',
153+
'name',
154+
'photo',
155+
'username'
156+
])
155157
}
156158
},
157159
update: (store, { data: { createReview: newReview } }) => {
@@ -198,4 +200,7 @@ const withEditReview = graphql(EDIT_REVIEW_MUTATION, {
198200
})
199201
})
200202

201-
export default compose(withAddReview, withEditReview)(ReviewForm)
203+
export default compose(
204+
withAddReview,
205+
withEditReview
206+
)(ReviewForm)

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)