Fix 'juniper_rocket_async' crate up to latest upstream changes
This commit is contained in:
parent
5b4f6fca39
commit
563270d975
2 changed files with 18 additions and 27 deletions
|
@ -32,7 +32,8 @@ fn post_graphql_handler(
|
||||||
request.execute_sync(&schema, &context)
|
request.execute_sync(&schema, &context)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
#[rocket::main]
|
||||||
|
async fn main() {
|
||||||
rocket::ignite()
|
rocket::ignite()
|
||||||
.manage(Database::new())
|
.manage(Database::new())
|
||||||
.manage(Schema::new(
|
.manage(Schema::new(
|
||||||
|
@ -45,5 +46,6 @@ fn main() {
|
||||||
rocket::routes![graphiql, get_graphql_handler, post_graphql_handler],
|
rocket::routes![graphiql, get_graphql_handler, post_graphql_handler],
|
||||||
)
|
)
|
||||||
.launch()
|
.launch()
|
||||||
|
.await
|
||||||
.expect("server to launch");
|
.expect("server to launch");
|
||||||
}
|
}
|
||||||
|
|
|
@ -325,25 +325,15 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use rocket::futures::future::BoxFuture;
|
impl<'r, 'o: 'r> Responder<'r, 'o> for GraphQLResponse {
|
||||||
|
fn respond_to(self, _req: &'r Request<'_>) -> response::Result<'o> {
|
||||||
impl<'r> Responder<'r> for GraphQLResponse {
|
|
||||||
fn respond_to<'a, 'x>(self, _req: &'r Request<'a>) -> BoxFuture<'x, response::Result<'r>>
|
|
||||||
where
|
|
||||||
'a: 'x,
|
|
||||||
'r: 'x,
|
|
||||||
Self: 'x,
|
|
||||||
{
|
|
||||||
let GraphQLResponse(status, body) = self;
|
let GraphQLResponse(status, body) = self;
|
||||||
|
|
||||||
Box::pin(async move {
|
Response::build()
|
||||||
Ok(Response::build()
|
.header(ContentType::new("application", "json"))
|
||||||
.header(ContentType::new("application", "json"))
|
.status(status)
|
||||||
.status(status)
|
.sized_body(body.len(), Cursor::new(body))
|
||||||
.sized_body(Cursor::new(body))
|
.ok()
|
||||||
.await
|
|
||||||
.finalize())
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,10 +518,10 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[tokio::test]
|
||||||
fn test_rocket_integration() {
|
async fn test_rocket_integration() {
|
||||||
let rocket = make_rocket();
|
let rocket = make_rocket();
|
||||||
let client = Client::new(rocket).expect("valid rocket");
|
let client = Client::new(rocket).await.expect("valid rocket");
|
||||||
let integration = TestRocketIntegration { client };
|
let integration = TestRocketIntegration { client };
|
||||||
|
|
||||||
http_tests::run_http_test_suite(&integration);
|
http_tests::run_http_test_suite(&integration);
|
||||||
|
@ -551,7 +541,7 @@ mod tests {
|
||||||
|
|
||||||
let rocket = make_rocket_without_routes()
|
let rocket = make_rocket_without_routes()
|
||||||
.mount("/", routes![post_graphql_assert_operation_name_handler]);
|
.mount("/", routes![post_graphql_assert_operation_name_handler]);
|
||||||
let client = Client::new(rocket).expect("valid rocket");
|
let client = Client::new(rocket).await.expect("valid rocket");
|
||||||
|
|
||||||
let resp = client
|
let resp = client
|
||||||
.post("/")
|
.post("/")
|
||||||
|
@ -583,14 +573,13 @@ mod tests {
|
||||||
.expect("No content type header from handler")
|
.expect("No content type header from handler")
|
||||||
.to_string();
|
.to_string();
|
||||||
let body = response
|
let body = response
|
||||||
.body()
|
.body_string()
|
||||||
.expect("No body returned from GraphQL handler")
|
.await
|
||||||
.into_string()
|
.expect("No body returned from GraphQL handler");
|
||||||
.await;
|
|
||||||
|
|
||||||
http_tests::TestResponse {
|
http_tests::TestResponse {
|
||||||
status_code,
|
status_code,
|
||||||
body,
|
body: Some(body),
|
||||||
content_type,
|
content_type,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue