mirror of https://github.com/requarks/wiki
parent
1d2d1c66c1
commit
197b6b4160
@ -0,0 +1,12 @@
|
|||||||
|
mutation($theme: String!, $darkMode: Boolean!) {
|
||||||
|
theming {
|
||||||
|
setConfig(theme: $theme, darkMode: $darkMode) {
|
||||||
|
responseResult {
|
||||||
|
succeeded
|
||||||
|
errorCode
|
||||||
|
slug
|
||||||
|
message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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
|
||||||
|
}
|
Loading…
Reference in new issue