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.

46 lines
899 B

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