-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimum Pagination Requirements #165
Comments
See #160, which added the requirement for I'm not convinced A related thought I had on this: transition |
@thekaveman Wonderful! Thanks for pointing that out - sorry I missed it. I agree with your assessment of the benefit of As far as the
As for requiring |
Totally. No harm in those being there, and keeps it closer to a known spec. The
👍
It gets tricky if we "sometimes" allow Another option in that case is to simply leave the But I am by no means saying I am the last word on this. |
Addresses part of #165, by adding an explicit requirement to the README that paginated payloads should include a `next` key at a minimum.
reading through the relevent JSON API docs, my interpretation is as follows
This means that Assuming that we are always hitting next, the required behavior should be once next is |
@black-tea just reading the changes suggested in #166, I would suggest that for those changes we additionally add that either |
Here is what is currently valid under the JSON spec:
{
"version": "x.y.z",
"data": { },
"links": {
"next": "https://..."
}
}
{
"version": "x.y.z",
"data": { },
"links": {
"next": null
}
}
{
"version": "x.y.z",
"data": { },
} Importantly, what is invalid is a missing {
"version": "x.y.z",
"data": { },
"links": { }
} Even if there are other keys present, this is still invalid without {
"version": "x.y.z",
"data": { },
"links": {
"prev": "https://...",
"last": null,
}
} |
Thanks @hunterowens for the suggestion to #166 and @thekaveman for clarifying what we have so far. Based on our conversations with some providers who are saying it is difficult to implement the I also think that a I think that @thekaveman and I are interpreting the spec to not require all 4 links, which is why I think we can get everything by pushing a tighter standard on the |
@black-tea are you saying you don't want this behavior supported, to indicate the last page?
In other words, are you saying: If paging is being done at all (even if it is the last page), |
@thekaveman I'm suggesting that that behavior would be supported if they decide not to paginate, which we would know by the omission of the I was suggesting that this behavior should not be supported: |
If I'll try to rephrase my question. For the purposes of signalling that "this is the last page of data, you don't have to request anything else right now", there are currently 2 different options:
My question is, are you suggesting we only support option 1? I personally don't see a problem allowing the second option, but I don't feel very strongly if option 1 is the only supported option. |
Yes - Sorry - I meant to articulate that I support keeping that restriction as is. For checking the last page, I was just suggesting that we enforce allowing only (1) and not (2). I'm largely in the same camp as you though I think forcing |
Definitely agree with the clarity that From a JSON Schema perspective though, we've already covered that. I don't know if there's anything else we can do in the schema to only allow (1) and not (2), since (2) has to be supported for those providers that choose not to page at all. |
@thekaveman agreed. From a JSON Schema perspective they would be indistinguishable. I was thinking more about adding it to the README to enforce in-practice.
|
Following discussion #165, suggestion adds a explicit requirement for the last page of any paginated payload to return a value of `null` for the `next` key.
* Add `next` link requirement Addresses part of #165, by adding an explicit requirement to the README that paginated payloads should include a `next` key at a minimum. * Revision to for null value on last page Following discussion #165, suggestion adds a explicit requirement for the last page of any paginated payload to return a value of `null` for the `next` key.
I think we're good to close this right @black-tea @hunterowens? |
I think so, given that @hunterowens approved my PR with recommended changes. |
When a provider decides to paginate the payload, the current MDS guidelines specify that pagination must comply with the JSON API specification. The specification requires that
links
be formatted a particular way, but allows that:suggesting that there is no minimum set of required links. In practice, so far I've always seen 'next', but there has been varying levels of implementation for the others. In theory, it seems plausible that a provider could just have both a
first
andlast
page, which would require a different method of iterating through page results than usingnext
.I thought it might be helpful to provide some additional guidance so that we can ensure a standard method for iterating through pages.
Suggestion
Given the flexibility in the JSON API spec above, if a Provider does decide to paginate, we should require at a minimum the
next
link.Additional Questions
null
value, or should we allow thenext
key to be omitted (which would be allowable under the current spec)?next
link? Should re require alast
link? Should we require all four types of links?I think that, at the very least, this would be helpful to provide some guidance. I know we've discussed this a bit with @asadowns. Any other thoughts?
The text was updated successfully, but these errors were encountered: