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.
54 lines
1.0 KiB
54 lines
1.0 KiB
7 years ago
|
|
||
7 years ago
|
/* global WIKI */
|
||
7 years ago
|
|
||
|
const gql = require('graphql')
|
||
|
|
||
|
module.exports = {
|
||
|
Query: {
|
||
|
rights(obj, args, context, info) {
|
||
7 years ago
|
return WIKI.db.Right.findAll({ where: args })
|
||
7 years ago
|
}
|
||
|
},
|
||
|
Mutation: {
|
||
|
addRightToGroup(obj, args) {
|
||
7 years ago
|
return WIKI.db.Group.findById(args.groupId).then(grp => {
|
||
7 years ago
|
if (!grp) {
|
||
|
throw new gql.GraphQLError('Invalid Group ID')
|
||
|
}
|
||
7 years ago
|
return WIKI.db.Right.create({
|
||
7 years ago
|
path: args.path,
|
||
|
role: args.role,
|
||
|
exact: args.exact,
|
||
|
allow: args.allow,
|
||
|
group: grp
|
||
|
})
|
||
|
})
|
||
|
},
|
||
|
removeRightFromGroup(obj, args) {
|
||
7 years ago
|
return WIKI.db.Right.destroy({
|
||
7 years ago
|
where: {
|
||
|
id: args.rightId
|
||
|
},
|
||
|
limit: 1
|
||
|
})
|
||
|
},
|
||
|
modifyRight(obj, args) {
|
||
7 years ago
|
return WIKI.db.Right.update({
|
||
7 years ago
|
path: args.path,
|
||
|
role: args.role,
|
||
|
exact: args.exact,
|
||
|
allow: args.allow
|
||
|
}, {
|
||
|
where: {
|
||
|
id: args.id
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
},
|
||
|
Right: {
|
||
|
group(rt) {
|
||
|
return rt.getGroup()
|
||
|
}
|
||
|
}
|
||
|
}
|