Port StopIgnoringUser Mutation

This commit is contained in:
Chi Vinh Le
2017-05-09 02:50:52 +07:00
parent 5c44922d2b
commit 80d08bbe2e
4 changed files with 29 additions and 22 deletions
@@ -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},
@@ -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',
]
});
}
};
}
});
}}),
});
@@ -1,7 +0,0 @@
mutation stopIgnoringUser ($id: ID!) {
stopIgnoringUser(id:$id) {
errors {
translation_key
}
}
}
@@ -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);