Skip to content

Instantly share code, notes, and snippets.

@neerajkumar161
Last active January 15, 2022 07:13
Show Gist options
  • Save neerajkumar161/fa2722e92a962165977d782f4e2eed67 to your computer and use it in GitHub Desktop.
Save neerajkumar161/fa2722e92a962165977d782f4e2eed67 to your computer and use it in GitHub Desktop.
/src/resolvers/delete-user.ts
import { userModel } from '../models/user'
export const deleteUserResolver = async (parent: any, args: any, context: any) => {
let user = await userModel.findOne({email: args.email})
if (!user) throw new Error('User not exists!')
await userModel.findOneAndRemove({_id: user._id})
return {message: 'User Deleted!'}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment