site.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. ga: args.ga
  33. }
  34. WIKI.config.logo = {
  35. hasLogo: args.hasLogo,
  36. logoIsSquare: args.logoIsSquare
  37. }
  38. WIKI.config.features = {
  39. featurePageRatings: args.featurePageRatings,
  40. featurePageComments: args.featurePageComments,
  41. featurePersonalWikis: args.featurePersonalWikis
  42. }
  43. await WIKI.configSvc.saveToDb(['host', 'title', 'company', 'seo', 'logo', 'features'])
  44. return {
  45. responseResult: graphHelper.generateSuccess('Site configuration updated successfully')
  46. }
  47. } catch (err) {
  48. return graphHelper.generateError(err)
  49. }
  50. }
  51. }
  52. }