-
Notifications
You must be signed in to change notification settings - Fork 181
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
Spec violation in connectionFromArraySlice #51
Comments
Yeah, we should probably treat that cursor the same way we would a malformed one. Good catch.
Hm, I'd expect that connectionFromArraySlice( would have similar issues? It would see -5 as the offset and return nothing? |
yup, spot on, negative offsets bug out as well. I was thinking of cursor > length case in which case last / before is okay. I'll pull together a patch for both along with a couple of tests and send them in. Thanks |
Any progress on this? |
Hi,
It looks like there is a spec violation in connectionFromArraySlice implementation. Specifically, spec of the Relay pagination algorithm (4.3 / ApplyCursorsToEdges / Step 2.2) indicates that elements should be removed from the slice only if
afterEdge
exists (ifafterEdge
does not exist,allEdges
are returned) [1]. Here is a counter example:This returns empty edges array. Argument
after
in this case is base64 encoded"arrayconnection:10"
string. Clearly, edge corresponding to that cursor doesn't exist, soconnectionFromArraySlice
should return all six nodes in theedges
array as per the spec.There is no symmetrical issue with last / before combination, because endOffset is set to min of beforeOffset and array length.
Just wanted to confirm that my read of the spec makes sense to you all before sending a pull request with the fix.
Thanks,
Nemanja
[1] Spec: https://facebook.github.io/relay/graphql/connections.htm#ApplyCursorsToEdges()
The text was updated successfully, but these errors were encountered: