Vulcan/packages/nova-comments/lib/mutations.js

50 lines
1.4 KiB
JavaScript
Raw Normal View History

import Telescope, { newMutation, editMutation, removeMutation } from 'meteor/nova:lib';
2016-11-05 18:37:46 +09:00
import Comments from './collection.js'
import Users from 'meteor/nova:users';
import Events from "meteor/nova:events";
// Resolvers
2016-11-05 18:37:46 +09:00
Comments.mutations = {
2016-11-07 23:46:12 +09:00
commentsNew(root, {document}, context) {
return newMutation({
collection: context.Comments,
2016-11-07 23:46:12 +09:00
document: document,
currentUser: context.currentUser,
validate: true
});
2016-11-05 18:37:46 +09:00
},
2016-11-07 23:46:12 +09:00
commentsEdit(root, {documentId, set, unset}, context) {
return editMutation({
collection: context.Comments,
2016-11-07 23:46:12 +09:00
documentId: documentId,
set: set,
unset: unset,
currentUser: context.currentUser,
validate: true
});
},
2016-11-05 18:37:46 +09:00
2016-11-07 23:46:12 +09:00
commentsRemove(root, {documentId}, context) {
return removeMutation({
collection: context.Comments,
2016-11-07 23:46:12 +09:00
documentId: documentId,
currentUser: context.currentUser,
validate: true
});
2016-11-05 18:37:46 +09:00
},
2016-11-07 23:46:12 +09:00
commentsVote(root, {documentId, voteType}, context) {
2016-11-05 18:37:46 +09:00
},
};
// GraphQL mutations
2016-11-07 23:46:12 +09:00
Telescope.graphQL.addMutation('commentsNew(document: commentsInput) : Comment');
Telescope.graphQL.addMutation('commentsEdit(documentId: String, set: commentsInput, unset: commentsUnset) : Comment');
Telescope.graphQL.addMutation('commentsRemove(documentId: String) : Comment');
Telescope.graphQL.addMutation('commentsVote(documentId: String, voteType: String) : Comment');
2016-11-05 18:37:46 +09:00
export default Comments.mutations;