feat: write updateConfig GQL mutation
This commit is contained in:
@@ -17,6 +17,7 @@ import login from './mutations/login';
|
|||||||
import registerUser from './mutations/register-user.ee';
|
import registerUser from './mutations/register-user.ee';
|
||||||
import resetConnection from './mutations/reset-connection';
|
import resetConnection from './mutations/reset-connection';
|
||||||
import resetPassword from './mutations/reset-password.ee';
|
import resetPassword from './mutations/reset-password.ee';
|
||||||
|
import updateConfig from './mutations/update-config';
|
||||||
import updateConnection from './mutations/update-connection';
|
import updateConnection from './mutations/update-connection';
|
||||||
import updateCurrentUser from './mutations/update-current-user';
|
import updateCurrentUser from './mutations/update-current-user';
|
||||||
import updateFlow from './mutations/update-flow';
|
import updateFlow from './mutations/update-flow';
|
||||||
@@ -24,8 +25,8 @@ import updateFlowStatus from './mutations/update-flow-status';
|
|||||||
import updateRole from './mutations/update-role.ee';
|
import updateRole from './mutations/update-role.ee';
|
||||||
import updateStep from './mutations/update-step';
|
import updateStep from './mutations/update-step';
|
||||||
import updateUser from './mutations/update-user.ee';
|
import updateUser from './mutations/update-user.ee';
|
||||||
import verifyConnection from './mutations/verify-connection';
|
|
||||||
import upsertSamlAuthProvider from './mutations/upsert-saml-auth-provider.ee';
|
import upsertSamlAuthProvider from './mutations/upsert-saml-auth-provider.ee';
|
||||||
|
import verifyConnection from './mutations/verify-connection';
|
||||||
|
|
||||||
const mutationResolvers = {
|
const mutationResolvers = {
|
||||||
createConnection,
|
createConnection,
|
||||||
@@ -47,15 +48,16 @@ const mutationResolvers = {
|
|||||||
registerUser,
|
registerUser,
|
||||||
resetConnection,
|
resetConnection,
|
||||||
resetPassword,
|
resetPassword,
|
||||||
|
updateConfig,
|
||||||
updateConnection,
|
updateConnection,
|
||||||
updateCurrentUser,
|
updateCurrentUser,
|
||||||
updateUser,
|
|
||||||
updateFlow,
|
updateFlow,
|
||||||
updateFlowStatus,
|
updateFlowStatus,
|
||||||
updateRole,
|
updateRole,
|
||||||
updateStep,
|
updateStep,
|
||||||
verifyConnection,
|
updateUser,
|
||||||
upsertSamlAuthProvider,
|
upsertSamlAuthProvider,
|
||||||
|
verifyConnection,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default mutationResolvers;
|
export default mutationResolvers;
|
||||||
|
44
packages/backend/src/graphql/mutations/update-config.ts
Normal file
44
packages/backend/src/graphql/mutations/update-config.ts
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import type { IJSONValue } from '@automatisch/types';
|
||||||
|
import Config from '../../models/config';
|
||||||
|
import Context from '../../types/express/context';
|
||||||
|
|
||||||
|
type Params = {
|
||||||
|
input: {
|
||||||
|
[index: string]: IJSONValue;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateConfig = async (_parent: unknown, params: Params, context: Context) => {
|
||||||
|
context.currentUser.can('update', 'Config');
|
||||||
|
|
||||||
|
const config = params.input;
|
||||||
|
const configKeys = Object.keys(config);
|
||||||
|
const updates = [];
|
||||||
|
|
||||||
|
for (const key of configKeys) {
|
||||||
|
const newValue = config[key];
|
||||||
|
|
||||||
|
const entryUpdate = Config
|
||||||
|
.query()
|
||||||
|
.insert({
|
||||||
|
key,
|
||||||
|
value: {
|
||||||
|
data: newValue
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.onConflict('key')
|
||||||
|
.merge({
|
||||||
|
value: {
|
||||||
|
data: newValue
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
updates.push(entryUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.all(updates);
|
||||||
|
|
||||||
|
return config;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default updateConfig;
|
@@ -72,6 +72,7 @@ type Mutation {
|
|||||||
registerUser(input: RegisterUserInput): User
|
registerUser(input: RegisterUserInput): User
|
||||||
resetConnection(input: ResetConnectionInput): Connection
|
resetConnection(input: ResetConnectionInput): Connection
|
||||||
resetPassword(input: ResetPasswordInput): Boolean
|
resetPassword(input: ResetPasswordInput): Boolean
|
||||||
|
updateConfig(input: JSONObject): JSONObject
|
||||||
updateConnection(input: UpdateConnectionInput): Connection
|
updateConnection(input: UpdateConnectionInput): Connection
|
||||||
updateCurrentUser(input: UpdateCurrentUserInput): User
|
updateCurrentUser(input: UpdateCurrentUserInput): User
|
||||||
updateFlow(input: UpdateFlowInput): Flow
|
updateFlow(input: UpdateFlowInput): Flow
|
||||||
@@ -79,8 +80,8 @@ type Mutation {
|
|||||||
updateRole(input: UpdateRoleInput): Role
|
updateRole(input: UpdateRoleInput): Role
|
||||||
updateStep(input: UpdateStepInput): Step
|
updateStep(input: UpdateStepInput): Step
|
||||||
updateUser(input: UpdateUserInput): User
|
updateUser(input: UpdateUserInput): User
|
||||||
verifyConnection(input: VerifyConnectionInput): Connection
|
|
||||||
upsertSamlAuthProvider(input: UpsertSamlAuthProviderInput): SamlAuthProvider
|
upsertSamlAuthProvider(input: UpsertSamlAuthProviderInput): SamlAuthProvider
|
||||||
|
verifyConnection(input: VerifyConnectionInput): Connection
|
||||||
}
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user