Skip to content

Instantly share code, notes, and snippets.

@LazyFatArrow
Created May 29, 2019 23:31
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/a897248cf27fb278245cc1faeb51811a to your computer and use it in GitHub Desktop.
Save LazyFatArrow/a897248cf27fb278245cc1faeb51811a to your computer and use it in GitHub Desktop.
<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