Conversation
Nayte91
force-pushed
the
feat/RFC-8288-links
branch
from
September 17, 2026 17:19
3d40d7f to
94234b5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
2nd step of my issue #7137, as "How to handle pagination, the stanrdized way?". After #7856 that adds Content-Range and Request-Range, we now add a RFCed header that gives link to collection pages, that allow to know how much page do we have in this current collection, giving a nice approximation of the number of items.
Topic
A collection operation that opts in with
paginationLinkHeader: trueanswers with the pagination relations ofRFC 8288 (Web Linking) in the
Linkresponse header:The five relation types are registered at IANA. A HEAD request carries the same header with an empty body
(RFC 9110 §9.3.2), so a client can learn the page count and its own position without parsing a representation,
whatever the format.
Design choices
Implementation
ApiPlatform\State\Processor\PaginationLinkProcessor decorates api_platform.state_processor.respond (priority
420, inside the Hydra link processor) and pushes Symfony\Component\WebLink\Link objects into the
_api_platform_links provider; the existing AddLinkHeaderProcessor serializes them, so the Hydra
apiDocumentation entry and the pagination entries share one header line. The page arithmetic mirrors
Hydra\State\Util\PaginationHelperTrait (the State component cannot depend on Hydra; a marker points at the
duplication). Wired once for both Symfony modes (state/pagination_link.php, loaded unconditionally) and in the
Laravel service provider at the same depth of the respond chain.
Tests
Notes
Happy to flip the default to enabled, or to narrow the flag to HttpOperation only, if you prefer.