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.

34 lines
827 B

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