Skip to content

Commit

Permalink
Add examples/graphql_issues.rs
Browse files Browse the repository at this point in the history
I could not find any examples of a real graphql query, so here comes
one. It would have helped me.
  • Loading branch information
Enselic committed Oct 29, 2023
1 parent 37a7fcc commit e9b22e9
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions examples/graphql_issues.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let octocrab = octocrab::Octocrab::builder()
.personal_token(std::env::var("GITHUB_TOKEN").unwrap())
.build()?;

let query = r#" query {
repository(owner:"XAMPPRocky", name:"octocrab") {
issues(last: 2, states: OPEN) {
nodes {
title
url
}
}
}
} "#;

let response: octocrab::Result<serde_json::Value> = octocrab
.graphql(&serde_json::json!({ "query": query }))
.await;

match response {
Ok(value) => println!("{value:#?}"),
Err(error) => println!("{error:#?}"),
}

Ok(())
}

0 comments on commit e9b22e9

Please sign in to comment.