Skip to content

Commit

Permalink
sui-graphql-client: make pagination consistent across queries (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-mysten authored Dec 11, 2024
1 parent 24c3493 commit 6c44290
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions crates/sui-graphql-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1293,23 +1293,15 @@ impl Client {
/// checkpoints, but only records the latest versions of system packages.
pub async fn packages(
&self,
after: Option<&str>,
before: Option<&str>,
first: Option<i32>,
last: Option<i32>,
pagination_filter: PaginationFilter,
after_checkpoint: Option<u64>,
before_checkpoint: Option<u64>,
) -> Result<Page<MovePackage>> {
if first.is_some() && last.is_some() {
return Err(Error::from_error(
Kind::Other,
"Conflicting arguments: either first or last can be provided, but not both.",
));
}
let (after, before, first, last) = self.pagination_filter(pagination_filter).await;

let operation = PackagesQuery::build(PackagesQueryArgs {
after,
before,
after: after.as_deref(),
before: before.as_deref(),
first,
last,
filter: Some(PackageCheckpointFilter {
Expand Down Expand Up @@ -2187,7 +2179,9 @@ mod tests {
#[tokio::test]
async fn test_packages_query() {
let client = test_client();
let packages = client.packages(None, None, None, None, None, None).await;
let packages = client
.packages(PaginationFilter::default(), None, None)
.await;
assert!(
packages.is_ok(),
"Packages query failed for {} network. Error: {}",
Expand Down

0 comments on commit 6c44290

Please sign in to comment.