From 0e931d023dc93989170eb9b852b9bea7a1af1184 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 9 May 2017 01:15:07 +0700 Subject: [PATCH] Port DeleteAction Mutation --- .../src/containers/Stream.js | 7 +++-- .../coral-embed-stream/src/graphql/index.js | 7 +++++ .../graphql/mutations/deleteAction.graphql | 7 ----- .../graphql/mutations/index.js | 28 +++++++++++-------- 4 files changed, 29 insertions(+), 20 deletions(-) delete mode 100644 client/coral-framework/graphql/mutations/deleteAction.graphql diff --git a/client/coral-embed-stream/src/containers/Stream.js b/client/coral-embed-stream/src/containers/Stream.js index 9b01ee439..913d894f3 100644 --- a/client/coral-embed-stream/src/containers/Stream.js +++ b/client/coral-embed-stream/src/containers/Stream.js @@ -6,7 +6,10 @@ import uniqBy from 'lodash/uniqBy'; import sortBy from 'lodash/sortBy'; import isNil from 'lodash/isNil'; import {NEW_COMMENT_COUNT_POLL_INTERVAL} from '../constants/stream'; -import {withPostComment, withPostFlag, withPostDontAgree, deleteAction, addCommentTag, removeCommentTag, ignoreUser} from 'coral-framework/graphql/mutations'; +import { + withPostComment, withPostFlag, withPostDontAgree, withDeleteAction, + addCommentTag, removeCommentTag, ignoreUser, +} from 'coral-framework/graphql/mutations'; import {notificationActions, authActions} from 'coral-framework'; import {editName} from 'coral-framework/actions/user'; import {setCommentCountCache, setActiveReplyBox} from '../actions/stream'; @@ -242,6 +245,6 @@ export default compose( addCommentTag, removeCommentTag, ignoreUser, - deleteAction, + withDeleteAction, )(StreamContainer); diff --git a/client/coral-embed-stream/src/graphql/index.js b/client/coral-embed-stream/src/graphql/index.js index e71eef1cb..001c953f9 100644 --- a/client/coral-embed-stream/src/graphql/index.js +++ b/client/coral-embed-stream/src/graphql/index.js @@ -3,6 +3,13 @@ import {registerConfig} from 'coral-framework/services/registry'; const config = { fragments: { + DeleteActionResponse: gql` + fragment CoralEmbedStream_DeleteActionResponse on DeleteActionResponse { + errors { + translation_key + } + } + `, CreateFlagResponse: gql` fragment CoralEmbedStream_CreateFlagResponse on CreateFlagResponse { flag { diff --git a/client/coral-framework/graphql/mutations/deleteAction.graphql b/client/coral-framework/graphql/mutations/deleteAction.graphql deleted file mode 100644 index f8adf371c..000000000 --- a/client/coral-framework/graphql/mutations/deleteAction.graphql +++ /dev/null @@ -1,7 +0,0 @@ -mutation deleteAction ($id: ID!) { - deleteAction(id:$id) { - errors { - translation_key - } - } -} diff --git a/client/coral-framework/graphql/mutations/index.js b/client/coral-framework/graphql/mutations/index.js index e758d2dfa..1d8e3a081 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 DELETE_ACTION from './deleteAction.graphql'; import ADD_COMMENT_TAG from './addCommentTag.graphql'; import REMOVE_COMMENT_TAG from './removeCommentTag.graphql'; import IGNORE_USER from './ignoreUser.graphql'; @@ -61,16 +60,23 @@ export const withPostDontAgree = withMutation( }}), }); -export const deleteAction = graphql(DELETE_ACTION, { - props: ({mutate}) => ({ - deleteAction: (id) => { - return mutate({ - variables: { - id - } - }); - }}), -}); +export const withDeleteAction = withMutation( + gql` + mutation DeleteAction($id: ID!) { + deleteAction(id:$id) { + ...DeleteActionResponse + } + } + `, { + props: ({mutate}) => ({ + deleteAction: (id) => { + return mutate({ + variables: { + id + } + }); + }}), + }); export const addCommentTag = graphql(ADD_COMMENT_TAG, { props: ({mutate}) => ({