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.

47 lines
892 B

  1. 'use strict'
  2. /* global wiki */
  3. module.exports = {
  4. Query: {
  5. documents(obj, args, context, info) {
  6. return wiki.db.Document.findAll({ where: args })
  7. }
  8. },
  9. Mutation: {
  10. createDocument(obj, args) {
  11. return wiki.db.Document.create(args)
  12. },
  13. deleteDocument(obj, args) {
  14. return wiki.db.Document.destroy({
  15. where: {
  16. id: args.id
  17. },
  18. limit: 1
  19. })
  20. },
  21. modifyDocument(obj, args) {
  22. return wiki.db.Document.update({
  23. title: args.title,
  24. subtitle: args.subtitle
  25. }, {
  26. where: { id: args.id }
  27. })
  28. },
  29. moveDocument(obj, args) {
  30. return wiki.db.Document.update({
  31. path: args.path
  32. }, {
  33. where: { id: args.id }
  34. })
  35. }
  36. },
  37. Document: {
  38. comments(doc) {
  39. return doc.getComments()
  40. },
  41. tags(doc) {
  42. return doc.getTags()
  43. }
  44. }
  45. }