Skip to content

Commit

Permalink
Update function return types
Browse files Browse the repository at this point in the history
  • Loading branch information
darunrs committed May 21, 2024
1 parent d87e7c7 commit e6dca93
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
19 changes: 12 additions & 7 deletions block-streamer/examples/get_bitmaps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,25 @@ async fn main() -> Result<(), Box<dyn Error>> {
let client = graphql::GraphqlClient::new(
"https://queryapi-hasura-graphql-mainnet-vcqilefdcq-ew.a.run.app/v1/graphql".to_string(),
);
let _ = client
.get_bitmaps_wildcard(
"app.nearcrowd.near".to_string(),

let exact_query = client
.get_bitmaps_exact(
vec!["app.nearcrowd.near".to_owned()],
"2024-03-21".to_string(),
100,
0,
)
.await;
client
.get_bitmaps_exact(
vec!["app.nearcrowd.near".to_owned()],
println!("exact query: {:#?}", exact_query);

let wildcard_query = client
.get_bitmaps_wildcard(
"app.nearcrowd.near".to_string(),
"2024-03-21".to_string(),
100,
0,
)
.await
.await;
println!("wildcard query: {:#?}", wildcard_query);
Ok(())
}
16 changes: 8 additions & 8 deletions block-streamer/src/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl GraphqlClient {
block_date: String,
limit: i64,
offset: i64,
) -> Result<(), Box<dyn Error>> {
) -> Result<Response<get_bitmaps_exact::ResponseData>, Box<dyn Error>> {
let variables = get_bitmaps_exact::Variables {
receiver_ids: Some(receiver_ids),
block_date: Some(block_date),
Expand All @@ -40,10 +40,10 @@ impl GraphqlClient {
.header("x-hasura-role", HASURA_ACCOUNT)
.json(&request_body)
.send()
.await?;
.await
.expect("Failed to query bitmaps for list of exact receivers");
let response_body: Response<get_bitmaps_exact::ResponseData> = res.json().await?;
println!("{:#?}", response_body);
Ok(())
Ok(response_body)
}

pub async fn get_bitmaps_wildcard(
Expand All @@ -52,7 +52,7 @@ impl GraphqlClient {
block_date: String,
limit: i64,
offset: i64,
) -> Result<(), Box<dyn Error>> {
) -> Result<Response<get_bitmaps_wildcard::ResponseData>, Box<dyn Error>> {
let variables = get_bitmaps_wildcard::Variables {
receiver_ids: Some(receiver_ids),
block_date: Some(block_date),
Expand All @@ -66,10 +66,10 @@ impl GraphqlClient {
.header("x-hasura-role", HASURA_ACCOUNT)
.json(&request_body)
.send()
.await?;
.await
.expect("Failed to query bitmaps for wildcard receivers");
let response_body: Response<get_bitmaps_wildcard::ResponseData> = res.json().await?;
println!("{:#?}", response_body);
Ok(())
Ok(response_body)
}
}

Expand Down

0 comments on commit e6dca93

Please sign in to comment.