Skip to content

Instantly share code, notes, and snippets.

@neerajkumar161
Last active January 15, 2022 06:58
Show Gist options
  • Save neerajkumar161/8bfba4670e88141ac2cc9d7d4b90f2cb to your computer and use it in GitHub Desktop.
Save neerajkumar161/8bfba4670e88141ac2cc9d7d4b90f2cb to your computer and use it in GitHub Desktop.
/src/resolvers/get-user.ts
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