Struct juniper_rocket::GraphQLResponse[][src]

pub struct GraphQLResponse(pub Status, pub String);
Expand description

Simple wrapper around the result of executing a GraphQL query

Implementations

Constructs an error response outside of the normal execution flow

Examples

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

    request.execute_sync(&*schema, &*context)
}

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_sync(..).

Trait Implementations

Returns Ok if a Response could be generated successfully. Otherwise, returns an Err with a failing Status. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Converts self into a collection.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.