π§© QueryService β
QueryService wraps a Prisma-compatible delegate. It does not import Prisma at runtime; generated Prisma types stay in your application and are connected through a small type map.
𧬠Type Map β
import { Injectable } from '@nestjs/common';
import { QueryService, type BaseDelegateTypeMap } from '@querry-kit/nest-prisma-query';
import { Prisma, PrismaService } from '../prisma';
interface ProjectTypeMap extends BaseDelegateTypeMap {
select: Prisma.ProjectSelect;
include: Prisma.ProjectInclude;
whereInput: Prisma.ProjectWhereInput;
orderByWithRelationInput: Prisma.ProjectOrderByWithRelationInput;
whereUniqueInput: Prisma.ProjectWhereUniqueInput;
scalarFieldEnum: Prisma.ProjectScalarFieldEnum;
}
@Injectable()
export class ProjectsService extends QueryService<typeof PrismaService.prototype.project, ProjectTypeMap> {
constructor(prisma: PrismaService) {
super(prisma.project);
}
}βοΈ Methods β
await projectsService.findOne({ where: { slug: 'alpha' } });
await projectsService.findMany({ where: { archived: false }, orderBy: { name: 'asc' } });
await projectsService.findById('project_1', { include: { members: true } });
await projectsService.findUnique({ where: { slug: 'alpha' } });
await projectsService.aggregate({ where: { archived: false }, _count: true });
await projectsService.count({ where: { archived: false } });query combines findMany, count, and PageMetaDTO:
const { items, pageMeta } = await projectsService.query({
page: 2,
perPage: 25,
where: { archived: false },
orderBy: { name: 'asc' },
});π Query Parsing β
Inputs are normalized with parseQueryObject, a public wrapper around @querry-kit/nest-util/object.
parseQueryObject({
'owner.email': 'ada@example.com',
archived: 'false',
tags: '["crm","internal"]',
});
// {
// owner: { email: 'ada@example.com' },
// archived: false,
// tags: ['crm', 'internal']
// }Invalid JSON-like strings are preserved instead of throwing during parsing. Prisma validation errors are converted later by QueryService.
Aggregate results are passed through serializeDecimalValues, which keeps the public Prisma-query API local while delegating Decimal-like object traversal to @querry-kit/nest-util/object when that utility is available.
π¨ Error Mapping β
Prisma validation-like errors become BadRequestException. Known Prisma request errors with a code become BadRequestException. Existing Nest HttpException instances pass through. Unexpected errors are logged through errorLogger when configured and then masked as InternalServerErrorException.