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:

  1. Add ResourceType::getLimitMax() (and perhaps ResourceType::getLimitDefault()). Then update JSON:API Extras to make it configurable.
  2. Add jsonapi.pager.max_size container parameter
  3. Don't provide explicit support for this, instead recommend to create a custom param enhancer or KernelEvents::REQUEST subscriber that runs after \Drupal\jsonapi\Routing\JsonApiParamEnhancer::enhance() and does $request->attributes['_json_api_params']['page'] = new OffsetPage(…, CUSTOM_MAX);.

Concerns for each:

  1. 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.
  2. 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

User interface changes

API changes

Data model changes

Release notes snippet

Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

moshe weitzman’s picture

Thanks 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.

wim leers’s picture

Project: JSON:API » Drupal core
Version: 8.x-2.x-dev » 9.3.x-dev
Component: Code » jsonapi.module
Parent issue: » #3032787: [META] Start creating the public PHP API of the JSON:API module
wim leers’s picture

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

maxilein’s picture

For 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

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.