Problem/Motivation
@moshe requested this during last week's API-First Initiative meeting. We discussed it at length in Slack, sadly Slack ate the history.
Proposed resolution
From most to least work:
- Add
ResourceType::getLimitMax()(and perhapsResourceType::getLimitDefault()). Then update JSON:API Extras to make it configurable. - Add
jsonapi.pager.max_sizecontainer parameter - Don't provide explicit support for this, instead recommend to create a custom param enhancer or
KernelEvents::REQUESTsubscriber that runs after\Drupal\jsonapi\Routing\JsonApiParamEnhancer::enhance()and does$request->attributes['_json_api_params']['page'] = new OffsetPage(…, CUSTOM_MAX);.
Concerns for each:
- Tying the limit to a resource type means we don't know what the limit would be for mixed bundles (#2956414: Support mixed-bundle collections (e.g. `/jsonapi/node`)) or when dealing with search (#2991729: Ability to define a "full text search" filter, e.g. using Elasticsearch). In other words: this would be a nice fit today, but it likely will get in the way in the future, when expanding JSON:API's capabilities.
- Hard. But this is okay, we want to discourage customization, and encourage experience reports to steer tweaking defaults. Moshe's use case is very particular.
Remaining tasks
TBD
Comments
Comment #2
wim leersComment #3
wim leersComment #4
moshe weitzman commentedThanks for writing up some possible approaches. Hopefully someone will jump on one.
I worked around my need by patching core to allow more normalizers. Thats the solution that was already in use so was least effort solution.
Comment #5
wim leersComment #6
wim leersMarked #3218605: List of taxonomy terms limited to first 50 as a duplicate of this.
Comment #11
maxilein commentedFor the time being may I add this:
There is the JSON:API Page Limit module and also JSON API Defaults (part of the popular JSON:API Extras module) to change the limit.
After you have installed the JSON API Defaults module go to
http://example.com/admin/config/services/jsonapi/add/resource_types/taxo...
and change the page limit at the bottom of the config form.
Then you can request a higher number of items with the query parameter page[limit]:
http://example.com/jsonapi/taxonomy_term/[vocabulary]?page[limit]=1000