mirror of https://github.com/requarks/wiki
parent
02183f82ec
commit
574e4b97f4
@ -0,0 +1,43 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
/* global wiki */
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
Query: {
|
||||||
|
comments(obj, args, context, info) {
|
||||||
|
return wiki.db.Comment.findAll({ where: args })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Mutation: {
|
||||||
|
createComment(obj, args) {
|
||||||
|
return wiki.db.Comment.create({
|
||||||
|
content: args.content,
|
||||||
|
author: args.userId,
|
||||||
|
document: args.documentId
|
||||||
|
})
|
||||||
|
},
|
||||||
|
deleteComment(obj, args) {
|
||||||
|
return wiki.db.Comment.destroy({
|
||||||
|
where: {
|
||||||
|
id: args.id
|
||||||
|
},
|
||||||
|
limit: 1
|
||||||
|
})
|
||||||
|
},
|
||||||
|
modifyComment(obj, args) {
|
||||||
|
return wiki.db.Comment.update({
|
||||||
|
content: args.content
|
||||||
|
}, {
|
||||||
|
where: { id: args.id }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Comment: {
|
||||||
|
author(cm) {
|
||||||
|
return cm.getAuthor()
|
||||||
|
},
|
||||||
|
document(cm) {
|
||||||
|
return cm.getDocument()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
/* global wiki */
|
||||||
|
|
||||||
|
const gql = require('graphql')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
Query: {
|
||||||
|
rights(obj, args, context, info) {
|
||||||
|
return wiki.db.Right.findAll({ where: args })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Mutation: {
|
||||||
|
addRightToGroup(obj, args) {
|
||||||
|
return wiki.db.Group.findById(args.groupId).then(grp => {
|
||||||
|
if (!grp) {
|
||||||
|
throw new gql.GraphQLError('Invalid Group ID')
|
||||||
|
}
|
||||||
|
return wiki.db.Right.create({
|
||||||
|
path: args.path,
|
||||||
|
role: args.role,
|
||||||
|
exact: args.exact,
|
||||||
|
allow: args.allow,
|
||||||
|
group: grp
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
removeRightFromGroup(obj, args) {
|
||||||
|
return wiki.db.Right.destroy({
|
||||||
|
where: {
|
||||||
|
id: args.rightId
|
||||||
|
},
|
||||||
|
limit: 1
|
||||||
|
})
|
||||||
|
},
|
||||||
|
modifyRight(obj, args) {
|
||||||
|
return wiki.db.Right.update({
|
||||||
|
path: args.path,
|
||||||
|
role: args.role,
|
||||||
|
exact: args.exact,
|
||||||
|
allow: args.allow
|
||||||
|
}, {
|
||||||
|
where: {
|
||||||
|
id: args.id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Right: {
|
||||||
|
group(rt) {
|
||||||
|
return rt.getGroup()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
/* global wiki */
|
||||||
|
|
||||||
|
const _ = require('lodash')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
Query: {
|
||||||
|
settings(obj, args, context, info) {
|
||||||
|
return wiki.db.Setting.findAll({ where: args, raw: true }).then(entries => {
|
||||||
|
return _.map(entries, entry => {
|
||||||
|
entry.config = JSON.stringify(entry.config)
|
||||||
|
return entry
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Mutation: {
|
||||||
|
setConfigEntry(obj, args) {
|
||||||
|
return wiki.db.Setting.update({
|
||||||
|
value: args.value
|
||||||
|
}, { where: { key: args.key } })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue