Avoiding refetch from Community

This commit is contained in:
Belen Curcio
2017-12-11 11:37:35 -03:00
parent f005d1e5f8
commit 588c1c201c
2 changed files with 22 additions and 1 deletions
+22
View File
@@ -3,6 +3,28 @@ import {mapLeaves} from 'coral-framework/utils';
export default {
mutations: {
SetUserRole: ({variables: {id: userId, role}}) => ({
updateQueries: {
TalkAdmin_Community: (prev) => {
const updated = update(prev, {
users: {
nodes: {
$apply: (nodes) => nodes.map((node) => {
if (node.id === userId) {
node.role = role;
}
return node;
})
},
},
});
return updated;
}
}
}),
BanUser: ({variables: {input: {id: userId}}}) => ({
updateQueries: {
TalkAdmin_Community: (prev) => {
@@ -36,7 +36,6 @@ class PeopleContainer extends React.Component {
setUserRole = async (id, role) => {
await this.props.setUserRole(id, role);
await this.fetchUsers();
}
loadMore = () => {