Trait cynic::http::ReqwestBlockingExt

source ·
pub trait ReqwestBlockingExt {
    // Required method
    fn run_graphql<ResponseData, Vars>(
        self,
        operation: Operation<ResponseData, Vars>
    ) -> Result<GraphQlResponse<ResponseData>, CynicReqwestError>
       where Vars: Serialize,
             ResponseData: DeserializeOwned + 'static;
}
Available on crate feature reqwest-blocking only.
Expand description

An extension trait for reqwest::blocking::RequestBuilder.

use cynic::{http::ReqwestBlockingExt, QueryBuilder};

let operation = FilmDirectorQuery::build(());

let client = reqwest::blocking::Client::new();
let response = client.post("https://swapi-graphql.netlify.app/.netlify/functions/index")
    .run_graphql(operation)
    .unwrap();

println!(
    "The director is {}",
    response.data
        .and_then(|d| d.film)
        .and_then(|f| f.director)
        .unwrap()
);

Required Methods§

source

fn run_graphql<ResponseData, Vars>( self, operation: Operation<ResponseData, Vars> ) -> Result<GraphQlResponse<ResponseData>, CynicReqwestError>
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 ReqwestBlockingExt for RequestBuilder

source§

fn run_graphql<ResponseData, Vars>( self, operation: Operation<ResponseData, Vars> ) -> Result<GraphQlResponse<ResponseData>, CynicReqwestError>
where Vars: Serialize, ResponseData: DeserializeOwned + 'static,

Available on crate feature http-reqwest-blocking only.

Implementors§