Thinking about this, take is something we already have, except that we call it first/last.
Example for forward pagination:
table(first: 10, after: "...")
{
items
{
col1
col2
}
}
This is conceptually the same as:
table(take: 10, after: "...")
{
items
{
col1
col2
}
}
Example for backwards pagination:
table(last: 10, before: "...")
{
items
{
col1
col2
}
}
which, again, is conceptually the same as:
table(take: 10, before: "...")
{
items
{
col1
col2
}
}
What we need to provide is an extra argument that would first skip N items before taking M:
table(skip: 5, first: 10, after: "...")
{
items
{
col1
col2
}
}
The effect here it would be that given the following dataset:
ID
Name
1
Aaa
2
Bbb
3
Ccc
4
Ddd
5
Eee
6
Fff
7
Ggg
8
Hhh
9
Iii
10
Jjj
11
Kkk
12
Lll
13
Mmm
14
Nnn
15
Ooo
16
Ppp
17
Qqq
18
Rrr
19
Sss
20
Ttt
Suppose that we call this:
with the after argument, then {Aaa, Bbb, Ccc, Ddd, Eee} are skipped and the return set contains {Fff, Ggg, Hhh, Iii, Jjj, Kkk, Lll, Mmm, Nnn, Ooo}
with the after argument set at "cursor-of-Jjj", then {Kkk, Lll, Mmm, Nnn, Ooo} are skipped and the return set contains {Ppp, Qqq, Rrr, Sss, Ttt}
This would work the same regardless of the order of the three arguments, skip, first, after.
Also, this would work the same for backwards pagination, with the arguments skip, last, before.
In the GraphQL context, skip does not make sense alone. Meaning that you are supposed to ask for at least one record after skipping some records. Also, it doesn't make sense that you first take and then skip. That should translate into two operations, with the first you take N records, and with the second you first skip M then take K more.
... View more