mirror of
https://github.com/strapi/strapi.git
synced 2025-07-29 03:50:26 +00:00
36 lines
913 B
JavaScript
36 lines
913 B
JavaScript
'use strict';
|
|
|
|
const usersPermissionsRoleUID = 'plugin::users-permissions.role';
|
|
|
|
module.exports = ({ nexus, strapi }) => {
|
|
const { getContentTypeInputName } = strapi.plugin('graphql').service('utils').naming;
|
|
const { nonNull } = nexus;
|
|
|
|
const roleContentType = strapi.getModel(usersPermissionsRoleUID);
|
|
|
|
const roleInputName = getContentTypeInputName(roleContentType);
|
|
|
|
return {
|
|
type: 'UsersPermissionsUpdateRolePayload',
|
|
|
|
args: {
|
|
id: nonNull('ID'),
|
|
data: nonNull(roleInputName),
|
|
},
|
|
|
|
description: 'Update an existing role',
|
|
|
|
async resolve(parent, args, context) {
|
|
const { koaContext } = context;
|
|
|
|
koaContext.params = { role: args.id };
|
|
koaContext.request.body = args.data;
|
|
koaContext.request.body.role = args.id;
|
|
|
|
await strapi.plugin('users-permissions').controller('role').updateRole(koaContext);
|
|
|
|
return { ok: true };
|
|
},
|
|
};
|
|
};
|