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> | |
</template> | |
<script> | |
import { POLLS } from '@/gql/queries/poll.queries' | |
export default { | |
apollo: { | |
polls: { | |
query: POLLS, |
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
import Vue from 'vue' | |
import Router from 'vue-router' | |
import Polls from './views/Polls.vue' | |
Vue.use(Router) | |
export default new Router({ | |
mode: 'history', | |
base: process.env.BASE_URL, |
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
import gql from 'graphql-tag' | |
export const POLLS = gql` | |
query Polls { | |
polls { | |
id | |
title | |
description | |
options { | |
id |
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
import Vue from 'vue' | |
import BootstrapVue from 'bootstrap-vue' | |
import App from './App.vue' | |
import router from './router' | |
import { createProvider } from './vue-apollo' | |
import 'bootstrap/dist/css/bootstrap.css' | |
import 'bootstrap-vue/dist/bootstrap-vue.css' |
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
type Subscription { | |
pollCreated: Poll | |
optionVoted: Option | |
} |
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(); |
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: { | |
async createPoll(parent, args) { | |
const poll = await pollService.create(args.poll).catch(); | |
pubsub.publish(POLL_CREATED, { |
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
export const POLL_CREATED = 'pollCreated' |
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
import { PubSub } from 'apollo-server' | |
import { POLL_CREATED } from '../events'; | |
import * as pollService from '../services/poll.service' | |
const pubsub = new PubSub() | |
export default { | |
// ... queries and mutations | |
subscriptions: { |
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
type Subscription { | |
pollCreated: Poll | |
} |