mirror of https://github.com/requarks/wiki
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.
45 lines
1.2 KiB
45 lines
1.2 KiB
2 years ago
|
import { generateError, generateSuccess } from '../../helpers/graph.mjs'
|
||
6 years ago
|
|
||
2 years ago
|
export default {
|
||
6 years ago
|
Query: {
|
||
3 years ago
|
async navigationTree (obj, args, context, info) {
|
||
2 years ago
|
return WIKI.db.navigation.getTree({ cache: false, locale: 'all', bypassAuth: true })
|
||
5 years ago
|
},
|
||
3 years ago
|
navigationConfig (obj, args, context, info) {
|
||
5 years ago
|
return WIKI.config.nav
|
||
6 years ago
|
}
|
||
|
},
|
||
3 years ago
|
Mutation: {
|
||
|
async updateNavigationTree (obj, args, context) {
|
||
6 years ago
|
try {
|
||
2 years ago
|
await WIKI.db.navigation.query().patch({
|
||
6 years ago
|
config: args.tree
|
||
|
}).where('key', 'site')
|
||
5 years ago
|
for (const tree of args.tree) {
|
||
|
await WIKI.cache.set(`nav:sidebar:${tree.locale}`, tree.items, 300)
|
||
|
}
|
||
6 years ago
|
|
||
6 years ago
|
return {
|
||
2 years ago
|
responseResult: generateSuccess('Navigation updated successfully')
|
||
6 years ago
|
}
|
||
|
} catch (err) {
|
||
2 years ago
|
return generateError(err)
|
||
6 years ago
|
}
|
||
5 years ago
|
},
|
||
3 years ago
|
async updateNavigationConfig (obj, args, context) {
|
||
5 years ago
|
try {
|
||
|
WIKI.config.nav = {
|
||
|
mode: args.mode
|
||
|
}
|
||
|
await WIKI.configSvc.saveToDb(['nav'])
|
||
|
|
||
|
return {
|
||
2 years ago
|
responseResult: generateSuccess('Navigation config updated successfully')
|
||
5 years ago
|
}
|
||
|
} catch (err) {
|
||
2 years ago
|
return generateError(err)
|
||
5 years ago
|
}
|
||
6 years ago
|
}
|
||
|
}
|
||
|
}
|