17 lines
469 B
TypeScript
17 lines
469 B
TypeScript
import { IdentityContext } from '@app/server/identity';
|
|
import { prisma } from '@app/server/prisma/client';
|
|
import { Book, QueryBookOneArgs } from '@generated/types';
|
|
import { toBookSchema } from './mappers/bookMapper';
|
|
|
|
export async function BookOneResolver(
|
|
_: any,
|
|
{ id }: QueryBookOneArgs,
|
|
{ identity }: IdentityContext
|
|
): Promise<Book> {
|
|
const model = await prisma.book.findUniqueOrThrow({
|
|
where: {
|
|
id
|
|
}
|
|
});
|
|
return toBookSchema(model);
|
|
}
|