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.

43 lines
802 B

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