-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow the after cursor to be an empty string (same as offset: 0)
- Loading branch information
1 parent
cb7565d
commit 5070070
Showing
4 changed files
with
223 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
Test.gql("forward pagination", function(t) | ||
local fetchTeams = function(after) | ||
t.query(string.format([[ | ||
query { | ||
teams(first:5 after:"%s") { | ||
pageInfo { | ||
hasNextPage | ||
endCursor | ||
} | ||
edges { | ||
node { | ||
slug | ||
} | ||
cursor | ||
} | ||
} | ||
} | ||
]], after)) | ||
end | ||
|
||
fetchTeams("") | ||
t.check { | ||
data = { | ||
teams = { | ||
pageInfo = { | ||
hasNextPage = true, | ||
endCursor = Save("endCursor"), | ||
}, | ||
edges = { | ||
{ | ||
node = { | ||
slug = "slug-1", | ||
}, | ||
cursor = Ignore(), | ||
}, | ||
{ | ||
node = { | ||
slug = "slug-10", | ||
}, | ||
cursor = Ignore(), | ||
}, | ||
{ | ||
node = { | ||
slug = "slug-11", | ||
}, | ||
cursor = Ignore(), | ||
}, | ||
{ | ||
node = { | ||
slug = "slug-12", | ||
}, | ||
cursor = Ignore(), | ||
}, | ||
{ | ||
node = { | ||
slug = "slug-13", | ||
}, | ||
cursor = Save("lastNodeInPageCursor"), | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
assert(State.lastNodeInPageCursor == State.endCursor, "lastNodeInPageCursor is not equal to endCursor") | ||
|
||
fetchTeams(State.endCursor) | ||
t.check { | ||
data = { | ||
teams = { | ||
pageInfo = { | ||
hasNextPage = true, | ||
endCursor = Save("endCursor"), | ||
}, | ||
edges = { | ||
{ | ||
node = { | ||
slug = "slug-14", | ||
}, | ||
cursor = Ignore(), | ||
}, | ||
{ | ||
node = { | ||
slug = "slug-15", | ||
}, | ||
cursor = Ignore(), | ||
}, | ||
{ | ||
node = { | ||
slug = "slug-16", | ||
}, | ||
cursor = Ignore(), | ||
}, | ||
{ | ||
node = { | ||
slug = "slug-17", | ||
}, | ||
cursor = Ignore(), | ||
}, | ||
{ | ||
node = { | ||
slug = "slug-18", | ||
}, | ||
cursor = Save("lastNodeInPageCursor"), | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
assert(State.lastNodeInPageCursor == State.endCursor, "lastNodeInPageCursor is not equal to endCursor") | ||
|
||
fetchTeams(State.endCursor) | ||
t.check { | ||
data = { | ||
teams = { | ||
pageInfo = { | ||
hasNextPage = true, | ||
endCursor = Save("endCursor"), | ||
}, | ||
edges = { | ||
{ | ||
node = { | ||
slug = "slug-19", | ||
}, | ||
cursor = Ignore(), | ||
}, | ||
{ | ||
node = { | ||
slug = "slug-2", | ||
}, | ||
cursor = Ignore(), | ||
}, | ||
{ | ||
node = { | ||
slug = "slug-20", | ||
}, | ||
cursor = Ignore(), | ||
}, | ||
{ | ||
node = { | ||
slug = "slug-3", | ||
}, | ||
cursor = Ignore(), | ||
}, | ||
{ | ||
node = { | ||
slug = "slug-4", | ||
}, | ||
cursor = Save("lastNodeInPageCursor"), | ||
}, | ||
|
||
}, | ||
}, | ||
}, | ||
} | ||
|
||
assert(State.lastNodeInPageCursor == State.endCursor, "lastNodeInPageCursor is not equal to endCursor") | ||
|
||
fetchTeams(State.endCursor) | ||
t.check { | ||
data = { | ||
teams = { | ||
pageInfo = { | ||
hasNextPage = false, | ||
endCursor = Save("endCursor"), | ||
}, | ||
edges = { | ||
{ | ||
node = { | ||
slug = "slug-5", | ||
}, | ||
cursor = Ignore(), | ||
}, | ||
{ | ||
node = { | ||
slug = "slug-6", | ||
}, | ||
cursor = Ignore(), | ||
}, | ||
{ | ||
node = { | ||
slug = "slug-7", | ||
}, | ||
cursor = Ignore(), | ||
}, | ||
{ | ||
node = { | ||
slug = "slug-8", | ||
}, | ||
cursor = Ignore(), | ||
}, | ||
{ | ||
node = { | ||
slug = "slug-9", | ||
}, | ||
cursor = Save("lastNodeInPageCursor"), | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
assert(State.lastNodeInPageCursor == State.endCursor, "lastNodeInPageCursor is not equal to endCursor") | ||
end) |
This file contains 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
This file contains 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
This file contains 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