Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update hyper requirement from 0.14 to 1.0 #1219

Merged
merged 4 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion juniper_axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ bytes = "1.2"
[dev-dependencies]
anyhow = "1.0"
axum = { version = "0.6", features = ["macros"] }
hyper = "0.14"
juniper = { version = "0.16.0-dev", path = "../juniper", features = ["expose-test-schema"] }
tokio = { version = "1.20", features = ["macros", "rt-multi-thread", "time"] }
tokio-stream = "0.1"
tokio-tungstenite = "0.20"
tower-service = "0.3"
tracing = "0.1"
tracing-subscriber = "0.3"
urlencoding = "2.1"
Expand Down
15 changes: 9 additions & 6 deletions juniper_axum/src/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,17 @@ mod juniper_request_tests {
}

/// Converts the provided [`HttpBody`] into a [`String`].
async fn display_body<B>(body: B) -> String
async fn display_body<B>(mut body: B) -> String
where
B: HttpBody<Data = Bytes>,
B: HttpBody<Data = Bytes> + Unpin,
B::Error: fmt::Display,
{
let bytes = hyper::body::to_bytes(body)
.await
.unwrap_or_else(|e| panic!("failed to represent `Body` as `Bytes`: {e}"));
String::from_utf8(bytes.into()).unwrap_or_else(|e| panic!("not UTF-8 body: {e}"))
let mut body_bytes = vec![];
while let Some(bytes) = body.data().await {
body_bytes.extend(
bytes.unwrap_or_else(|e| panic!("failed to represent `Body` as `Bytes`: {e}")),
);
}
String::from_utf8(body_bytes).unwrap_or_else(|e| panic!("not UTF-8 body: {e}"))
}
}
17 changes: 11 additions & 6 deletions juniper_axum/tests/http_test_suite.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
use std::sync::Arc;

use axum::{
body::{Body, HttpBody as _},
http::Request,
response::Response,
routing::{get, post},
Extension, Router,
};
use hyper::{service::Service, Body};
use juniper::{
http::tests::{run_http_test_suite, HttpIntegration, TestResponse},
tests::fixtures::starwars::schema::{Database, Query},
EmptyMutation, EmptySubscription, RootNode,
};
use juniper_axum::{extract::JuniperRequest, response::JuniperResponse};
use tower_service::Service as _;

type Schema = RootNode<'static, Query, EmptyMutation<Database>, EmptySubscription<Database>>;

Expand Down Expand Up @@ -89,15 +90,19 @@ async fn into_test_response(resp: Response) -> TestResponse {
.headers()
.get("content-type")
.map(|header| {
String::from_utf8(header.as_bytes().into())
header
.to_str()
.unwrap_or_else(|e| panic!("not UTF-8 header: {e}"))
.to_owned()
})
.unwrap_or_default();

let body = hyper::body::to_bytes(resp.into_body())
.await
.unwrap_or_else(|e| panic!("failed to represent `Body` as `Bytes`: {e}"));
let body = String::from_utf8(body.into()).unwrap_or_else(|e| panic!("not UTF-8 body: {e}"));
let mut body = resp.into_body();
let mut body_bytes = vec![];
while let Some(bytes) = body.data().await {
body_bytes.extend(bytes.unwrap());
}
let body = String::from_utf8(body_bytes).unwrap_or_else(|e| panic!("not UTF-8 body: {e}"));

TestResponse {
status_code,
Expand Down