Merge branch 'master' into prop-types

This commit is contained in:
Kim Gardner
2017-09-08 10:56:35 +01:00
committed by GitHub
35 changed files with 498 additions and 166 deletions
@@ -109,7 +109,7 @@ export default {
},
mutations: {
PostComment: ({
variables: {comment: {asset_id, body, parent_id, tags = []}},
variables: {input: {asset_id, body, parent_id, tags = []}},
state: {auth},
}) => ({
optimisticResponse: {
@@ -6,6 +6,7 @@ export default {
'SetCommentStatusResponse',
'SuspendUserResponse',
'RejectUsernameResponse',
'CreateCommentResponse',
'SetUserStatusResponse',
'CreateFlagResponse',
'EditCommentResponse',
+4 -4
View File
@@ -192,17 +192,17 @@ export const withSetUserStatus = withMutation(
export const withPostComment = withMutation(
gql`
mutation PostComment($comment: CreateCommentInput!) {
createComment(comment: $comment) {
mutation PostComment($input: CreateCommentInput!) {
createComment(input: $input) {
...CreateCommentResponse
}
}
`, {
props: ({mutate}) => ({
postComment: (comment) => {
postComment: (input) => {
return mutate({
variables: {
comment
input
},
});
}
+1 -1
View File
@@ -109,7 +109,7 @@ export function mergeDocuments(documents) {
export function getResponseErrors(mutationResult) {
const result = [];
Object.keys(mutationResult.data).forEach((response) => {
const errors = mutationResult.data[response].errors;
const errors = mutationResult.data[response] && mutationResult.data[response].errors;
if (errors && errors.length) {
result.push(...errors);
}
+3 -3
View File
@@ -55,7 +55,7 @@ class CommentBox extends React.Component {
return;
}
let comment = {
let input = {
asset_id: assetId,
parent_id: parentId,
body: this.state.body,
@@ -63,10 +63,10 @@ class CommentBox extends React.Component {
};
// Execute preSubmit Hooks
this.state.hooks.preSubmit.forEach((hook) => hook());
this.state.hooks.preSubmit.forEach((hook) => hook(input));
this.setState({loadingState: 'loading'});
postComment(comment, 'comments')
postComment(input, 'comments')
.then(({data}) => {
this.setState({loadingState: 'success', body: ''});
const postedComment = data.createComment.comment;