Skip to content

Commit e1efcea

Browse files
committed
graphql-alt: Object version pagination
## Description Adding infrastructure for pagination, filters and filter intersection, and using it to implement pagination for object versions, exposed in the following fields: - `Query.objectVersions` - `Object.objectVersionsBefore` - `Object.objectVersionsAfter` ## Test plan New unit tests for pagination logic: ``` sui$ cargo nextest run \ -p sui-indexer-alt-graphql \ -- pagination ``` New E2E tests for new object pagination methods: ``` sui$ cargo nextest run \ -p sui-indexer-alt-e2e-tests \ -- graphql/objects/object_versions ```
1 parent cab540d commit e1efcea

File tree

14 files changed

+1503
-10
lines changed

14 files changed

+1503
-10
lines changed
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
// Copyright (c) Mysten Labs, Inc.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
//# init --protocol-version 70 --accounts A --addresses P=0x0 --simulator
5+
6+
//# programmable --sender A --inputs 1
7+
//> SplitCoins(Gas, [Input(0)]);
8+
//> MergeCoins(Gas, [Result(0)])
9+
10+
//# programmable --sender A --inputs 1
11+
//> SplitCoins(Gas, [Input(0)]);
12+
//> MergeCoins(Gas, [Result(0)])
13+
14+
//# create-checkpoint
15+
16+
//# programmable --sender A --inputs 1
17+
//> SplitCoins(Gas, [Input(0)]);
18+
//> MergeCoins(Gas, [Result(0)])
19+
20+
//# programmable --sender A --inputs 1
21+
//> SplitCoins(Gas, [Input(0)]);
22+
//> MergeCoins(Gas, [Result(0)])
23+
24+
//# create-checkpoint
25+
26+
//# programmable --sender A --inputs 1
27+
//> SplitCoins(Gas, [Input(0)]);
28+
//> MergeCoins(Gas, [Result(0)])
29+
30+
//# create-checkpoint
31+
32+
//# run-graphql
33+
{ # Fetch all object versions -- there should be 6 of these.
34+
objectVersions(address: "@{obj_0_0}") {
35+
pageInfo {
36+
hasPreviousPage
37+
hasNextPage
38+
startCursor
39+
endCursor
40+
}
41+
edges {
42+
cursor
43+
node {
44+
address
45+
version
46+
objectBcs
47+
}
48+
}
49+
}
50+
}
51+
52+
//# run-graphql
53+
{ # Limit from the front
54+
objectVersions(address: "@{obj_0_0}", first: 3) {
55+
pageInfo {
56+
hasPreviousPage
57+
hasNextPage
58+
startCursor
59+
endCursor
60+
}
61+
nodes { version }
62+
}
63+
}
64+
65+
//# run-graphql
66+
{ # Limit from the back
67+
objectVersions(address: "@{obj_0_0}", last: 3) {
68+
pageInfo {
69+
hasPreviousPage
70+
hasNextPage
71+
startCursor
72+
endCursor
73+
}
74+
nodes { version }
75+
}
76+
}
77+
78+
//# run-graphql --cursors 1
79+
{ # Offset at the front and then fetch from the front
80+
objectVersions(address: "@{obj_0_0}", after: "@{cursor_0}", first: 3) {
81+
pageInfo {
82+
hasPreviousPage
83+
hasNextPage
84+
startCursor
85+
endCursor
86+
}
87+
nodes { version }
88+
}
89+
}
90+
91+
//# run-graphql --cursors 4
92+
{ # Offset at the front such that the first page is not full
93+
objectVersions(address: "@{obj_0_0}", after: "@{cursor_0}", first: 5) {
94+
pageInfo {
95+
hasPreviousPage
96+
hasNextPage
97+
startCursor
98+
endCursor
99+
}
100+
nodes { version }
101+
}
102+
}
103+
104+
//# run-graphql --cursors 4
105+
{ # Offset at the front such that the first page is not full, fetch from the back
106+
objectVersions(address: "@{obj_0_0}", after: "@{cursor_0}", last: 5) {
107+
pageInfo {
108+
hasPreviousPage
109+
hasNextPage
110+
startCursor
111+
endCursor
112+
}
113+
nodes { version }
114+
}
115+
}
116+
117+
//# run-graphql --cursors 5
118+
{ # Offset at the back and fetch from the back
119+
objectVersions(address: "@{obj_0_0}", before: "@{cursor_0}", last: 3) {
120+
pageInfo {
121+
hasPreviousPage
122+
hasNextPage
123+
startCursor
124+
endCursor
125+
}
126+
nodes { version }
127+
}
128+
}
129+
130+
//# run-graphql --cursors 5
131+
{ # Offset at the back and fetch from the front
132+
objectVersions(address: "@{obj_0_0}", before: "@{cursor_0}", first: 3) {
133+
pageInfo {
134+
hasPreviousPage
135+
hasNextPage
136+
startCursor
137+
endCursor
138+
}
139+
nodes { version }
140+
}
141+
}
142+
143+
//# run-graphql --cursors 2
144+
{ # Offset at the back such that the first page is not full, fetch from the back
145+
objectVersions(address: "@{obj_0_0}", before: "@{cursor_0}", last: 5) {
146+
pageInfo {
147+
hasPreviousPage
148+
hasNextPage
149+
startCursor
150+
endCursor
151+
}
152+
nodes { version }
153+
}
154+
}
155+
156+
//# run-graphql --cursors 2
157+
{ # Offset at the back such that the first page is not full, fetch from the front
158+
objectVersions(address: "@{obj_0_0}", before: "@{cursor_0}", first: 5) {
159+
pageInfo {
160+
hasPreviousPage
161+
hasNextPage
162+
startCursor
163+
endCursor
164+
}
165+
nodes { version }
166+
}
167+
}
168+
169+
//# run-graphql --cursors 1 4
170+
{ # Offset at the front and back
171+
objectVersions(address: "@{obj_0_0}", after: "@{cursor_0}", before: "@{cursor_1}") {
172+
pageInfo {
173+
hasPreviousPage
174+
hasNextPage
175+
startCursor
176+
endCursor
177+
}
178+
nodes { version }
179+
}
180+
}
181+
182+
//# run-graphql --cursors 1 4
183+
{ # Offset at the front and back, limit at the front
184+
objectVersions(address: "@{obj_0_0}", after: "@{cursor_0}", before: "@{cursor_1}", first: 1) {
185+
pageInfo {
186+
hasPreviousPage
187+
hasNextPage
188+
startCursor
189+
endCursor
190+
}
191+
nodes { version }
192+
}
193+
}
194+
195+
//# run-graphql --cursors 1 4
196+
{ # Offset at the front and back, limit at the back
197+
objectVersions(address: "@{obj_0_0}", after: "@{cursor_0}", before: "@{cursor_1}", last: 1) {
198+
pageInfo {
199+
hasPreviousPage
200+
hasNextPage
201+
startCursor
202+
endCursor
203+
}
204+
nodes { version }
205+
}
206+
}
207+
208+
//# run-graphql
209+
{ # Using objectVersions ...Before and ...After
210+
object(address: "@{obj_0_0}", version: 3) {
211+
objectVersionsBefore {
212+
nodes { version }
213+
}
214+
version
215+
objectVersionsAfter {
216+
nodes { version }
217+
}
218+
}
219+
}

0 commit comments

Comments
 (0)