chore: remove redundant create role mutation

This commit is contained in:
Ali BARIN
2024-09-03 13:56:23 +00:00
parent a4ea6c1fad
commit e76a99fd68
4 changed files with 0 additions and 49 deletions

View File

@@ -1,29 +0,0 @@
import kebabCase from 'lodash/kebabCase.js';
import Role from '../../models/role.js';
const createRole = async (_parent, params, context) => {
context.currentUser.can('create', 'Role');
const { name, description, permissions } = params.input;
const key = kebabCase(name);
const existingRole = await Role.query().findOne({ key });
if (existingRole) {
throw new Error('Role already exists!');
}
return await Role.query()
.insertGraph(
{
key,
name,
description,
permissions,
},
{ relate: ['permissions'] }
)
.returning('*');
};
export default createRole;