问题描述
我在 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();
等于 B
的 TypeName
,如下所示:
"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;