I want to dynamically set value to MaxPageSize
in UseOffsetPaging
rather than global setting.
How to do that?
Following are ways to set it, either globally OR per query. But what I want is, set it per query as shown in "Desired Result" block below. I do not want to go to cursor based pagination unless that is the only option.
Option-1:
[UseOffsetPaging(MaxPageSize = YOUR-VALUE)]
Option-2:
.SetPagingOptions(new PagingOptions
{
IncludeTotalCount = true,
MaxPageSize = int.MaxValue
})
Desired Result:
public partial class Query
{
[UseOffsetPaging(MaxPageSize = take)] // Use take value which is coming from UI
public async Task MyQuery(
[GraphQLNonNullType]
int skip,
[GraphQLNonNullType]
int take)
=> await doSomething;
}
Reference:
https://chillicream.com/docs/hotchocolate/v13/fetching-data/pagination/#pagingoptions