Skip to content

Instantly share code, notes, and snippets.

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