【发布时间】:2021-04-23 15:11:19
【问题描述】:
我正在使用带有 EF Core 的 HotChocolate (11.2.2) 并且想要过滤子属性。根据 GraphQL 文档,这应该可以通过在导航属性上使用 filter 关键字来实现,但 HotChocolate 只是失败了。
我的架构:
type A {
Name: string,
RefTo: [B]
}
type B {
TypeName: string,
Value: int
}
这得到了 EF 的支持,我向 HotChocolate 提供了一个IQueryable<A>。
[UsePaging]
[UseProjection]
[UseFiltering]
[UseSorting]
public IQueryable<A> GetAs([Service] Context db) => db.As.AsSingleQuery().AsNoTrackingWithIdentityResolution();
现在我想只包含那些TypeName 等于"ExampleType" 的Bs,如下所示:
query {
As {
Name,
RefTo(where: { TypeName: { eq: "ExampleType" } })
{
TypeName,
Value
}
}
}
但 HotChcolate 似乎不明白这一点,并说:
字段“A.RefTo”.validation 上的未知参数“where”
是否可以使用 EF Core 模型过滤导航属性?
【问题讨论】:
标签: c# graphql entity-framework-core hotchocolate