2018-05-20 22:50:51 +00:00
|
|
|
const graphHelper = require('../../helpers/graph')
|
|
|
|
|
|
|
|
/* global WIKI */
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
Query: {
|
|
|
|
async pages() { return {} }
|
|
|
|
},
|
|
|
|
Mutation: {
|
|
|
|
async pages() { return {} }
|
|
|
|
},
|
|
|
|
PageQuery: {
|
2018-11-25 06:28:20 +00:00
|
|
|
async history(obj, args, context, info) {
|
|
|
|
return WIKI.models.pageHistory.getHistory({
|
|
|
|
pageId: args.id,
|
2018-11-25 23:25:52 +00:00
|
|
|
offsetPage: args.offsetPage || 0,
|
|
|
|
offsetSize: args.offsetSize || 100
|
2018-11-25 06:28:20 +00:00
|
|
|
})
|
2018-05-20 22:50:51 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
PageMutation: {
|
2018-07-22 04:29:39 +00:00
|
|
|
async create(obj, args, context) {
|
2018-07-30 02:23:33 +00:00
|
|
|
const page = await WIKI.models.pages.createPage({
|
2018-07-22 20:25:39 +00:00
|
|
|
...args,
|
2018-07-22 04:29:39 +00:00
|
|
|
authorId: context.req.user.id
|
2018-05-20 22:50:51 +00:00
|
|
|
})
|
|
|
|
return {
|
2018-07-22 04:29:39 +00:00
|
|
|
responseResult: graphHelper.generateSuccess('Page created successfully.'),
|
|
|
|
page
|
2018-05-20 22:50:51 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
async delete(obj, args) {
|
2018-07-30 02:23:33 +00:00
|
|
|
await WIKI.models.groups.query().deleteById(args.id)
|
2018-05-20 22:50:51 +00:00
|
|
|
return {
|
2018-07-22 04:29:39 +00:00
|
|
|
responseResult: graphHelper.generateSuccess('Page has been deleted.')
|
2018-05-20 22:50:51 +00:00
|
|
|
}
|
|
|
|
},
|
2018-07-23 01:13:01 +00:00
|
|
|
async update(obj, args, context) {
|
2018-07-30 02:23:33 +00:00
|
|
|
const page = await WIKI.models.pages.updatePage({
|
2018-07-23 01:13:01 +00:00
|
|
|
...args,
|
|
|
|
authorId: context.req.user.id
|
|
|
|
})
|
2018-05-20 22:50:51 +00:00
|
|
|
return {
|
2018-07-23 01:13:01 +00:00
|
|
|
responseResult: graphHelper.generateSuccess('Page has been updated.'),
|
|
|
|
page
|
2018-05-20 22:50:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
Page: {
|
|
|
|
// comments(pg) {
|
|
|
|
// return pg.$relatedQuery('comments')
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|