Refactor subscriptions

This commit is contained in:
Chi Vinh Le
2017-06-16 22:55:22 +07:00
parent 9573c9a7af
commit 74fbadcc0f
5 changed files with 79 additions and 19 deletions
+9 -2
View File
@@ -348,8 +348,15 @@ const setStatus = async ({user, loaders: {Comments}, pubsub}, {id, status}) => {
if (pubsub) {
// Publish the comment status change via the subscription.
pubsub.publish('commentStatusChanged', comment);
if (status === 'ACCEPTED') {
// Publish the comment status change via the subscription.
pubsub.publish('commentAccepted', comment);
} else if (status === 'REJECTED') {
// Publish the comment status change via the subscription.
pubsub.publish('commentRejected', comment);
}
}
return comment;