Skip to content

Instantly share code, notes, and snippets.

@LazyFatArrow
Created May 18, 2019 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LazyFatArrow/bd68445c7782aa47ebd4e9e893d75221 to your computer and use it in GitHub Desktop.
Save LazyFatArrow/bd68445c7782aa47ebd4e9e893d75221 to your computer and use it in GitHub Desktop.
// ... 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