Last active
January 15, 2022 06:58
-
-
Save neerajkumar161/8bfba4670e88141ac2cc9d7d4b90f2cb to your computer and use it in GitHub Desktop.
/src/resolvers/get-user.ts
This file contains 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
import { userModel } from '../models/user'; | |
export const getUserByIdResolver = async (parent: any, args: any, context: any) => { | |
const user = await userModel.findOne({_id: args.id}).lean() | |
if (!user) throw new Error('No user exists!') | |
return user | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment