site.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. const graphHelper = require('../../helpers/graph')
  2. /* global WIKI */
  3. module.exports = {
  4. Query: {
  5. async site() { return {} }
  6. },
  7. Mutation: {
  8. async site() { return {} }
  9. },
  10. SiteQuery: {
  11. async config(obj, args, context, info) {
  12. return {
  13. host: WIKI.config.host,
  14. title: WIKI.config.title,
  15. company: WIKI.config.company,
  16. ...WIKI.config.seo,
  17. ...WIKI.config.logo,
  18. ...WIKI.config.features
  19. }
  20. }
  21. },
  22. SiteMutation: {
  23. async updateConfig(obj, args, context) {
  24. try {
  25. WIKI.config.host = args.host
  26. WIKI.config.title = args.title
  27. WIKI.config.company = args.company
  28. WIKI.config.seo = {
  29. description: args.description,
  30. robots: args.robots,
  31. analyticsService: args.analyticsService,
  32. analyticsId: args.analyticsId
  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. }