Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ... imports
export default {
// ... queries
mutations: {
// ... createPoll
async voteOnPoll(parent, args) {
const poll = await pollService.voteOnPoll(args.optionId).catch();
pubsub.publish(OPTION_VOTED, {
[OPTION_VOTED]: poll.options.find((option) => {
return option._id.toString() === args.optionId
})
})
return poll
}
},
subscriptions: {
// ... poll create subscription
[OPTION_VOTED]: {
subscribe: () => pubsub.asyncIterator(OPTION_VOTED),
}
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.