feat: prisma typed select (#347)
* feat: wip prisma gql select * feat: stronger api using decorator * feat: add PrismaSelect everywhere * fix: remove unused * fix: remove seed debug
This commit is contained in:
@ -8,6 +8,10 @@ import { Comment } from '../../../core/@generated/comment/comment.model';
|
||||
import { CreateOneCommentGuard } from '../../../guards/create-one-comment.guard';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { CommentService } from '../services/comment.service';
|
||||
import {
|
||||
PrismaSelector,
|
||||
PrismaSelect,
|
||||
} from 'src/decorators/prisma-select.decorator';
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Resolver(() => Comment)
|
||||
@ -21,12 +25,15 @@ export class CommentResolver {
|
||||
async createOneComment(
|
||||
@Args() args: CreateOneCommentArgs,
|
||||
@AuthWorkspace() workspace: Workspace,
|
||||
): Promise<Comment> {
|
||||
@PrismaSelector({ modelName: 'Comment' })
|
||||
prismaSelect: PrismaSelect<'Comment'>,
|
||||
): Promise<Partial<Comment>> {
|
||||
return this.commentService.create({
|
||||
data: {
|
||||
...args.data,
|
||||
...{ workspace: { connect: { id: workspace.id } } },
|
||||
},
|
||||
} satisfies CreateOneCommentArgs as Prisma.CommentCreateArgs);
|
||||
select: prismaSelect.value,
|
||||
} as Prisma.CommentCreateArgs);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user