diff --git a/crates/sui-graphql-rpc/src/context_data/db_data_provider.rs b/crates/sui-graphql-rpc/src/context_data/db_data_provider.rs index 4a326d970301dc..3f41fb5c6db3b7 100644 --- a/crates/sui-graphql-rpc/src/context_data/db_data_provider.rs +++ b/crates/sui-graphql-rpc/src/context_data/db_data_provider.rs @@ -195,8 +195,11 @@ impl QueryBuilder { after_tx_seq_num: Option, before_tx_seq_num: Option, ) -> Result, Error> { + let mut query = transactions::dsl::transactions.into_boxed(); if let Some(cursor_val) = cursor { + if descending_order { + let filter_value = before_tx_seq_num.map_or(cursor_val, |b| std::cmp::min(b, cursor_val)); query = query.filter(transactions::dsl::tx_sequence_number.lt(filter_value)); } else {