strawberry-django icon indicating copy to clipboard operation
strawberry-django copied to clipboard

Default pagination default max

Open patrick91 opened this issue 2 years ago • 3 comments

We should a default to the standard pagination 😊

patrick91 avatar Jul 15 '23 09:07 patrick91

The current implementation, when passing pagination=True to the field or to the type (which means including it on all fields) is to add this input in the arguments and apply it to the queryset when passed to the query.

Maybe we should have a default "max results" on django settings, defaulting to 100 maybe, and type limit: Optional[int] = None.

Some things to consider:

  1. limit is currently defaulting to -1. I'm not sure why as, considering the implementation, is basically means that not passing a limit would make the code either break (qs[0:-1] raises an error) or not work (qs[10:-9] returns no results)

  2. But because of that, that also means that when someone uses the pagination, they are probably passing a limit together, meaning the change in typing should not break anything.

  3. In the current implementation, when no pagination is passed the queryset will not be limited. Should we enforce the limit to that "max results", as long as the field has pagination=True?

bellini666 avatar Jul 15 '23 15:07 bellini666

In my use case, it would be ideal to also set an absolute max on the what the limit value can be.

jcuenod avatar Oct 23 '23 21:10 jcuenod

In my use case, it would be ideal to also set an absolute max on the what the limit value can be.

yes, definitely, we shouldn't allow to fetch too many things

patrick91 avatar Oct 24 '23 23:10 patrick91