You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote a little about it here, but basically after = Math.max(before - last - 1, 0).
So if you implement first and after, you automatically get the functionality of last and before without needing to change much at all as first and after is the same as last and before.
It makes me think that the equivalency should be in the spec and that we should add the function below to graphql-relay-js.
export function transformBackwardToForward(args) {
const { last, before } = args;
const afterOffset = Math.max(cursorToOffset(before) - last - 1, 0);
return { first: last, after: offsetToCursor(afterOffset) };
}
Has anyone else solved pagination this way?
This might be worth looking into as it seems that many have problems with pagination by looking at #94.
What do you guys think about this implementation overall, good/bad?
The text was updated successfully, but these errors were encountered:
nijynot
changed the title
Backwards arguments are equivalent to forward arguments
[RFC] Backwards arguments are equivalent to forward arguments
Feb 18, 2018
I wrote a little about it here, but basically
after = Math.max(before - last - 1, 0)
.So if you implement
first
andafter
, you automatically get the functionality oflast
andbefore
without needing to change much at all asfirst
andafter
is the same aslast
andbefore
.It makes me think that the equivalency should be in the spec and that we should add the function below to
graphql-relay-js
.Has anyone else solved pagination this way?
This might be worth looking into as it seems that many have problems with pagination by looking at #94.
What do you guys think about this implementation overall, good/bad?
The text was updated successfully, but these errors were encountered: