Complete graphql code refactor in framework

This commit is contained in:
Chi Vinh Le
2017-05-09 03:05:19 +07:00
parent 57e7396997
commit 028e13761f
8 changed files with 36 additions and 64 deletions
@@ -1,8 +0,0 @@
fragment actionSummaryView on ActionSummary {
__typename
count
current_user {
id
created_at
}
}
@@ -1,18 +0,0 @@
#import "../fragments/actionSummaryView.graphql"
fragment commentView on Comment {
id
body
created_at
status
tags {
name
}
user {
id
name: username
}
action_summaries {
...actionSummaryView
}
}
@@ -1,5 +1,5 @@
import {gql} from 'react-apollo';
import withMutation from '../../hocs/withMutation';
import withMutation from '../hocs/withMutation';
export const withPostComment = withMutation(
gql`
@@ -1,13 +0,0 @@
import {graphql} from 'react-apollo';
import MY_COMMENT_HISTORY from './myCommentHistory.graphql';
import MY_IGNORED_USERS from './myIgnoredUsers.graphql';
export const myCommentHistory = graphql(MY_COMMENT_HISTORY, {});
export const myIgnoredUsers = graphql(MY_IGNORED_USERS, {
props: ({data}) => {
return ({
myIgnoredUsersData: data
});
}
});
@@ -1,14 +0,0 @@
query myCommentHistory {
me {
comments {
id
body
asset {
id
title
url
}
created_at
}
}
}
@@ -1,6 +0,0 @@
query myIgnoredUsers {
myIgnoredUsers {
id,
username,
}
}
@@ -1,10 +1,9 @@
import {connect} from 'react-redux';
import {compose} from 'react-apollo';
import {compose, graphql, gql} from 'react-apollo';
import React, {Component} from 'react';
import I18n from 'coral-framework/modules/i18n/i18n';
import {bindActionCreators} from 'redux';
import {myCommentHistory, myIgnoredUsers} from 'coral-framework/graphql/queries';
import {withStopIgnoringUser} from 'coral-framework/graphql/mutations';
import {link} from 'coral-framework/services/PymConnection';
@@ -88,6 +87,38 @@ class ProfileContainer extends Component {
}
}
// TODO: These currently relies on refetching (see ignoreUser and stopIgnoringUser mutations).
//
const withMyIgnoredUsersQuery = graphql(gql`
query myIgnoredUsers {
myIgnoredUsers {
id,
username,
}
}`, {
props: ({data}) => {
return ({
myIgnoredUsersData: data
});
}
});
const withMyCommentHistoryQuery = graphql(gql`
query myCommentHistory {
me {
comments {
id
body
asset {
id
title
url
}
created_at
}
}
}`);
const mapStateToProps = state => ({
user: state.user.toJS(),
asset: state.asset.toJS(),
@@ -99,7 +130,7 @@ const mapDispatchToProps = dispatch =>
export default compose(
connect(mapStateToProps, mapDispatchToProps),
myCommentHistory,
myIgnoredUsers,
withMyCommentHistoryQuery,
withMyIgnoredUsersQuery,
withStopIgnoringUser,
)(ProfileContainer);