implemented ratings, fixes
This commit is contained in:
parent
4801cf3a13
commit
d1da980501
31 changed files with 775 additions and 236 deletions
26
app/server/graphql/resolvers/reviewManyResolver.ts
Normal file
26
app/server/graphql/resolvers/reviewManyResolver.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { IdentityContext } from '@app/server/identity';
|
||||
import { prisma } from '@app/server/prisma/client';
|
||||
import { QueryReviewManyArgs, ReviewManyOutput } from '@generated/types';
|
||||
import { toReviewSchema } from './mappers/reviewMapper';
|
||||
|
||||
export async function ReviewManyResolver(
|
||||
_: any,
|
||||
{ input }: QueryReviewManyArgs,
|
||||
{ req, res, identity }: IdentityContext
|
||||
): Promise<ReviewManyOutput> {
|
||||
const { bookId, filter } = input;
|
||||
|
||||
const items = await prisma.review.findMany({
|
||||
where: { bookId },
|
||||
skip: filter.offset ?? 0,
|
||||
take: filter.size ?? 10,
|
||||
orderBy: {
|
||||
createdAt: 'desc'
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
items: await Promise.all(items.map(value => toReviewSchema(value))),
|
||||
total: await prisma.review.count({ where: { bookId } })
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue