Support latest Rocket master
This commit is contained in:
parent
e998457c0e
commit
9c9639e8f0
2 changed files with 18 additions and 18 deletions
|
@ -13,20 +13,20 @@ fn graphiql() -> content::Html<String> {
|
||||||
|
|
||||||
#[rocket::get("/graphql?<request>")]
|
#[rocket::get("/graphql?<request>")]
|
||||||
fn get_graphql_handler(
|
fn get_graphql_handler(
|
||||||
context: State<Database>,
|
context: &State<Database>,
|
||||||
request: juniper_rocket_async::GraphQLRequest,
|
request: juniper_rocket_async::GraphQLRequest,
|
||||||
schema: State<Schema>,
|
schema: &State<Schema>,
|
||||||
) -> juniper_rocket_async::GraphQLResponse {
|
) -> juniper_rocket_async::GraphQLResponse {
|
||||||
request.execute_sync(&schema, &context)
|
request.execute_sync(&*schema, &*context)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rocket::post("/graphql", data = "<request>")]
|
#[rocket::post("/graphql", data = "<request>")]
|
||||||
fn post_graphql_handler(
|
fn post_graphql_handler(
|
||||||
context: State<Database>,
|
context: &State<Database>,
|
||||||
request: juniper_rocket_async::GraphQLRequest,
|
request: juniper_rocket_async::GraphQLRequest,
|
||||||
schema: State<Schema>,
|
schema: &State<Schema>,
|
||||||
) -> juniper_rocket_async::GraphQLResponse {
|
) -> juniper_rocket_async::GraphQLResponse {
|
||||||
request.execute_sync(&schema, &context)
|
request.execute_sync(&*schema, &*context)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rocket::main]
|
#[rocket::main]
|
||||||
|
|
|
@ -170,16 +170,16 @@ impl GraphQLResponse {
|
||||||
/// #[rocket::get("/graphql?<request..>")]
|
/// #[rocket::get("/graphql?<request..>")]
|
||||||
/// fn get_graphql_handler(
|
/// fn get_graphql_handler(
|
||||||
/// cookies: &CookieJar,
|
/// cookies: &CookieJar,
|
||||||
/// context: State<Database>,
|
/// context: &State<Database>,
|
||||||
/// request: juniper_rocket_async::GraphQLRequest,
|
/// request: juniper_rocket_async::GraphQLRequest,
|
||||||
/// schema: State<Schema>,
|
/// schema: &State<Schema>,
|
||||||
/// ) -> juniper_rocket_async::GraphQLResponse {
|
/// ) -> juniper_rocket_async::GraphQLResponse {
|
||||||
/// if cookies.get("user_id").is_none() {
|
/// if cookies.get("user_id").is_none() {
|
||||||
/// let err = FieldError::new("User is not logged in", Value::null());
|
/// let err = FieldError::new("User is not logged in", Value::null());
|
||||||
/// return juniper_rocket_async::GraphQLResponse::error(err);
|
/// return juniper_rocket_async::GraphQLResponse::error(err);
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// request.execute_sync(&schema, &context)
|
/// request.execute_sync(&*schema, &*context)
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn error(error: FieldError) -> Self {
|
pub fn error(error: FieldError) -> Self {
|
||||||
|
@ -528,20 +528,20 @@ mod tests {
|
||||||
|
|
||||||
#[get("/?<request..>")]
|
#[get("/?<request..>")]
|
||||||
fn get_graphql_handler(
|
fn get_graphql_handler(
|
||||||
context: State<Database>,
|
context: &State<Database>,
|
||||||
request: super::GraphQLRequest,
|
request: super::GraphQLRequest,
|
||||||
schema: State<Schema>,
|
schema: &State<Schema>,
|
||||||
) -> super::GraphQLResponse {
|
) -> super::GraphQLResponse {
|
||||||
request.execute_sync(&schema, &context)
|
request.execute_sync(&*schema, &*context)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/", data = "<request>")]
|
#[post("/", data = "<request>")]
|
||||||
fn post_graphql_handler(
|
fn post_graphql_handler(
|
||||||
context: State<Database>,
|
context: &State<Database>,
|
||||||
request: super::GraphQLRequest,
|
request: super::GraphQLRequest,
|
||||||
schema: State<Schema>,
|
schema: &State<Schema>,
|
||||||
) -> super::GraphQLResponse {
|
) -> super::GraphQLResponse {
|
||||||
request.execute_sync(&schema, &context)
|
request.execute_sync(&*schema, &*context)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TestRocketIntegration {
|
struct TestRocketIntegration {
|
||||||
|
@ -585,12 +585,12 @@ mod tests {
|
||||||
async fn test_operation_names() {
|
async fn test_operation_names() {
|
||||||
#[post("/", data = "<request>")]
|
#[post("/", data = "<request>")]
|
||||||
fn post_graphql_assert_operation_name_handler(
|
fn post_graphql_assert_operation_name_handler(
|
||||||
context: State<Database>,
|
context: &State<Database>,
|
||||||
request: super::GraphQLRequest,
|
request: super::GraphQLRequest,
|
||||||
schema: State<Schema>,
|
schema: &State<Schema>,
|
||||||
) -> super::GraphQLResponse {
|
) -> super::GraphQLResponse {
|
||||||
assert_eq!(request.operation_names(), vec![Some("TestQuery")]);
|
assert_eq!(request.operation_names(), vec![Some("TestQuery")]);
|
||||||
request.execute_sync(&schema, &context)
|
request.execute_sync(&*schema, &*context)
|
||||||
}
|
}
|
||||||
|
|
||||||
let rocket = make_rocket_without_routes()
|
let rocket = make_rocket_without_routes()
|
||||||
|
|
Loading…
Reference in a new issue