在 GraphQL HotChocolate 上过滤 EF Core 导航属性

问题描述

我在 EF Core 中使用 HotChocolate (11.2.2) 并想过滤子属性。根据 GraphQL 文档,这应该可以通过在导航属性上使用 filter 关键字来实现,但 HotChocolate 却失败了。

我的架构:

0.00000001

这得到了 EF 的支持,我向 HotChocolate 提供了一个 type A { Name: string,RefTo: [B] } type B { TypeName: string,Value: int }

IQueryable<A>

现在我只想包括那些 [UsePaging] [UseProjection] [UseFiltering] [UseSorting] public IQueryable<A> GetAs([Service] Context db) => db.As.AsSingleQuery().AsNoTrackingWithIdentityResolution(); 等于 BTypeName,如下所示:

"ExampleType"

但 HotChcolate 似乎不明白这一点并说:

字段“A.RefTo”.validation 上的未知参数“where”

是否可以使用 EF Core 模型过滤导航属性?

解决方法

您也必须向 RefTo 添加过滤

ssl_certificate /etc/letsencrypt/domain.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/domain.example.com/privkey.pem;

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...