Add hooks to RootMutation to save our setting in the database.

This commit is contained in:
Fabian Neumann
2018-05-11 11:19:09 +02:00
parent bbd3050b95
commit 499030028c
3 changed files with 15 additions and 0 deletions
@@ -1,5 +1,6 @@
const { readFileSync } = require('fs');
const path = require('path');
const hooks = require('./server/hooks');
const resolvers = require('./server/resolvers');
module.exports = {
@@ -7,5 +8,6 @@ module.exports = {
path.join(__dirname, 'server/typeDefs.graphql'),
'utf8'
),
hooks,
resolvers,
};
@@ -0,0 +1,13 @@
module.exports = {
RootMutation: {
updateSettings: {
async pre(_, { input }) {
input.metadata = {
...input.metadata,
globalSwitchoffEnable: input.globalSwitchoffEnable,
};
delete input.globalSwitchoffEnable;
},
},
},
};