stacker.news/api/resolvers/admin.js

19 lines
457 B
JavaScript

export default {
Query: {
snl: async (parent, _, { models }) => {
const { live } = await models.snl.findFirst()
return live
}
},
Mutation: {
onAirToggle: async (parent, _, { models, me }) => {
if (me.id !== 616) {
throw new Error('not an admin')
}
const { id, live } = await models.snl.findFirst()
await models.snl.update({ where: { id }, data: { live: !live } })
return !live
}
}
}