Port RemoveCommentTag Mutation

This commit is contained in:
Chi Vinh Le
2017-05-09 02:22:44 +07:00
parent b87c36078a
commit 774a6f68ac
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,
withAddCommentTag, removeCommentTag, ignoreUser,
withAddCommentTag, withRemoveCommentTag, ignoreUser,
} from 'coral-framework/graphql/mutations';
import {notificationActions, authActions} from 'coral-framework';
import {editName} from 'coral-framework/actions/user';
@@ -243,7 +243,7 @@ export default compose(
withPostFlag,
withPostDontAgree,
withAddCommentTag,
removeCommentTag,
withRemoveCommentTag,
ignoreUser,
withDeleteAction,
)(StreamContainer);
@@ -3,6 +3,19 @@ import {registerConfig} from 'coral-framework/services/registry';
const config = {
fragments: {
RemoveCommentTagResponse: gql`
fragment CoralEmbedStream_RemoveCommentTagResponse on RemoveCommentTagResponse {
comment {
id
tags {
name
}
}
errors {
translation_key
}
}
`,
AddCommentTagResponse: gql`
fragment CoralEmbedStream_AddCommentTagResponse on AddCommentTagResponse {
comment {
@@ -1,5 +1,4 @@
import {graphql, gql} from 'react-apollo';
import REMOVE_COMMENT_TAG from './removeCommentTag.graphql';
import IGNORE_USER from './ignoreUser.graphql';
import STOP_IGNORING_USER from './stopIgnoringUser.graphql';
import withMutation from '../../hocs/withMutation';
@@ -96,17 +95,24 @@ export const withAddCommentTag = withMutation(
}}),
});
export const removeCommentTag = graphql(REMOVE_COMMENT_TAG, {
props: ({mutate}) => ({
removeCommentTag: ({id, tag}) => {
return mutate({
variables: {
id,
tag
}
});
}}),
});
export const withRemoveCommentTag = withMutation(
gql`
mutation RemoveCommentTag($id: ID!, $tag: String!) {
removeCommentTag(id:$id, tag:$tag) {
...RemoveCommentTagResponse
}
}
`, {
props: ({mutate}) => ({
removeCommentTag: ({id, tag}) => {
return mutate({
variables: {
id,
tag
}
});
}}),
});
// TODO: don't rely on refetching.
export const ignoreUser = graphql(IGNORE_USER, {
@@ -1,13 +0,0 @@
mutation RemoveCommentTag ($id: ID!, $tag: String!) {
removeCommentTag(id:$id, tag:$tag) {
comment {
id
tags {
name
}
}
errors {
translation_key
}
}
}