Struct graphql_client::Response[][src]

pub struct Response<Data> {
    pub data: Option<Data>,
    pub errors: Option<Vec<Error>>,
}

The generic shape taken by the responses of GraphQL APIs.

This will generally be used with the ResponseData struct from a derived module.

Spec

use graphql_client::Response;

let body: Response<ResponseData> = serde_json::from_value(json!({
    "data": {
        "users": [{"id": 13}],
        "dogs": [{"name": "Strelka"}],
    },
    "errors": [],
}))?;

let expected: Response<ResponseData> = Response {
    data: Some(ResponseData {
        users: vec![User { id: 13 }],
        dogs: vec![Dog { name: "Strelka".to_owned() }],
    }),
    errors: Some(vec![]),
};

assert_eq!(body, expected);

Fields

The absent, partial or complete response data.

The top-level errors returned by the server.

Trait Implementations

impl<Data: Debug> Debug for Response<Data>
[src]

Formats the value using the given formatter. Read more

impl<Data: PartialEq> PartialEq for Response<Data>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

impl<Data> Send for Response<Data> where
    Data: Send

impl<Data> Sync for Response<Data> where
    Data: Sync