graphql - 带有 GraphQL 的 Nestjs:如何在 @Resolver 方法的 @Arg 中传递 where 子句?
问题描述
我想让 Nestjs 中的 Graphql 解析器接受 where 子句,然后 Prisma 服务使用它来动态接受给定资源的不同搜索类型。我现在拥有的是:
//task.resolver.ts
@Resolver((of) => Task)
export class TaskResolver {
constructor(private repository: TaskRepository) {}
@Query((returns) => [Task])
@UseGuards(JwtAuthGuard)
async tasks(
@Args('where', { type: () => <Dont know the type> }) where: Prisma.TaskWhereInput,
) {
return await this.repository.tasks({
where,
});
}
}
我只是希望解析器方法能够处理 where 子句,例如:
// GraphQL client query
query GetTasks($id: ID!, $level: Int!) {
tasks(
where: { user: { id: $id }, taskTemplate: { level: $level } }
) {
id
state
taskTemplate {
title
level
}
}
}
解决方案
推荐阅读
- python - 如何解决或识别神经网络中的问题,可以在 Tensorboard Graphs 上看到
- definition - Nearley 标记器与规则
- php - 在 Woocommerce 3 中添加 3 个结帐选择字段作为复合日期字段
- coq - Coq:当只有一种情况时对 Prop for Set 执行反转
- python - Python 和队列文件管理
- asp.net - 引导弹出框内的 asp 复选框 oncheckedchanged 未触发
- javascript - 用零数据填充日志
- python - Tweepy error code 400
- javascript - puppeteer : how check if browser is still open and working
- amazon-web-services - Amazon EC2 - How to execute the 'launch" part of a Cross-Account AMI Copy?