Enable to force-disable pagination per relationship #1750
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In cases where the total number of resources of a certain type is high, but the number of related resources is consistently low, it becomes easier for clients to build master/detail views when they don't need to consider nested pagination.
For example, the total number of products in a web shop is typically high, but the number of products in a shopping basket is typically low. This PR enables turning off pagination for that relationship (while leaving the default page size activated):
The effect is that pagination on
products
will be disabled for the following requests:/shoppingBaskets?include=products
/shoppingBaskets/1?include=products
/shoppingBaskets/1/products
/shoppingBaskets/1/products?page[size]=25
Additionally, when pagination is set from a resource definition, it does not get applied. This is because resource definitions operate on resource types. The new property on a relationship overrules that, similar to how setting links on a relationship overrules the links defined on a resource type.
Caution
Only use this property when the set of related resources is known to be small. Take into account the full size of any nested includes.
For example, when the default page size is 50 and each basket contains 125 products, and each product contains 80 discount rules, the request
/shoppingBaskets?include=products.discountRules
returns a total of 50 (baskets) * 125 (products) * 50 (rules) = 312,500 resources!Fixes #1731.
QUALITY CHECKLIST