Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
194 changes: 194 additions & 0 deletions crates/sui-graphql-e2e-tests/tests/stable/epoch/pagination.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
processed 15 tasks

init:
C: object(0,0)

task 1, line 6:
//# advance-epoch
Epoch advanced: 0

task 2, line 8:
//# advance-epoch
Epoch advanced: 1

task 3, line 10:
//# advance-epoch
Epoch advanced: 2

task 4, line 12:
//# advance-epoch
Epoch advanced: 3

task 5, line 14:
//# advance-epoch
Epoch advanced: 4

task 6, line 16:
//# advance-epoch
Epoch advanced: 5

task 7, lines 18-29:
//# run-graphql
Response: {
"data": {
"epochs": {
"pageInfo": {
"hasPreviousPage": true,
"hasNextPage": false
},
"nodes": [
{
"epochId": 4
},
{
"epochId": 5
}
]
}
}
}

task 8, lines 31-42:
//# run-graphql
Response: {
"data": {
"epochs": {
"pageInfo": {
"hasPreviousPage": false,
"hasNextPage": true
},
"nodes": [
{
"epochId": 0
},
{
"epochId": 1
},
{
"epochId": 2
}
]
}
}
}

task 9, lines 44-55:
//# run-graphql --cursors {"c":5,"e":2}
Response: {
"data": {
"epochs": {
"pageInfo": {
"hasPreviousPage": false,
"hasNextPage": true
},
"nodes": [
{
"epochId": 0
},
{
"epochId": 1
}
]
}
}
}

task 10, lines 57-68:
//# run-graphql --cursors {"c":3,"e":4}
Response: {
"data": {
"epochs": {
"pageInfo": {
"hasPreviousPage": false,
"hasNextPage": false
},
"nodes": [
{
"epochId": 0
},
{
"epochId": 1
},
{
"epochId": 2
}
]
}
}
}

task 11, lines 70-81:
//# run-graphql --cursors {"c":11,"e":1}
Response: {
"data": {
"epochs": {
"pageInfo": {
"hasPreviousPage": true,
"hasNextPage": false
},
"nodes": [
{
"epochId": 2
},
{
"epochId": 3
},
{
"epochId": 4
},
{
"epochId": 5
},
{
"epochId": 6
}
]
}
}
}

task 12, lines 83-94:
//# run-graphql --cursors {"c":0,"e":5}
Response: {
"data": {
"epochs": {
"pageInfo": {
"hasPreviousPage": false,
"hasNextPage": false
},
"nodes": [
{
"epochId": 0
}
]
}
}
}

task 13, lines 96-107:
//# run-graphql --cursors {"c":3,"e":4}
Response: {
"data": {
"epochs": {
"pageInfo": {
"hasPreviousPage": false,
"hasNextPage": false
},
"nodes": []
}
}
}

task 14, lines 109-120:
//# run-graphql --cursors {"c":0,"e":0}
Response: {
"data": {
"epochs": {
"pageInfo": {
"hasPreviousPage": false,
"hasNextPage": false
},
"nodes": []
}
}
}
120 changes: 120 additions & 0 deletions crates/sui-graphql-e2e-tests/tests/stable/epoch/pagination.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# init --protocol-version 51 --simulator --accounts C

//# advance-epoch

//# advance-epoch

//# advance-epoch

//# advance-epoch

//# advance-epoch

//# advance-epoch

//# run-graphql
{
epochs(last:2) {
pageInfo {
hasPreviousPage
hasNextPage
}
nodes {
epochId
}
}
}

//# run-graphql
{
epochs(first:3) {
pageInfo {
hasPreviousPage
hasNextPage
}
nodes {
epochId
}
}
}

//# run-graphql --cursors {"c":5,"e":2}
{
epochs(before: "@{cursor_0}") {
pageInfo {
hasPreviousPage
hasNextPage
}
nodes {
epochId
}
}
}

//# run-graphql --cursors {"c":3,"e":4}
{
epochs(before: "@{cursor_0}") {
pageInfo {
hasPreviousPage
hasNextPage
}
nodes {
epochId
}
}
}

//# run-graphql --cursors {"c":11,"e":1}
{
epochs(after: "@{cursor_0}") {
pageInfo {
hasPreviousPage
hasNextPage
}
nodes {
epochId
}
}
}

//# run-graphql --cursors {"c":0,"e":5}
{
epochs(before: "@{cursor_0}") {
pageInfo {
hasPreviousPage
hasNextPage
}
nodes {
epochId
}
}
}

//# run-graphql --cursors {"c":3,"e":4}
{
epochs(after: "@{cursor_0}") {
pageInfo {
hasPreviousPage
hasNextPage
}
nodes {
epochId
}
}
}

//# run-graphql --cursors {"c":0,"e":0}
{
epochs(after: "@{cursor_0}") {
pageInfo {
hasPreviousPage
hasNextPage
}
nodes {
epochId
}
}
}
30 changes: 30 additions & 0 deletions crates/sui-graphql-rpc/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,35 @@ type Epoch {
transactionBlocks(first: Int, after: String, last: Int, before: String, filter: TransactionBlockFilter, scanLimit: Int): TransactionBlockConnection!
}

type EpochConnection {
"""
Information to aid in pagination.
"""
pageInfo: PageInfo!
"""
A list of edges.
"""
edges: [EpochEdge!]!
"""
A list of nodes.
"""
nodes: [Epoch!]!
}

"""
An edge in a connection.
"""
type EpochEdge {
"""
The item at the end of the edge
"""
node: Epoch!
"""
A cursor for use in pagination
"""
cursor: String!
}

type Event {
"""
The Move module containing some function that when called by
Expand Down Expand Up @@ -3306,6 +3335,7 @@ type Query {
`0x2::sui::SUI`). If no type is provided, it will default to `0x2::sui::SUI`.
"""
coins(first: Int, after: String, last: Int, before: String, type: String): CoinConnection!
epochs(first: Int, after: String, last: Int, before: String): EpochConnection!
"""
The checkpoints that exist in the network.
"""
Expand Down
Loading
Loading