I have a problem using GraphQL with the HotChocolate library in a C# backend. When I use filtering the whole table is loaded and after that it is filtered. This of course means an awful performance as a full table scan is performed each time.
This is the query
[UseFiltering]
public IQueryable<Person> GetFilteredPersons(
[Service] IPersonRepo repo)
{
return repo.GetAll().AsQueryable();
}
And this is the repo
public IEnumerable<Person> GetAll()
{
var query = "SELECT * FROM Persons";
var param = new DynamicParameters();
return SqlMapper.Query<Person>(GetConnection()
query, param,
commandType: CommandType.Text);
}
How can I make the filters be passed to the WHERE clause? Maybe with DapperExtensions using a predicate? It would be hard anyway as the filters are not really accessible in the GraphQL query.