mirror of https://github.com/requarks/wiki
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.
52 lines
1.3 KiB
52 lines
1.3 KiB
7 years ago
|
const graphHelper = require('../../helpers/graph')
|
||
|
|
||
|
/* global WIKI */
|
||
|
|
||
|
module.exports = {
|
||
|
Query: {
|
||
|
async pages() { return {} }
|
||
|
},
|
||
|
Mutation: {
|
||
|
async pages() { return {} }
|
||
|
},
|
||
|
PageQuery: {
|
||
|
async list(obj, args, context, info) {
|
||
|
return WIKI.db.groups.query().select(
|
||
|
'groups.*',
|
||
|
WIKI.db.groups.relatedQuery('users').count().as('userCount')
|
||
|
)
|
||
|
},
|
||
|
async single(obj, args, context, info) {
|
||
|
return WIKI.db.groups.query().findById(args.id)
|
||
|
}
|
||
|
},
|
||
|
PageMutation: {
|
||
|
async create(obj, args) {
|
||
|
const group = await WIKI.db.pages.query().insertAndFetch({
|
||
|
name: args.name
|
||
|
})
|
||
|
return {
|
||
|
responseResult: graphHelper.generateSuccess('Group created successfully.'),
|
||
|
group
|
||
|
}
|
||
|
},
|
||
|
async delete(obj, args) {
|
||
|
await WIKI.db.groups.query().deleteById(args.id)
|
||
|
return {
|
||
|
responseResult: graphHelper.generateSuccess('Group has been deleted.')
|
||
|
}
|
||
|
},
|
||
|
async update(obj, args) {
|
||
|
await WIKI.db.groups.query().patch({ name: args.name }).where('id', args.id)
|
||
|
return {
|
||
|
responseResult: graphHelper.generateSuccess('Group has been updated.')
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
Page: {
|
||
|
// comments(pg) {
|
||
|
// return pg.$relatedQuery('comments')
|
||
|
// }
|
||
|
}
|
||
|
}
|