Jean-Sébastien Herbaux 5a7a5dc987
[V4] GraphQL - Migrate Users & Permissions GraphQL config to V4 (#10979)
* Migrate UsersPermissions's GQL configuration to V4

* Remove old graphql configuration
2021-09-15 15:44:42 +02:00

38 lines
882 B
JavaScript

'use strict';
const { toPlainObject } = require('lodash/fp');
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: 'UsersPermissionsCreateRolePayload',
args: {
data: nonNull(roleInputName),
},
description: 'Create a new role',
async resolve(parent, args, context) {
const { koaContext } = context;
koaContext.request.body = toPlainObject(args.data);
await strapi
.plugin('users-permissions')
.controller('role')
.createRole(koaContext);
return { ok: true };
},
};
};