Struct graphql_client::GraphQLError[][src]

pub struct GraphQLError {
    pub message: String,
    pub locations: Option<Vec<Location>>,
    pub path: Option<Vec<PathFragment>>,
    pub extensions: Option<HashMap<String, Value>>,
}

An element in the top-level errors array of a response body.

This tries to be as close to the spec as possible.

Spec

use graphql_client::*;

let body: GraphQLResponse<ResponseData> = serde_json::from_value(json!({
    "data": null,
    "errors": [
        {
            "message": "The server crashed. Sorry.",
            "locations": [{ "line": 1, "column": 1 }]
        },
        {
            "message": "Seismic activity detected",
            "path": ["undeground", 20]
        },
     ],
}))?;

let expected: GraphQLResponse<ResponseData> = GraphQLResponse {
    data: None,
    errors: Some(vec![
        GraphQLError {
            message: "The server crashed. Sorry.".to_owned(),
            locations: Some(vec![
                Location {
                    line: 1,
                    column: 1,
                }
            ]),
            path: None,
            extensions: None,
        },
        GraphQLError {
            message: "Seismic activity detected".to_owned(),
            locations: None,
            path: Some(vec![
                PathFragment::Key("undeground".into()),
                PathFragment::Index(20),
            ]),
            extensions: None,
        },
    ]),
};

assert_eq!(body, expected);

Fields

The human-readable error message. This is the only required field.

Which locations in the query the error applies to.

Which path in the query the error applies to, e.g. ["users", 0, "email"].

Additional errors. Their exact format is defined by the server.

Trait Implementations

impl Debug for GraphQLError
[src]

Formats the value using the given formatter. Read more

impl PartialEq for GraphQLError
[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