17 lines
503 B
TypeScript
17 lines
503 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,
|
|
{ req, res, identity }: IdentityContext
|
|
): Promise<Book> {
|
|
const model = await prisma.book.findUniqueOrThrow({
|
|
where: {
|
|
id
|
|
}
|
|
});
|
|
return toBookSchema(model, { req, res, identity });
|
|
}
|