Created
May 29, 2019 23:31
-
-
Save LazyFatArrow/a897248cf27fb278245cc1faeb51811a 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
<template> | |
<!-- ...html --> | |
</template> | |
<script> | |
// ... code | |
import { OPTION_VOTED, POLL_CREATED } from '@/gql/subscriptions/poll.subscriptions' | |
// ... code | |
export default { | |
// ... code | |
apollo: { | |
polls: { | |
query: POLLS, | |
subscribeToMore: [ | |
{ | |
document: OPTION_VOTED, | |
}, | |
{ | |
document: POLL_CREATED, | |
updateQuery(previousResult, { subscriptionData }) { | |
return { | |
polls: [ | |
subscriptionData.data.pollCreated, | |
...previousResult.polls, | |
] | |
} | |
} | |
} | |
] | |
} | |
}, | |
// ... code | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment