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.

33 lines
777 B

  1. const graphHelper = require('../../helpers/graph')
  2. /* global WIKI */
  3. module.exports = {
  4. Query: {
  5. async navigation() { return {} }
  6. },
  7. Mutation: {
  8. async navigation() { return {} }
  9. },
  10. NavigationQuery: {
  11. async tree(obj, args, context, info) {
  12. return WIKI.models.navigation.getTree()
  13. }
  14. },
  15. NavigationMutation: {
  16. async updateTree(obj, args, context) {
  17. try {
  18. await WIKI.models.navigation.query().patch({
  19. config: args.tree
  20. }).where('key', 'site')
  21. await WIKI.cache.set('nav:sidebar', args.tree, 300)
  22. return {
  23. responseResult: graphHelper.generateSuccess('Navigation updated successfully')
  24. }
  25. } catch (err) {
  26. return graphHelper.generateError(err)
  27. }
  28. }
  29. }
  30. }