From 774a6f68ac38105cc4f832caf0b7b6c8bc7ee635 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 9 May 2017 02:22:44 +0700 Subject: [PATCH] Port RemoveCommentTag Mutation --- .../src/containers/Stream.js | 4 +-- .../coral-embed-stream/src/graphql/index.js | 13 ++++++++ .../graphql/mutations/index.js | 30 +++++++++++-------- .../mutations/removeCommentTag.graphql | 13 -------- 4 files changed, 33 insertions(+), 27 deletions(-) delete mode 100644 client/coral-framework/graphql/mutations/removeCommentTag.graphql diff --git a/client/coral-embed-stream/src/containers/Stream.js b/client/coral-embed-stream/src/containers/Stream.js index 4154a3a9a..08f3a1e1b 100644 --- a/client/coral-embed-stream/src/containers/Stream.js +++ b/client/coral-embed-stream/src/containers/Stream.js @@ -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); diff --git a/client/coral-embed-stream/src/graphql/index.js b/client/coral-embed-stream/src/graphql/index.js index e4db858b9..5e4943b1a 100644 --- a/client/coral-embed-stream/src/graphql/index.js +++ b/client/coral-embed-stream/src/graphql/index.js @@ -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 { diff --git a/client/coral-framework/graphql/mutations/index.js b/client/coral-framework/graphql/mutations/index.js index 602d00cc1..6407cf4a0 100644 --- a/client/coral-framework/graphql/mutations/index.js +++ b/client/coral-framework/graphql/mutations/index.js @@ -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, { diff --git a/client/coral-framework/graphql/mutations/removeCommentTag.graphql b/client/coral-framework/graphql/mutations/removeCommentTag.graphql deleted file mode 100644 index 3826b0703..000000000 --- a/client/coral-framework/graphql/mutations/removeCommentTag.graphql +++ /dev/null @@ -1,13 +0,0 @@ -mutation RemoveCommentTag ($id: ID!, $tag: String!) { - removeCommentTag(id:$id, tag:$tag) { - comment { - id - tags { - name - } - } - errors { - translation_key - } - } -}