From 80d08bbe2e1787787a4cab77f71d3923939f43d1 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 9 May 2017 02:50:52 +0700 Subject: [PATCH] Port StopIgnoringUser Mutation --- .../coral-embed-stream/src/graphql/index.js | 14 ++++++++++ .../graphql/mutations/index.js | 26 +++++++++---------- .../mutations/stopIgnoringUser.graphql | 7 ----- .../containers/ProfileContainer.js | 4 +-- 4 files changed, 29 insertions(+), 22 deletions(-) delete mode 100644 client/coral-framework/graphql/mutations/stopIgnoringUser.graphql diff --git a/client/coral-embed-stream/src/graphql/index.js b/client/coral-embed-stream/src/graphql/index.js index 71d1f0924..66705c25a 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: { + StopIgnoringUserResponse: gql` + fragment CoralEmbedStream_StopIgnoringUserResponse on StopIgnoringUserResponse { + errors { + translation_key + } + } + `, IgnoreUserResponse: gql` fragment CoralEmbedStream_IgnoreUserResponse on IgnoreUserResponse { errors { @@ -107,6 +114,13 @@ const config = { 'EmbedQuery', 'myIgnoredUsers', ], }), + StopIgnoringUser: () => ({ + + // TODO: don't rely on refetching. + refetchQueries: [ + 'EmbedQuery', 'myIgnoredUsers', + ], + }), PostComment: ({ variables: {comment: {asset_id, body, parent_id, tags = []}}, state: {auth}, diff --git a/client/coral-framework/graphql/mutations/index.js b/client/coral-framework/graphql/mutations/index.js index 0c4a05f12..f43c68dc0 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 STOP_IGNORING_USER from './stopIgnoringUser.graphql'; +import {gql} from 'react-apollo'; import withMutation from '../../hocs/withMutation'; export const withPostComment = withMutation( @@ -131,20 +130,21 @@ export const withIgnoreUser = withMutation( }}), }); -// TODO: don't rely on refetching. -export const stopIgnoringUser = graphql(STOP_IGNORING_USER, { - props: ({mutate}) => { - return { +export const withStopIgnoringUser = withMutation( + gql` + mutation StopIgnoringUser($id: ID!) { + stopIgnoringUser(id:$id) { + ...StopIgnoringUserResponse + } + } + `, { + props: ({mutate}) => ({ stopIgnoringUser: ({id}) => { return mutate({ variables: { id, }, - refetchQueries: [ - 'EmbedQuery', 'myIgnoredUsers', - ] }); - } - }; - } -}); + }}), + }); + diff --git a/client/coral-framework/graphql/mutations/stopIgnoringUser.graphql b/client/coral-framework/graphql/mutations/stopIgnoringUser.graphql deleted file mode 100644 index 042452ff5..000000000 --- a/client/coral-framework/graphql/mutations/stopIgnoringUser.graphql +++ /dev/null @@ -1,7 +0,0 @@ -mutation stopIgnoringUser ($id: ID!) { - stopIgnoringUser(id:$id) { - errors { - translation_key - } - } -} diff --git a/client/coral-settings/containers/ProfileContainer.js b/client/coral-settings/containers/ProfileContainer.js index 39e615725..e289ff485 100644 --- a/client/coral-settings/containers/ProfileContainer.js +++ b/client/coral-settings/containers/ProfileContainer.js @@ -5,7 +5,7 @@ import I18n from 'coral-framework/modules/i18n/i18n'; import {bindActionCreators} from 'redux'; import {myCommentHistory, myIgnoredUsers} from 'coral-framework/graphql/queries'; -import {stopIgnoringUser} from 'coral-framework/graphql/mutations'; +import {withStopIgnoringUser} from 'coral-framework/graphql/mutations'; import {link} from 'coral-framework/services/PymConnection'; import NotLoggedIn from '../components/NotLoggedIn'; @@ -101,5 +101,5 @@ export default compose( connect(mapStateToProps, mapDispatchToProps), myCommentHistory, myIgnoredUsers, - stopIgnoringUser, + withStopIgnoringUser, )(ProfileContainer);