feat: Convert all mutation files to js
This commit is contained in:
27
packages/backend/src/graphql/mutations/update-user.ee.js
Normal file
27
packages/backend/src/graphql/mutations/update-user.ee.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import User from '../../models/user';
|
||||
|
||||
const updateUser = async (_parent, params, context) => {
|
||||
context.currentUser.can('update', 'User');
|
||||
|
||||
const userPayload = {
|
||||
email: params.input.email,
|
||||
fullName: params.input.fullName,
|
||||
};
|
||||
|
||||
try {
|
||||
context.currentUser.can('update', 'Role');
|
||||
|
||||
userPayload.roleId = params.input.role.id;
|
||||
} catch {
|
||||
// void
|
||||
}
|
||||
|
||||
const user = await User.query().patchAndFetchById(
|
||||
params.input.id,
|
||||
userPayload
|
||||
);
|
||||
|
||||
return user;
|
||||
};
|
||||
|
||||
export default updateUser;
|
Reference in New Issue
Block a user