我正在使用带有 EF Core 的 HotChocolate (11.2.2) 并且想要过滤子属性。根据 GraphQL 文档,这应该可以通过在导航属性上使用 filter 关键字来实现,但 HotChocolate 只是失败了。
我的架构:
type A {
Name: string,
RefTo: [B]
}
type B {
TypeName: string,
Value: int
}
这是由 EF 支持的,我为IQueryable<A>
HotChocolate 提供了一个。
[UsePaging]
[UseProjection]
[UseFiltering]
[UseSorting]
public IQueryable<A> GetAs([Service] Context db) => db.As.AsSingleQuery().AsNoTrackingWithIdentityResolution();
现在我只想包括那些等于这样B
的 s :TypeName
"ExampleType"
query {
As {
Name,
RefTo(where: { TypeName: { eq: "ExampleType" } })
{
TypeName,
Value
}
}
}
但 HotChcolate 似乎并不理解这一点,并说:
字段“A.RefTo”.validation 上的未知参数“where”
是否可以使用 EF Core 模型过滤导航属性?