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.

56 lines
1.5 KiB

  1. const _ = require('lodash')
  2. const graphHelper = require('../../helpers/graph')
  3. /* global WIKI */
  4. module.exports = {
  5. Query: {
  6. async site() { return {} }
  7. },
  8. Mutation: {
  9. async site() { return {} }
  10. },
  11. SiteQuery: {
  12. async config(obj, args, context, info) {
  13. return {
  14. host: WIKI.config.host,
  15. title: WIKI.config.title,
  16. company: WIKI.config.company,
  17. ...WIKI.config.seo,
  18. ...WIKI.config.logo,
  19. ...WIKI.config.features
  20. }
  21. }
  22. },
  23. SiteMutation: {
  24. async updateConfig(obj, args, context) {
  25. try {
  26. WIKI.config.host = args.host
  27. WIKI.config.title = args.title
  28. WIKI.config.company = args.company
  29. WIKI.config.seo = {
  30. description: args.description,
  31. robots: args.robots,
  32. analyticsService: args.analyticsService,
  33. analyticsId: args.analyticsId
  34. }
  35. WIKI.config.logo = {
  36. hasLogo: args.hasLogo,
  37. logoIsSquare: args.logoIsSquare
  38. }
  39. WIKI.config.features = {
  40. featurePageRatings: args.featurePageRatings,
  41. featurePageComments: args.featurePageComments,
  42. featurePersonalWikis: args.featurePersonalWikis
  43. }
  44. await WIKI.configSvc.saveToDb(['host', 'title', 'company', 'seo', 'logo', 'features'])
  45. return {
  46. responseResult: graphHelper.generateSuccess('Site configuration updated successfully')
  47. }
  48. } catch (err) {
  49. return graphHelper.generateError(err)
  50. }
  51. }
  52. }
  53. }