chore: remove redundant create role mutation
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import createConnection from './mutations/create-connection.js';
|
||||
import createRole from './mutations/create-role.ee.js';
|
||||
import createStep from './mutations/create-step.js';
|
||||
import createUser from './mutations/create-user.ee.js';
|
||||
import deleteFlow from './mutations/delete-flow.js';
|
||||
@@ -26,7 +25,6 @@ import deleteCurrentUser from './mutations/delete-current-user.ee.js';
|
||||
const mutationResolvers = {
|
||||
createConnection,
|
||||
createFlow,
|
||||
createRole,
|
||||
createStep,
|
||||
createUser,
|
||||
deleteCurrentUser,
|
||||
|
@@ -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;
|
@@ -4,7 +4,6 @@ type Query {
|
||||
type Mutation {
|
||||
createConnection(input: CreateConnectionInput): Connection
|
||||
createFlow(input: CreateFlowInput): Flow
|
||||
createRole(input: CreateRoleInput): Role
|
||||
createStep(input: CreateStepInput): Step
|
||||
createUser(input: CreateUserInput): UserWithAcceptInvitationUrl
|
||||
deleteCurrentUser: Boolean
|
||||
@@ -342,12 +341,6 @@ input PermissionInput {
|
||||
conditions: [String]
|
||||
}
|
||||
|
||||
input CreateRoleInput {
|
||||
name: String!
|
||||
description: String
|
||||
permissions: [PermissionInput]
|
||||
}
|
||||
|
||||
input UpdateRoleInput {
|
||||
id: String!
|
||||
name: String!
|
||||
|
@@ -1,11 +0,0 @@
|
||||
import { gql } from '@apollo/client';
|
||||
export const CREATE_ROLE = gql`
|
||||
mutation CreateRole($input: CreateRoleInput) {
|
||||
createRole(input: $input) {
|
||||
id
|
||||
key
|
||||
name
|
||||
description
|
||||
}
|
||||
}
|
||||
`;
|
Reference in New Issue
Block a user