Skip to content

Instantly share code, notes, and snippets.

@LazyFatArrow
Created May 29, 2019 23:03
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/8585888ea0a28bbb19ad2b083ca92349 to your computer and use it in GitHub Desktop.
Save LazyFatArrow/8585888ea0a28bbb19ad2b083ca92349 to your computer and use it in GitHub Desktop.
<template>
<b-container class="my-5">
<b-row>
<b-col>
<CreatePollModal
@createPoll="handleCreatePoll"
/>
</b-col>
</b-row>
<b-row class="mt-3" v-if="polls && polls.length">
<b-col>
<b-card-group columns>
<SinglePoll
v-for="poll in polls"
@optionVote="handleOptionVote"
:key="`poll-${poll.id}`"
:poll="poll"
/>
</b-card-group>
</b-col>
</b-row>
</b-container>
</template>
<script>
import { POLLS } from '@/gql/queries/poll.queries'
import { VOTE_ON_POLL, CREATE_POLL } from '@/gql/mutations/poll.mutations'
import { OPTION_VOTED, POLL_CREATED } from '@/gql/subscriptions/poll.subscriptions'
import SinglePoll from '@/components/SinglePoll.vue'
import CreatePollModal from '@/components/CreatePollModal.vue'
export default {
// ... code
methods: {
// ... code
handleCreatePoll(pollForm) {
this.$apollo.mutate({
mutation: CREATE_POLL,
variables: {
poll: pollForm,
},
})
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment