craftcms / element-api

Create a JSON API/Feed for your elements in Craft.
MIT License
498 stars 57 forks source link

Are `paginate` and `elementsPerPage` really necessary? #28

Closed johndwells closed 7 years ago

johndwells commented 7 years ago

When providing an endpoint with an ElementCriteriaModel, it already contains a limit attribute, which to my mind is exactly what elementsPerPage represents. And it would seem that, unless limit were explicitly set to null, that pagination is expected as part of the response.

With that in mind, are these configurations really necessary?

timkelty commented 7 years ago

And it would seem that, unless limit were explicitly set to null, that pagination is expected as part of the response.

I think you'd still want paginate (maybe defaulting to true). Just in case you only wanted x amount of results and didn't care about other pages.

But yeah - I'm not sure about why we can't just use the limit from the ElementCriteriaModel as well.

brandonkelly commented 7 years ago

The response JSON is formatted differently if it’s paginated, so I definitely think that’s something that needs to be explicitly enabled via the paginate param.

limit vs elementsPerPage… I could go either way, but by keeping elementsPerPage around, we have the option to support offset and limit params down the road, independently of elementsPerPage. For example, if you only wanted to expose the first 100 entries, and you want to paginate them @ 10 entries per page, you could do that by setting elemenstPerPage to 10 and limit to 100. (Not possible right now but would be easily doable if/when someone needs it.)