Repository navigation
Preserve the declared query parameters in every pagination link. - #14
Merged
Merged
Conversation
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.
Summary
The links of a page (
self,first,prev,nextandlast, in the body and in theLinkheader) were rebuiltfrom
filter,sortandpageonly. Any other query parameter that a route reads was lost in every link. Found inschedule:GET /v1/eligible-waitlist-entries?slot_start_time=...&slot_end_time=...&page[size]=1answered the firstpage with the window, but
links.nextcarried no window, so the second page fell back to the default order and cameback empty although the store held more records. On
GET /v1/availability-overrides?from=...&to=...the loss made thenext page return records outside the window. The service worked around the first route by decoding the JSON the
library produced and rebuilding the response.
A schema now declares the names of the extra parameters its route uses:
Criteria::fromQueryreads the declared parameters from the request and repeats them in every link, betweensortandthe pagination, in the order the request carried them. A declared parameter that did not come is left out, and an
undeclared one is never copied. Names and values are percent-encoded, and a nested value such as
window[from]keeps itsbrackets. A name that is empty, carries a bracket, or equals
filter,sortorpageraisesPreservedParameterIsInvalidwhen the schema declares it, and so does a value that is neither a string nor a nestedarray of strings. The library reads the values from the request itself, so they never diverge from what the client
sent, and the consumer declares only names.
Public API: backward compatible.
Schema::preserving,PreservedParametersandPreservedParameterIsInvalidare theadditions, and
Links::from,Offset\Page::from,Offset\Slice::from,Cursor\Page::fromandCursor\Keyset::fromgain an optional
?PreservedParameters $preserved = nullas the last argument, so the release is2.7.0. Without adeclaration the links are the ones of
2.6.1.Related issue
None.
Checklist
Linkheader, adeclared parameter that did not come, an undeclared one, nested values, reserved characters in names and values, and
the invalid names and values.
window of
fromandtoand ofslot_start_timeandslot_end_timeas the example.make reviewpasses.make testspasses. 440 tests, lines 100% (1072/1072), MSI 100% (803 of 803 killed).