Trait cynic::http::ReqwestExt
source · pub trait ReqwestExt {
// Required method
fn run_graphql<ResponseData, Vars>(
self,
operation: Operation<ResponseData, Vars>
) -> CynicReqwestBuilder<ResponseData>
where Vars: Serialize,
ResponseData: DeserializeOwned + 'static;
}
Available on crate feature
reqwest
only.Expand description
An extension trait for reqwest::RequestBuilder.
use cynic::{http::ReqwestExt, QueryBuilder};
let operation = FilmDirectorQuery::build(());
let client = reqwest::Client::new();
let response = client.post("https://swapi-graphql.netlify.app/.netlify/functions/index")
.run_graphql(operation)
.await
.unwrap();
println!(
"The director is {}",
response.data
.and_then(|d| d.film)
.and_then(|f| f.director)
.unwrap()
);
Required Methods§
sourcefn run_graphql<ResponseData, Vars>(
self,
operation: Operation<ResponseData, Vars>
) -> CynicReqwestBuilder<ResponseData>where
Vars: Serialize,
ResponseData: DeserializeOwned + 'static,
fn run_graphql<ResponseData, Vars>(
self,
operation: Operation<ResponseData, Vars>
) -> CynicReqwestBuilder<ResponseData>where
Vars: Serialize,
ResponseData: DeserializeOwned + 'static,
Runs a GraphQL query with the parameters in RequestBuilder, deserializes the and returns the result.
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
source§impl ReqwestExt for RequestBuilder
impl ReqwestExt for RequestBuilder
source§fn run_graphql<ResponseData, Vars>(
self,
operation: Operation<ResponseData, Vars>
) -> CynicReqwestBuilder<ResponseData>where
Vars: Serialize,
ResponseData: DeserializeOwned + 'static,
fn run_graphql<ResponseData, Vars>(
self,
operation: Operation<ResponseData, Vars>
) -> CynicReqwestBuilder<ResponseData>where
Vars: Serialize,
ResponseData: DeserializeOwned + 'static,
Available on crate feature
http-reqwest
only.