mirror of
https://github.com/strapi/strapi.git
synced 2025-07-23 09:00:19 +00:00
40 lines
961 B
JavaScript
40 lines
961 B
JavaScript
'use strict';
|
|
|
|
const { checkBadRequest } = require('../../../utils');
|
|
|
|
const usersPermissionsUserUID = 'plugin::users-permissions.user';
|
|
|
|
module.exports = ({ nexus, strapi }) => {
|
|
const { nonNull } = nexus;
|
|
const { getEntityResponseName } = strapi.plugin('graphql').service('utils').naming;
|
|
|
|
const userContentType = strapi.getModel(usersPermissionsUserUID);
|
|
|
|
const responseName = getEntityResponseName(userContentType);
|
|
|
|
return {
|
|
type: nonNull(responseName),
|
|
|
|
args: {
|
|
id: nonNull('ID'),
|
|
},
|
|
|
|
description: 'Delete an existing user',
|
|
|
|
async resolve(parent, args, context) {
|
|
const { koaContext } = context;
|
|
|
|
koaContext.params = { id: args.id };
|
|
|
|
await strapi.plugin('users-permissions').controller('user').destroy(koaContext);
|
|
|
|
checkBadRequest(koaContext.body);
|
|
|
|
return {
|
|
value: koaContext.body,
|
|
info: { args, resourceUID: 'plugin::users-permissions.user' },
|
|
};
|
|
},
|
|
};
|
|
};
|