Files
automatisch/packages/backend/src/graphql/queries/get-role.ee.ts
2023-08-03 19:39:48 +02:00

24 lines
466 B
TypeScript

import Context from '../../types/express/context';
import Role from '../../models/role';
type Params = {
id: string
};
const getRole = async (_parent: unknown, params: Params, context: Context) => {
context.currentUser.can('read', 'Role');
return await Role
.query()
.leftJoinRelated({
permissions: true
})
.withGraphFetched({
permissions: true
})
.findById(params.id)
.throwIfNotFound();
};
export default getRole;