[][src]Struct juniper_rocket::GraphQLResponse

pub struct GraphQLResponse(pub Status, pub String);

Simple wrapper around the result of executing a GraphQL query

Methods

impl GraphQLResponse[src]

pub fn error(error: FieldError) -> Self[src]

Constructs an error response outside of the normal execution flow

Examples

#[rocket::get("/graphql?<request..>")]
fn get_graphql_handler(
    mut cookies: Cookies,
    context: State<Database>,
    request: Form<juniper_rocket::GraphQLRequest>,
    schema: State<Schema>,
) -> juniper_rocket::GraphQLResponse {
    if cookies.get_private("user_id").is_none() {
        let err = FieldError::new("User is not logged in", Value::null());
        return juniper_rocket::GraphQLResponse::error(err);
    }

    request.execute(&schema, &context)
}

pub fn custom(status: Status, response: Value) -> Self[src]

Constructs a custom response outside of the normal execution flow

This is intended for highly customized integrations and should only be used as a last resort. For normal juniper use, use the response from GraphQLRequest::execute(..).

Trait Implementations

impl<'r> Responder<'r> for GraphQLResponse[src]

Auto Trait Implementations

Blanket Implementations

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[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<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

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

impl<T> Typeable for T where
    T: Any

fn get_type(&self) -> TypeId

Get the TypeId of this object.

impl<T> IntoCollection<T> for T

impl<T, I> AsResult<T, I> for T where
    I: Input,