Skip to content

Instantly share code, notes, and snippets.

@desaijay315
Created June 5, 2019 10:05
Show Gist options
  • Save desaijay315/7878e1748ccb7ae664f039d552f2c4b1 to your computer and use it in GitHub Desktop.
Save desaijay315/7878e1748ccb7ae664f039d552f2c4b1 to your computer and use it in GitHub Desktop.
deleteUser(parent,args,ctx,info){
const isUserExists = users.findIndex((user)=> user.id === args.author)
if(!isUserExists){
throw new Error('User does not exist!')
}
//splice will return the removed items from the array object
const userdeleted = users.splice(isUserExists, 1)
return userdeleted[0]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment