problems
- easy to forget default limit is there - get dropdowns with just a few options, etc
- have to specify arbitrary-ish big number for page_sizeto remove limit. how to choose?
benefits
- not having to remember to implement paging
- query performance by default
possible solutions
- don't used PagedView<>for lookups or queries where consumer probably won't want paging
- don't make page_numberoptional for queries with paging: throw error if missing. can't mistake that it's a paged view then
- only use paging if page_number/page_sizespecified
KJ - prefer 1&2, 3 could mean getting in the habit of not paging, having slow queries + big results pages?
I've had a look around at paged endpoints in other public APIs and the general approach seems to be as follows:
pageSizeandpageNumberto have default values. A lot of the time this seems to be in the region of 20 items per page.pageSizehas a maximum number that you can supply to it. This mostly seems to be 100 items (this could vary depending upon the complexity of the query).Based upon this I suggest the following approaches:
pageSizeandpageNumberdefaults to whatever is the typical view on the frontend. So our current typical values of 10 and 1 are probably fine.pageSizeto prevent large queries being executed. This could easily be implemented as part of the validators (there are alreadyrequirePageSizeandrequirePageNumbervalidators that should be being used). Probably a default of 100 but can be overridden as a parameter on therequirePageSizefunction.