pub fn error(error: FieldError) -> Self {
        let response = http::GraphQLResponse::error(error);
        let json = serde_json::to_string(&response).unwrap();
        GraphQLResponse(Status::BadRequest, json)
    }
/// Constructs an error response outside of the normal execution flow
///
/// # Examples
///
/// ```
/// # use rocket::http::CookieJar;
/// # use rocket::request::Form;
/// # use rocket::response::content;
/// # use rocket::State;
/// #
/// # use juniper::tests::fixtures::starwars::schema::{Database, Query};
/// # use juniper::{EmptyMutation, EmptySubscription, FieldError, RootNode, Value};
/// #
/// # type Schema = RootNode<'static, Query, EmptyMutation<Database>, EmptySubscription<Database>>;
/// #
/// #[rocket::get("/graphql?<request..>")]
/// fn get_graphql_handler(
///     cookies: &CookieJar,
///     context: State<Database>,
///     request: Form<juniper_rocket_async::GraphQLRequest>,
///     schema: State<Schema>,
/// ) -> juniper_rocket_async::GraphQLResponse {
///     if cookies.get("user_id").is_none() {
///         let err = FieldError::new("User is not logged in", Value::null());
///         return juniper_rocket_async::GraphQLResponse::error(err);
///     }
///
///     request.execute_sync(&schema, &context)
/// }
/// ```
Constructs an error response outside of the normal execution flow
Constructs an error response outside of the normal execution flow
pub fn error(error: FieldError) -> Self {
        let response = http::GraphQLResponse::error(error);
        let json = serde_json::to_string(&response).unwrap();
        GraphQLResponse(Status::BadRequest, json)
    }
pub fn error ( error : FieldError ) -> Self { let response = http :: GraphQLResponse :: error ( error ) ; let json = serde_json :: to_string ( & response ) . unwrap ( ) ; GraphQLResponse ( Status :: BadRequest , json ) }
Constructs an error response outside of the normal execution flow
Constructs an error response outside of the normal execution flow
error
FieldError
error
FieldError
examples
None
use rocket::http::cookiejar;
None
use rocket::request::form;
None
use rocket::response::content;
None
use rocket::state;
None
use juniper::tests::fixtures::starwars::schema::{database, query};
None
use juniper::{emptymutation, emptysubscription, fielderror, rootnode, value};
None
type schema = rootnode<'static, query, emptymutation<database>, emptysubscription<database>>;
None
[rocket::get("/graphql?<request..>")]
fn get_graphql_handler(
cookies: &CookieJar,
context: State,
request: Form,
schema: State,
) -> juniper_rocket_async::GraphQLResponse {
if cookies.get("user_id").is_none() {
let err = FieldError::new("User is not logged in", Value::null());
return juniper_rocket_async::GraphQLResponse::error(err);
}

request.execute_sync(&schema, &context)
}
```
fn get_graphql_handler ( cookies : &CookieJar context : State request : Form schema : State ) - > juniper_rocket_async :: GraphQLResponse { if cookies . get ( " user_id " ) . is_none () { let err = FieldError :: new ( " User is not logged in " Value :: null () ) ; return juniper_rocket_async :: GraphQLResponse :: error ( err ) ; } request . execute_sync ( &schema &context ) } ` ` `