pub struct GraphQLResponse<'a, S = DefaultScalarValue>(_);
Expand description

Simple wrapper around the result from executing a GraphQL query

This struct implements Serialize, so you can simply serialize this to JSON and send it over the wire. Use the is_ok method to determine whether to send a 200 or 400 HTTP status code.

Implementations§

source§

impl<'a, S> GraphQLResponse<'a, S>where
    S: ScalarValue,

source

pub fn from_result(
    r: Result<(Value<S>, Vec<ExecutionError<S>>), GraphQLError<'a>>
) -> Self

Constructs new GraphQLResponse using the given result

source

pub fn error(error: FieldError<S>) -> Self

Constructs an error response outside of the normal execution flow

source

pub fn is_ok(&self) -> bool

Was the request successful or not?

Note that there still might be errors in the response even though it’s considered OK. This is by design in GraphQL.

Trait Implementations§

source§

impl<'a, S: Debug> Debug for GraphQLResponse<'a, S>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, T> Serialize for GraphQLResponse<'a, T>where
    T: Serialize + ScalarValue,
    Value<T>: Serialize,
    ExecutionError<T>: Serialize,
    GraphQLError<'a>: Serialize,

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where
    S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<'a, S> RefUnwindSafe for GraphQLResponse<'a, S>where
    S: RefUnwindSafe,

§

impl<'a, S> Send for GraphQLResponse<'a, S>where
    S: Send,

§

impl<'a, S> Sync for GraphQLResponse<'a, S>where
    S: Sync,

§

impl<'a, S> Unpin for GraphQLResponse<'a, S>where
    S: Unpin,

§

impl<'a, S> UnwindSafe for GraphQLResponse<'a, S>where
    S: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
    U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

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

§

fn vzip(self) -> V