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.

42 lines
789 B

  1. /* global WIKI */
  2. module.exports = {
  3. Query: {
  4. comments(obj, args, context, info) {
  5. return WIKI.db.Comment.findAll({ where: args })
  6. }
  7. },
  8. Mutation: {
  9. createComment(obj, args) {
  10. return WIKI.db.Comment.create({
  11. content: args.content,
  12. author: args.userId,
  13. document: args.documentId
  14. })
  15. },
  16. deleteComment(obj, args) {
  17. return WIKI.db.Comment.destroy({
  18. where: {
  19. id: args.id
  20. },
  21. limit: 1
  22. })
  23. },
  24. modifyComment(obj, args) {
  25. return WIKI.db.Comment.update({
  26. content: args.content
  27. }, {
  28. where: { id: args.id }
  29. })
  30. }
  31. },
  32. Comment: {
  33. author(cm) {
  34. return cm.getAuthor()
  35. },
  36. document(cm) {
  37. return cm.getDocument()
  38. }
  39. }
  40. }