Created
May 18, 2019 17:29
-
-
Save LazyFatArrow/bd68445c7782aa47ebd4e9e893d75221 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... 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