-
-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I could not find any examples of a real graphql query, so here comes one. It would have helped me.
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(()) | ||
} |