mirror of https://github.com/Requarks/wiki.git
12 changed files with 232 additions and 1 deletions
Unified View
Diff Options
-
2server/models/_relations.js
-
5server/models/document.js
-
4server/modules/graphql.js
-
43server/schemas/resolvers-comment.js
-
18server/schemas/resolvers-document.js
-
7server/schemas/resolvers-folder.js
-
7server/schemas/resolvers-group.js
-
54server/schemas/resolvers-right.js
-
25server/schemas/resolvers-setting.js
-
7server/schemas/resolvers-tag.js
-
17server/schemas/resolvers-user.js
-
44server/schemas/types.graphql
@ -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 } }) |
||||
|
} |
||||
|
} |
||||
|
} |
xxxxxxxxxx