feat(auth): add user and role management
This commit is contained in:
23
packages/backend/src/graphql/queries/get-user.ts
Normal file
23
packages/backend/src/graphql/queries/get-user.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import Context from '../../types/express/context';
|
||||
import User from '../../models/user';
|
||||
|
||||
type Params = {
|
||||
id: string
|
||||
};
|
||||
|
||||
const getUser = async (_parent: unknown, params: Params, context: Context) => {
|
||||
context.currentUser.can('read', 'User');
|
||||
|
||||
return await User
|
||||
.query()
|
||||
.leftJoinRelated({
|
||||
role: true
|
||||
})
|
||||
.withGraphFetched({
|
||||
role: true
|
||||
})
|
||||
.findById(params.id)
|
||||
.throwIfNotFound();
|
||||
};
|
||||
|
||||
export default getUser;
|
Reference in New Issue
Block a user