added user overview
This commit is contained in:
parent
b5738c610d
commit
2ac082a4e4
5 changed files with 107 additions and 14 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue