I am using HotChocolate (11.2.2) with EF Core and want to filter a sub property. According to the GraphQL docu this should be possible by using the filter keyword on the navigation property but HotChocolate just fails.
My schema:
type A {
Name: string,
RefTo: [B]
}
type B {
TypeName: string,
Value: int
}
This is backed by EF and I provide an IQueryable<A>
to HotChocolate.
[UsePaging]
[UseProjection]
[UseFiltering]
[UseSorting]
public IQueryable<A> GetAs([Service] Context db) => db.As.AsSingleQuery().AsNoTrackingWithIdentityResolution();
Now I want to include only those B
s where the TypeName
is equal to "ExampleType"
like this:
query {
As {
Name,
RefTo(where: { TypeName: { eq: "ExampleType" } })
{
TypeName,
Value
}
}
}
But HotChcolate does not seem to understand this and says:
Unknown argument "where" on field "A.RefTo".validation
Is it possible to filter Navigation Properties with an EF Core model?
You would have to add filtering to RefTo too
[UseFiltering]
public ICollection<A> RefTo {get; set;}