From 4d08e492b07e35899fb951e3689f8e5c7af9cda1 Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Mon, 3 Jan 2022 23:38:56 +0000 Subject: [PATCH 1/2] Add feature to use reqwest with rustls rather than native-tls. Currently, enabling the reqwest feature pulls in native-tls. This is annoying in a project that otherwise uses rustls. This change adds a new feature 'reqwest-rustls' that also adds the reqwest module, but using reqwest with rustls rather than native-tls. --- CHANGELOG.md | 2 ++ graphql_client/Cargo.toml | 6 ++++-- graphql_client/src/lib.rs | 2 +- graphql_client/src/reqwest.rs | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cf3f1a8..11ea5b6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## Unreleased - The `variables_derives` now trims whitespace from individual derivation traits. +- The new `reqwest-rustls` feature works like the `reqwest` feature but with + `rustls` rather than `native-tls`. ## 0.10.0 - 2021-07-04 diff --git a/graphql_client/Cargo.toml b/graphql_client/Cargo.toml index e6cc06e4..e1331daa 100644 --- a/graphql_client/Cargo.toml +++ b/graphql_client/Cargo.toml @@ -17,8 +17,10 @@ serde_json = "1.0" # Optional dependencies graphql_query_derive = { path = "../graphql_query_derive", version = "0.10.0", optional = true } -reqwest = { version = "^0.11", features = ["json"], optional = true } +reqwest-crate = { package = "reqwest", version = "^0.11", features = ["json"], default-features = false, optional = true } [features] default = ["graphql_query_derive"] -reqwest-blocking = ["reqwest/blocking"] +reqwest = ["reqwest-crate", "reqwest-crate/default-tls"] +reqwest-rustls = ["reqwest-crate", "reqwest-crate/rustls-tls"] +reqwest-blocking = ["reqwest-crate/blocking"] diff --git a/graphql_client/src/lib.rs b/graphql_client/src/lib.rs index c78548c4..d7ff9118 100644 --- a/graphql_client/src/lib.rs +++ b/graphql_client/src/lib.rs @@ -23,7 +23,7 @@ extern crate graphql_query_derive; #[doc(hidden)] pub use graphql_query_derive::*; -#[cfg(any(feature = "reqwest", feature = "reqwest-blocking"))] +#[cfg(any(feature = "reqwest", feature = "reqwest-rustls", feature = "reqwest-blocking"))] pub mod reqwest; use serde::{Deserialize, Serialize}; diff --git a/graphql_client/src/reqwest.rs b/graphql_client/src/reqwest.rs index 6fecf9ba..0a95819a 100644 --- a/graphql_client/src/reqwest.rs +++ b/graphql_client/src/reqwest.rs @@ -1,9 +1,10 @@ //! A concrete client implementation over HTTP with reqwest. use crate::GraphQLQuery; +use reqwest_crate as reqwest; /// Use the provided reqwest::Client to post a GraphQL request. -#[cfg(feature = "reqwest")] +#[cfg(any(feature = "reqwest", feature = "reqwest-rustls"))] pub async fn post_graphql( client: &reqwest::Client, url: U, From 281350232e2c1308493c9881fddd61e4ab14b362 Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Mon, 3 Jan 2022 23:50:02 +0000 Subject: [PATCH 2/2] Enable reqwest feature for docs.rs. --- graphql_client/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/graphql_client/Cargo.toml b/graphql_client/Cargo.toml index e1331daa..9bcea81f 100644 --- a/graphql_client/Cargo.toml +++ b/graphql_client/Cargo.toml @@ -11,6 +11,9 @@ edition = "2018" homepage = "https://github.com/graphql-rust/graphql-client" readme = "../README.md" +[package.metadata.docs.rs] +features = ["reqwest"] + [dependencies] serde = { version = "^1.0.78", features = ["derive"] } serde_json = "1.0"