added user overview

This commit is contained in:
lnn0q 2025-06-01 20:11:57 +03:00
parent b5738c610d
commit 2ac082a4e4
5 changed files with 107 additions and 14 deletions

View file

@ -5,9 +5,17 @@ import { toUserSchema } from './mappers/userMapper';
export async function UserOneResolver(
_: any,
{ id }: QueryUserOneArgs,
{ input }: QueryUserOneArgs,
{ identity }: IdentityContext
): Promise<User> {
const model = await prisma.user.findUniqueOrThrow({ where: { id } });
if (input.id == null && input.username == null) throw new Error('Invalid user input.');
if (input.id != null && input.username != null) throw new Error('Invalid user input.');
const model = await prisma.user.findUniqueOrThrow({
where: {
id: input.id != null ? input.id : undefined,
username: input.username != null ? input.username : undefined
}
});
return toUserSchema(model);
}