sui_graphql_client::streams

Function stream_paginated_query

Source
pub fn stream_paginated_query<T, F, Fut>(
    query_fn: F,
    direction: Direction,
) -> PageStream<T, F, Fut>
where F: Fn(PaginationFilter) -> Fut, Fut: Future<Output = Result<Page<T>, Error>>,
Expand description

Creates a new PageStream for a paginated query.

Examples

use futures::StreamExt;
use sui_graphql_client::streams::stream_paginated_query;
use sui_graphql_client::Client;
use sui_graphql_client::PaginationFilter;
use sui_graphql_client::Direction;

let client = Client::new_testnet();
let stream = stream_paginated_query(|pagination_filter, Direction::Forward| {
   client.coins(owner, coin_type, pagination_filter)
});

while let Some(result) = stream.next().await {
   match result {
       Ok(coin) => println!("Got coin: {:?}", coin),
       Err(e) => eprintln!("Error: {}", e),
   }
}