Read/Write Fragments to update the cache

This commit is contained in:
Belen Curcio
2017-09-11 13:57:24 -03:00
parent a22ee3fefe
commit 06c45faeb0
@@ -7,6 +7,7 @@ import reducer from './reducer';
import ModTag from './containers/ModTag';
import ModActionButton from './containers/ModActionButton';
import ModSubscription from './containers/ModSubscription';
import {gql} from 'react-apollo';
import {findCommentInEmbedQuery} from 'coral-embed-stream/src/graphql/utils';
import {prependNewNodes} from 'plugin-api/beta/client/utils';
@@ -84,8 +85,28 @@ export default {
}
return updated;
},
}
}
},
update: (proxy) => {
if (name !== 'FEATURED') {
return;
}
const fragmentId = `Comment_${variables.id}`;
const fragment = gql`
fragment Talk_ModerationActions_addTag on Comment {
status
}
`;
const data = proxy.readFragment({fragment, id: fragmentId});
data.status = 'ACCEPTED';
proxy.writeFragment({fragment, id: fragmentId, data});
},
}),
RemoveTag: ({variables}) => ({
updateQueries: {