Struct gurkle::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 gurkle::*;

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

let expected: Response<ResponseData> = Response {
    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("underground".into()),
                PathFragment::Index(20),
            ]),
            extensions: None,
        },
    ]),
};

assert_eq!(body, expected);

Fields

message: String

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

locations: Option<Vec<Location>>

Which locations in the query the error applies to.

path: Option<Vec<PathFragment>>

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

extensions: Option<HashMap<String, Value>>

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

Trait Implementations

impl Clone for GraphQLError[src]

impl Debug for GraphQLError[src]

impl<'de> Deserialize<'de> for GraphQLError[src]

impl Display for GraphQLError[src]

impl PartialEq<GraphQLError> for GraphQLError[src]

impl Serialize for GraphQLError[src]

impl StructuralPartialEq for GraphQLError[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,