Port AddCommentTag Mutation

This commit is contained in:
Chi Vinh Le
2017-05-09 02:19:55 +07:00
parent 0e931d023d
commit b87c36078a
4 changed files with 33 additions and 27 deletions
@@ -8,7 +8,7 @@ import isNil from 'lodash/isNil';
import {NEW_COMMENT_COUNT_POLL_INTERVAL} from '../constants/stream';
import {
withPostComment, withPostFlag, withPostDontAgree, withDeleteAction,
addCommentTag, removeCommentTag, ignoreUser,
withAddCommentTag, removeCommentTag, ignoreUser,
} from 'coral-framework/graphql/mutations';
import {notificationActions, authActions} from 'coral-framework';
import {editName} from 'coral-framework/actions/user';
@@ -242,7 +242,7 @@ export default compose(
withPostComment,
withPostFlag,
withPostDontAgree,
addCommentTag,
withAddCommentTag,
removeCommentTag,
ignoreUser,
withDeleteAction,
@@ -3,6 +3,19 @@ import {registerConfig} from 'coral-framework/services/registry';
const config = {
fragments: {
AddCommentTagResponse: gql`
fragment CoralEmbedStream_AddCommentTagResponse on AddCommentTagResponse {
comment {
id
tags {
name
}
}
errors {
translation_key
}
}
`,
DeleteActionResponse: gql`
fragment CoralEmbedStream_DeleteActionResponse on DeleteActionResponse {
errors {
@@ -1,13 +0,0 @@
mutation AddCommentTag ($id: ID!, $tag: String!) {
addCommentTag(id:$id, tag:$tag) {
comment {
id
tags {
name
}
}
errors {
translation_key
}
}
}
@@ -1,5 +1,4 @@
import {graphql, gql} from 'react-apollo';
import ADD_COMMENT_TAG from './addCommentTag.graphql';
import REMOVE_COMMENT_TAG from './removeCommentTag.graphql';
import IGNORE_USER from './ignoreUser.graphql';
import STOP_IGNORING_USER from './stopIgnoringUser.graphql';
@@ -78,17 +77,24 @@ export const withDeleteAction = withMutation(
}}),
});
export const addCommentTag = graphql(ADD_COMMENT_TAG, {
props: ({mutate}) => ({
addCommentTag: ({id, tag}) => {
return mutate({
variables: {
id,
tag
}
});
}}),
});
export const withAddCommentTag = withMutation(
gql`
mutation AddCommentTag($id: ID!, $tag: String!) {
addCommentTag(id:$id, tag:$tag) {
...AddCommentTagResponse
}
}
`, {
props: ({mutate}) => ({
addCommentTag: ({id, tag}) => {
return mutate({
variables: {
id,
tag
}
});
}}),
});
export const removeCommentTag = graphql(REMOVE_COMMENT_TAG, {
props: ({mutate}) => ({