feat: theming resolvers + config fixes
This commit is contained in:
42
server/graph/resolvers/theming.js
Normal file
42
server/graph/resolvers/theming.js
Normal file
@@ -0,0 +1,42 @@
|
||||
const graphHelper = require('../../helpers/graph')
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
module.exports = {
|
||||
Query: {
|
||||
async theming() { return {} }
|
||||
},
|
||||
Mutation: {
|
||||
async theming() { return {} }
|
||||
},
|
||||
ThemingQuery: {
|
||||
async themes(obj, args, context, info) {
|
||||
return [{ // TODO
|
||||
key: 'default',
|
||||
title: 'Default',
|
||||
author: 'requarks.io'
|
||||
}]
|
||||
},
|
||||
async config(obj, args, context, info) {
|
||||
return {
|
||||
theme: WIKI.config.theming.theme,
|
||||
darkMode: WIKI.config.theming.darkMode
|
||||
}
|
||||
}
|
||||
},
|
||||
ThemingMutation: {
|
||||
async setConfig(obj, args, context, info) {
|
||||
try {
|
||||
WIKI.config.theming.theme = args.theme
|
||||
WIKI.config.theming.darkMode = args.darkMode
|
||||
await WIKI.configSvc.saveToDb(['theming'])
|
||||
|
||||
return {
|
||||
responseResult: graphHelper.generateSuccess('Theme config updated')
|
||||
}
|
||||
} catch (err) {
|
||||
return graphHelper.generateError(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
46
server/graph/schemas/theming.graphql
Normal file
46
server/graph/schemas/theming.graphql
Normal file
@@ -0,0 +1,46 @@
|
||||
# ===============================================
|
||||
# THEMES
|
||||
# ===============================================
|
||||
|
||||
extend type Query {
|
||||
theming: ThemingQuery
|
||||
}
|
||||
|
||||
extend type Mutation {
|
||||
theming: ThemingMutation
|
||||
}
|
||||
|
||||
# -----------------------------------------------
|
||||
# QUERIES
|
||||
# -----------------------------------------------
|
||||
|
||||
type ThemingQuery {
|
||||
themes: [ThemingTheme]
|
||||
config: ThemingConfig
|
||||
}
|
||||
|
||||
# -----------------------------------------------
|
||||
# MUTATIONS
|
||||
# -----------------------------------------------
|
||||
|
||||
type ThemingMutation {
|
||||
setConfig(
|
||||
theme: String!
|
||||
darkMode: Boolean!
|
||||
): DefaultResponse
|
||||
}
|
||||
|
||||
# -----------------------------------------------
|
||||
# TYPES
|
||||
# -----------------------------------------------
|
||||
|
||||
type ThemingConfig {
|
||||
theme: String
|
||||
darkMode: Boolean
|
||||
}
|
||||
|
||||
type ThemingTheme {
|
||||
key: String
|
||||
title: String
|
||||
author: String
|
||||
}
|
Reference in New Issue
Block a user