Created
June 5, 2019 10:05
-
-
Save desaijay315/7878e1748ccb7ae664f039d552f2c4b1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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