implemented ratings, fixes

This commit is contained in:
lnn0q 2025-06-01 17:54:57 +03:00
parent 4801cf3a13
commit d1da980501
31 changed files with 775 additions and 236 deletions

View file

@ -0,0 +1,26 @@
import { ensureIdentity } from '@app/server/helpers';
import { IdentityContext } from '@app/server/identity';
import { prisma, uuid } from '@app/server/prisma/client';
import { MutationReviewCreateArgs, Review } from '@generated/types';
import { toReviewSchema } from './mappers/reviewMapper';
export async function ReviewCreateResolver(
_: any,
{ input }: MutationReviewCreateArgs,
{ identity }: IdentityContext
): Promise<Review> {
ensureIdentity(identity);
if (input.text.length > 700) throw new Error('Review is too long.');
const model = await prisma.review.create({
data: {
id: uuid(),
text: input.text,
bookId: input.bookId,
userId: identity.id
}
});
return toReviewSchema(model);
}