You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wiki/server/graph/resolvers/page.js

61 lines
1.6 KiB

const graphHelper = require('../../helpers/graph')
/* global WIKI */
module.exports = {
Query: {
async pages() { return {} }
},
Mutation: {
async pages() { return {} }
},
PageQuery: {
async list(obj, args, context, info) {
6 years ago
return WIKI.db.pages.query().select(
'pages.*',
WIKI.db.pages.relatedQuery('users').count().as('userCount')
)
},
async single(obj, args, context, info) {
6 years ago
return WIKI.db.pages.query().findById(args.id)
}
},
PageMutation: {
6 years ago
async create(obj, args, context) {
const page = await WIKI.db.pages.query().insertAndFetch({
path: args.path,
title: args.title,
description: args.description,
isPrivate: false,
isPublished: args.isPublished,
publishStartDate: args.publishStartDate,
publishEndDate: args.publishEndDate,
localeCode: args.locale,
editorKey: args.editor,
authorId: context.req.user.id
})
return {
6 years ago
responseResult: graphHelper.generateSuccess('Page created successfully.'),
page
}
},
async delete(obj, args) {
await WIKI.db.groups.query().deleteById(args.id)
return {
6 years ago
responseResult: graphHelper.generateSuccess('Page has been deleted.')
}
},
async update(obj, args) {
await WIKI.db.groups.query().patch({ name: args.name }).where('id', args.id)
return {
6 years ago
responseResult: graphHelper.generateSuccess('Page has been updated.')
}
}
},
Page: {
// comments(pg) {
// return pg.$relatedQuery('comments')
// }
}
}