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 Poll from '../models/poll.model' | |
export function create(data) { | |
return Poll.create(data) | |
} | |
export function findAll() { | |
return Poll.find().sort({ createdAt: -1 }) | |
} |
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 * as pollService from '../services/poll.service' | |
export default { | |
queries: { | |
polls() { | |
return pollService.findAll().catch() | |
} | |
}, | |
mutations: { |
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 Mutation { | |
createPoll(poll: CreatePollInput): Poll | |
voteOnPoll(optionId: ID!): Poll | |
} | |
input CreatePollInput { | |
title: String! | |
description: String! | |
options: [CreateOptionInput] | |
} |
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 Poll from '../models/poll.model' | |
export function create(data) { | |
return Poll.create(data) | |
} | |
export function findAll() { | |
return Poll.find().sort({ createdAt: -1 }) | |
} |
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 * as pollService from '../services/poll.service' | |
export default { | |
queries: { | |
polls() { | |
return pollService.findAll().catch() | |
} | |
}, | |
mutations: { |
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 Poll from '../models/poll.model' | |
export function create(data) { | |
return Poll.create(data) | |
} |
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 * as pollService from '../services/poll.service' | |
export default { | |
queries: {}, | |
mutations: { | |
createPoll(parent, args) { | |
return pollService.create(args.poll).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
type Mutation { | |
createPoll(poll: CreatePollInput): Poll | |
} | |
input CreatePollInput { | |
title: String! | |
description: String! | |
options: [CreateOptionInput] | |
} |
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 * as pollService from '../services/poll.service' | |
export default { | |
queries: { | |
polls: () => pollService.findAll() | |
}, | |
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 Query { | |
polls: [Poll] | |
} |