I'm trying to implement similar to described here filtering model with hotchocolate code-first approach. I need to filter movies if at least one of their actors meets certain criteria. Model looks like this:
public class Movie
{
public IList<Actor> Actors { get; set; }
}
public class Actor { }
public class MovieTypeDef : ObjectType<Movie>
{
protected override void Configure(IObjectTypeDescriptor<Movie> descriptor)
{
descriptor.Field(x => x.Actors)
.Type<NonNullType<ListType<NonNullType<ActorTypeDef>>>>();
}
}
public class ActorTypeDef : ObjectType<Actor> { }
public class Query
{
public IList<Movie> Movies()
{
return new List<Movie>();
}
}
public class QueryTypeDef : ObjectType<Query>
{
protected override void Configure(IObjectTypeDescriptor<Query> descriptor)
{
descriptor.Field(x => x.Movies())
.Type<NonNullType<ListType<MovieTypeDef>>>()
.UseFiltering<MoviesFileringTypeDef>();
}
}
public class MoviesFileringTypeDef : FilterInputType<Movie>
{
protected override void Configure(IFilterInputTypeDescriptor<Movie> descriptor)
{
descriptor.Filter(x => x.Actors) // compilation error
}
}
There seems to be no ability to add custom filter to MoviesFileringTypeDef
since it only allows using properties of Movie
class, and collections are not accepted there.
Is it possible to implement such filter with hotchocolate?