Skip to content

Instantly share code, notes, and snippets.

View LazyFatArrow's full-sized avatar

Amenallah Hsoumi LazyFatArrow

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