We have a very simple scenario where I need to return data from the database.
Some actions require pagination on the data, but others do not. For this second case, I just need to return all the data (with no pagination).
Does anyone know a way for creating a single query type to solve both situations instead of two query types?
Trying to find a good way, we needed to remove all the attributes to enable HotChocolate for returning all Users on the database, and another query for the pagination.
First Query Type
[UseDbContext(typeof(MyContext)), UseOffsetPaging, UseFiltering, UseSorting]
public IQueryable<User> Users(ClaimsPrincipal claims, [Service] MyContext context)
{
return context.Users;
}
Second Query Type (that we want to remove, and mix with a single query, mixed with the pagination features)
[UseDbContext(typeof(MyContext))]
public IQueryable<User> GetAllUsers(ClaimsPrincipal claims, [Service] MyContext context)
{
return context.Users;
}
Is there a way to expose a single query type for both scenarios? Pagination and Get All?
Thank you!