From d646d4fa6e48fa2b3f04a2eaa95c75f943408b0b Mon Sep 17 00:00:00 2001 From: Arthur Khlghatyan Date: Wed, 6 Jan 2021 05:18:38 +0400 Subject: [PATCH] Added gql_client under rust/client directory --- .../rust/client/gql_client.md | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/content/code/language-support/rust/client/gql_client.md diff --git a/src/content/code/language-support/rust/client/gql_client.md b/src/content/code/language-support/rust/client/gql_client.md new file mode 100644 index 0000000000..bffd74c656 --- /dev/null +++ b/src/content/code/language-support/rust/client/gql_client.md @@ -0,0 +1,32 @@ +--- +name: gql_client +description: Minimal GraphQL client for Rust +url: https://github.com/arthurkhlghatyan/gql-client-rs +github: arthurkhlghatyan/gql-client-rs +--- + +Usage example +```rust +use gql_client::Client; + +#[tokio::main] +async fn main() -> Result<(), Box> { + let endpoint = "https://graphqlzero.almansi.me/api"; + let query = r#" + query AllPostsQuery { + posts { + data { + id + } + } + } + "#; + + let client = Client::new(endpoint); + let data: AllPosts = client.query::(query).await.unwrap(); + + println!("{:?}" data); + + Ok(()) +} +```