17 lines
566 B
TypeScript
17 lines
566 B
TypeScript
import { IdentityContext } from '@app/server/identity';
|
|
import { prisma } from '@app/server/prisma/client';
|
|
import { BookChapter, QueryBookChapterOneArgs } from '@generated/types';
|
|
import { toBookChapterSchema } from './mappers/bookChapterMapper';
|
|
|
|
export async function BookChapterOneResolver(
|
|
_: any,
|
|
{ id }: QueryBookChapterOneArgs,
|
|
{ req, res, identity }: IdentityContext
|
|
): Promise<BookChapter> {
|
|
const model = await prisma.bookChapter.findUniqueOrThrow({
|
|
where: {
|
|
id
|
|
}
|
|
});
|
|
return toBookChapterSchema(model, { req, res, identity });
|
|
}
|