| 
									
										
										
										
											2021-09-15 15:44:42 +02:00
										 |  |  | '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'), | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-10 21:50:06 +09:00
										 |  |  |     description: 'Delete an existing user', | 
					
						
							| 
									
										
										
										
											2021-09-15 15:44:42 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     async resolve(parent, args, context) { | 
					
						
							|  |  |  |       const { koaContext } = context; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       koaContext.params = { id: args.id }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-08 23:33:39 +02:00
										 |  |  |       await strapi.plugin('users-permissions').controller('user').destroy(koaContext); | 
					
						
							| 
									
										
										
										
											2021-09-15 15:44:42 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |       checkBadRequest(koaContext.body); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       return { | 
					
						
							|  |  |  |         value: koaContext.body, | 
					
						
							|  |  |  |         info: { args, resourceUID: 'plugin::users-permissions.user' }, | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | }; |