Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'd like to have the query count per resource available in responce. It's not specified in JSON API, but perhaps it can be treated as meta data:
Where specified, a meta member can be used to include non-standard meta-information.
.
Some further discussion: http://discuss.jsonapi.org/t/pagination-controls/422/
Comment | File | Size | Author |
---|---|---|---|
#7 | 2877041--include-count.patch | 6.51 KB | dpolant |
Comments
Comment #2
tormiComment #3
e0ipsoThis is related to #2746939: [FEATURE] Add pagination metadata.
Comment #4
dawehnerThe query count totally can be helpful, but I suggest to not expose it by default. Counting all elements can be a huge performance loss.
Comment #5
e0ipsoLike @dawehner suggested, we should make sure this behavior is opt-in.
I see this as a global configuration. You either add counts everywhere or nowhere.
Comment #6
sluceroIt doesn't account for the configuration options being discussed here, but for anyone using already using the work in #2746939: [FEATURE] Add pagination metadata as well, I've shared an updated patch to include the total result count in the meta section as described here.
See #2746939-49: [FEATURE] Add pagination metadata for the patch and interdiff specifically adding this to the meta section.
Comment #7
dpolant CreditAttribution: dpolant commentedThis patch adds an include_count config value to the schema and adds a form element on the settings form for setting it. Configurable resource types then look at this global value when deciding the result of their includeCount method.
For more background, see https://www.drupal.org/node/2746939#comment-12136652
Comment #8
e0ipsoI made two minor changes on commit.
We need the FQN.
The docblock for the new parameter is missing.