Skip to content

Instantly share code, notes, and snippets.

@desaijay315
Created June 5, 2019 08:30
Show Gist options
  • Save desaijay315/45ca44b90258e0630cdfeabb3c8895cd to your computer and use it in GitHub Desktop.
Save desaijay315/45ca44b90258e0630cdfeabb3c8895cd to your computer and use it in GitHub Desktop.
const resolvers = {
Mutation:{
createNewUser(parent,args,ctx,info){
const isEmailExists = users.some((user) => user.email === args.email)
if(isEmailExists){
throw new Error('Email already Taken')
}
const user = {
id:uuidv4(),
name:args.name,
email:args.email,
age:args.age
}
users.push(user)
return user
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment