diff --git a/docs/book/content/advanced/subscriptions.md b/docs/book/content/advanced/subscriptions.md index c1052b37..95b26513 100644 --- a/docs/book/content/advanced/subscriptions.md +++ b/docs/book/content/advanced/subscriptions.md @@ -51,7 +51,7 @@ type StringStream = Pin> + Send #[graphql_subscription(context = Database)] impl Subscription { async fn hello_world() -> StringStream { - let stream = tokio::stream::iter(vec![ + let stream = futures::stream::iter(vec![ Ok(String::from("Hello")), Ok(String::from("World!")) ]); @@ -123,7 +123,7 @@ where [`Connection`][Connection] is a `Stream` of values returned by the operati # impl Subscription { # async fn hello_world() -> StringStream { # let stream = -# tokio::stream::iter(vec![Ok(String::from("Hello")), Ok(String::from("World!"))]); +# futures::stream::iter(vec![Ok(String::from("Hello")), Ok(String::from("World!"))]); # Box::pin(stream) # } # } diff --git a/docs/book/tests/Cargo.toml b/docs/book/tests/Cargo.toml index 7456182c..c798aa2b 100644 --- a/docs/book/tests/Cargo.toml +++ b/docs/book/tests/Cargo.toml @@ -16,7 +16,7 @@ iron = "0.5" mount = "0.4" skeptic = "0.13" serde_json = "1.0" -tokio = { version = "0.2", features = ["blocking", "macros", "rt-core", "rt-util", "stream"] } +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } uuid = "0.8" [build-dependencies] diff --git a/examples/actix_subscriptions/Cargo.toml b/examples/actix_subscriptions/Cargo.toml index 531fe0bd..7685fc25 100644 --- a/examples/actix_subscriptions/Cargo.toml +++ b/examples/actix_subscriptions/Cargo.toml @@ -6,15 +6,15 @@ authors = ["Mihai Dinculescu "] publish = false [dependencies] -actix-web = "3.3" -actix-cors = "0.5" +actix-web = "4.0.0-beta.5" +actix-cors = "0.6.0-beta.1" futures = "0.3" -tokio = { version = "0.2", features = ["macros", "rt-core"] } env_logger = "0.8" serde = "1.0" serde_json = "1.0" -rand = "0.7" - +rand = "0.8" +tokio = "1.0" +async-stream = "0.3" juniper = { path = "../../juniper", features = ["expose-test-schema"] } juniper_actix = { path = "../../juniper_actix", features = ["subscriptions"] } juniper_graphql_ws = { path = "../../juniper_graphql_ws" } diff --git a/examples/actix_subscriptions/src/main.rs b/examples/actix_subscriptions/src/main.rs index 0061c023..b8945a54 100644 --- a/examples/actix_subscriptions/src/main.rs +++ b/examples/actix_subscriptions/src/main.rs @@ -1,7 +1,7 @@ use std::{env, pin::Pin, time::Duration}; use actix_cors::Cors; -use actix_web::{middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer}; +use actix_web::{http::header, middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer}; use juniper::{ graphql_object, graphql_subscription, @@ -64,27 +64,29 @@ impl Subscription { use rand::{rngs::StdRng, Rng, SeedableRng}; let mut rng = StdRng::from_entropy(); - - let stream = tokio::time::interval(Duration::from_secs(3)).map(move |_| { + let mut interval = tokio::time::interval(Duration::from_secs(5)); + let stream = async_stream::stream! { counter += 1; + loop { + interval.tick().await; + if counter == 2 { + yield Err(FieldError::new( + "some field error from handler", + Value::Scalar(DefaultScalarValue::String( + "some additional string".to_string(), + )), + )) + } else { + let random_id = rng.gen_range(1000..1005).to_string(); + let human = context.get_human(&random_id).unwrap().clone(); - if counter == 2 { - Err(FieldError::new( - "some field error from handler", - Value::Scalar(DefaultScalarValue::String( - "some additional string".to_string(), - )), - )) - } else { - let random_id = rng.gen_range(1000, 1005).to_string(); - let human = context.get_human(&random_id).unwrap().clone(); - - Ok(RandomHuman { - id: human.id().to_owned(), - name: human.name().unwrap().to_owned(), - }) + yield Ok(RandomHuman { + id: human.id().to_owned(), + name: human.name().unwrap().to_owned(), + }) + } } - }); + }; Box::pin(stream) } @@ -117,7 +119,10 @@ async fn main() -> std::io::Result<()> { .wrap(middleware::Logger::default()) .wrap( Cors::default() + .allowed_origin("http://127.0.0.1:8080") .allowed_methods(vec!["POST", "GET"]) + .allowed_headers(vec![header::AUTHORIZATION, header::ACCEPT]) + .allowed_header(header::CONTENT_TYPE) .supports_credentials() .max_age(3600), ) @@ -130,7 +135,7 @@ async fn main() -> std::io::Result<()> { .service(web::resource("/playground").route(web::get().to(playground))) .default_service(web::route().to(|| { HttpResponse::Found() - .header("location", "/playground") + .append_header((header::LOCATION, "/playground")) .finish() })) }) diff --git a/examples/basic_subscriptions/Cargo.toml b/examples/basic_subscriptions/Cargo.toml index bb5016e2..ccb294db 100644 --- a/examples/basic_subscriptions/Cargo.toml +++ b/examples/basic_subscriptions/Cargo.toml @@ -11,7 +11,7 @@ authors = ["Jordao Rosario "] futures = "0.3" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -tokio = { version = "0.2", features = ["rt-core", "macros", "stream"] } +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } juniper = { path = "../../juniper" } juniper_subscriptions = { path = "../../juniper_subscriptions" } diff --git a/examples/basic_subscriptions/src/main.rs b/examples/basic_subscriptions/src/main.rs index 819fe535..a8e3736c 100644 --- a/examples/basic_subscriptions/src/main.rs +++ b/examples/basic_subscriptions/src/main.rs @@ -37,7 +37,7 @@ type StringStream = Pin> + Send impl Subscription { async fn hello_world() -> StringStream { let stream = - tokio::stream::iter(vec![Ok(String::from("Hello")), Ok(String::from("World!"))]); + futures::stream::iter(vec![Ok(String::from("Hello")), Ok(String::from("World!"))]); Box::pin(stream) } } diff --git a/examples/warp_async/Cargo.toml b/examples/warp_async/Cargo.toml index ce37b750..d03aed7a 100644 --- a/examples/warp_async/Cargo.toml +++ b/examples/warp_async/Cargo.toml @@ -13,5 +13,5 @@ env_logger = "0.8.1" futures = "0.3.1" log = "0.4.8" reqwest = { version = "0.11", features = ["rustls-tls"] } -tokio = { version = "0.2", features = ["rt-core", "macros"] } -warp = "0.2" +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } +warp = "0.3" diff --git a/examples/warp_subscriptions/Cargo.toml b/examples/warp_subscriptions/Cargo.toml index a7edc4fe..6df6265e 100644 --- a/examples/warp_subscriptions/Cargo.toml +++ b/examples/warp_subscriptions/Cargo.toml @@ -10,9 +10,9 @@ futures = "0.3.1" log = "0.4.8" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -tokio = { version = "0.2", features = ["rt-core", "macros"] } -warp = "0.2.1" - +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } +warp = "0.3" +async-stream = "0.3" juniper = { path = "../../juniper" } juniper_graphql_ws = { path = "../../juniper_graphql_ws" } juniper_warp = { path = "../../juniper_warp", features = ["subscriptions"] } diff --git a/examples/warp_subscriptions/src/main.rs b/examples/warp_subscriptions/src/main.rs index 369a14b9..21e2668b 100644 --- a/examples/warp_subscriptions/src/main.rs +++ b/examples/warp_subscriptions/src/main.rs @@ -109,23 +109,27 @@ struct Subscription; impl Subscription { async fn users() -> UsersStream { let mut counter = 0; - let stream = tokio::time::interval(Duration::from_secs(5)).map(move |_| { + let mut interval = tokio::time::interval(Duration::from_secs(5)); + let stream = async_stream::stream! { counter += 1; - if counter == 2 { - Err(FieldError::new( - "some field error from handler", - Value::Scalar(DefaultScalarValue::String( - "some additional string".to_string(), - )), - )) - } else { - Ok(User { - id: counter, - kind: UserKind::Admin, - name: "stream user".to_string(), - }) + loop { + interval.tick().await; + if counter == 2 { + yield Err(FieldError::new( + "some field error from handler", + Value::Scalar(DefaultScalarValue::String( + "some additional string".to_string(), + )), + )) + } else { + yield Ok(User { + id: counter, + kind: UserKind::Admin, + name: "stream user".to_string(), + }) + } } - }); + }; Box::pin(stream) } diff --git a/integration_tests/async_await/Cargo.toml b/integration_tests/async_await/Cargo.toml index 2e8429bd..b625a33f 100644 --- a/integration_tests/async_await/Cargo.toml +++ b/integration_tests/async_await/Cargo.toml @@ -8,4 +8,4 @@ publish = false [dependencies] juniper = { path = "../../juniper" } futures = "0.3.1" -tokio = { version = "0.2", features = ["rt-core", "time", "macros"] } \ No newline at end of file +tokio = { version = "1", features = ["rt", "time", "macros"] } \ No newline at end of file diff --git a/integration_tests/async_await/src/main.rs b/integration_tests/async_await/src/main.rs index 42d914f7..cf58f90f 100644 --- a/integration_tests/async_await/src/main.rs +++ b/integration_tests/async_await/src/main.rs @@ -42,7 +42,7 @@ impl User { } async fn delayed() -> bool { - tokio::time::delay_for(std::time::Duration::from_millis(100)).await; + tokio::time::sleep(std::time::Duration::from_millis(100)).await; true } } @@ -68,7 +68,7 @@ impl Query { } async fn delayed() -> bool { - tokio::time::delay_for(std::time::Duration::from_millis(100)).await; + tokio::time::sleep(std::time::Duration::from_millis(100)).await; true } } diff --git a/integration_tests/codegen_fail/Cargo.toml b/integration_tests/codegen_fail/Cargo.toml index c7ff68fc..f9f296c8 100644 --- a/integration_tests/codegen_fail/Cargo.toml +++ b/integration_tests/codegen_fail/Cargo.toml @@ -10,5 +10,5 @@ futures = "0.3.1" [dev-dependencies] serde_json = { version = "1" } -tokio = { version = "0.2", features = ["rt-core", "time", "macros"] } +tokio = { version = "1", features = ["rt", "time", "macros"] } trybuild = "1.0.25" \ No newline at end of file diff --git a/integration_tests/juniper_tests/Cargo.toml b/integration_tests/juniper_tests/Cargo.toml index 1acfeb19..e21f60f4 100644 --- a/integration_tests/juniper_tests/Cargo.toml +++ b/integration_tests/juniper_tests/Cargo.toml @@ -14,4 +14,4 @@ juniper_subscriptions = { path = "../../juniper_subscriptions" } async-trait = "0.1.39" serde_json = "1.0" fnv = "1.0" -tokio = { version = "0.2", features = ["macros", "rt-core", "time"] } +tokio = { version = "1", features = ["rt", "macros", "time"] } diff --git a/juniper/Cargo.toml b/juniper/Cargo.toml index 1c6650a0..809e917b 100644 --- a/juniper/Cargo.toml +++ b/juniper/Cargo.toml @@ -55,7 +55,7 @@ uuid = { version = "0.8", default-features = false, optional = true } bencher = "0.1.2" pretty_assertions = "0.7.1" serde_json = "1.0.2" -tokio = { version = "0.2", features = ["macros", "rt-core", "time"] } +tokio = { version = "1", features = ["macros", "time", "rt-multi-thread"] } [[bench]] name = "bench" diff --git a/juniper/src/executor_tests/async_await/mod.rs b/juniper/src/executor_tests/async_await/mod.rs index 769de94e..06750bab 100644 --- a/juniper/src/executor_tests/async_await/mod.rs +++ b/juniper/src/executor_tests/async_await/mod.rs @@ -39,7 +39,7 @@ impl User { } async fn delayed() -> bool { - tokio::time::delay_for(std::time::Duration::from_millis(100)).await; + tokio::time::sleep(std::time::Duration::from_millis(100)).await; true } } @@ -65,7 +65,7 @@ impl Query { } async fn delayed() -> bool { - tokio::time::delay_for(std::time::Duration::from_millis(100)).await; + tokio::time::sleep(std::time::Duration::from_millis(100)).await; true } } diff --git a/juniper_actix/Cargo.toml b/juniper_actix/Cargo.toml index cf67354e..73988f32 100644 --- a/juniper_actix/Cargo.toml +++ b/juniper_actix/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "juniper_actix" -version = "0.2.5" +version = "0.3.0" edition = "2018" authors = ["Jordao Rosario "] description = "Juniper GraphQL integration with Actix" @@ -12,27 +12,34 @@ repository = "https://github.com/graphql-rust/juniper" subscriptions = ["juniper_graphql_ws"] [dependencies] -actix = "0.10" -actix-web = "3.3" -actix-web-actors = "3.0" +actix = "0.11" +# actix-web had some problems in beta release see https://github.com/actix/actix-web/issues/2173#issuecomment-822758353 +# and we need these version specification to handle this issue temporarily while the stable release is not available +# to understand these dependecy version specification see https://github.com/actix/actix-web/issues/2185 or https://github.com/LukeMathWalker/zero-to-production/issues/96 +actix-http = "=3.0.0-beta.5" +actix-service = "=2.0.0-beta.5" +actix-web = "=4.0.0-beta.5" +actix-web-actors = "4.0.0-beta.4" juniper = { version = "0.15.6", path = "../juniper", default-features = false } juniper_graphql_ws = { version = "0.2.5", path = "../juniper_graphql_ws", optional = true } anyhow = "1.0" -futures = "0.3.5" -serde = { version = "1.0.116", features = ["derive"] } -serde_json = "1.0.57" +futures = "0.3" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" thiserror = "1.0" -tokio = { version = "0.2", features = ["time"] } [dev-dependencies] -actix-rt = "1.1" -actix-cors = "0.5" -actix-identity = "0.3" +actix-rt = "2" +actix-cors = "0.6.0-beta.1" +actix-identity = "0.4.0-beta.1" +tokio = "1" +async-stream = "0.3" +actix-test = "0.1.0-beta.1" juniper = { version = "0.15.6", path = "../juniper", features = ["expose-test-schema"] } -bytes = "0.6" +bytes = "1.0" env_logger = "0.8" log = "0.4" diff --git a/juniper_actix/examples/actix_server.rs b/juniper_actix/examples/actix_server.rs index 722e5bcc..982313a5 100644 --- a/juniper_actix/examples/actix_server.rs +++ b/juniper_actix/examples/actix_server.rs @@ -6,6 +6,7 @@ use actix_cors::Cors; use actix_web::{http::header, middleware, web, App, Error, HttpResponse, HttpServer}; use juniper::{graphql_object, EmptyMutation, EmptySubscription, GraphQLObject, RootNode}; use juniper_actix::{graphiql_handler, graphql_handler, playground_handler}; + #[derive(Clone, GraphQLObject)] ///a user pub struct User { diff --git a/juniper_actix/src/lib.rs b/juniper_actix/src/lib.rs index cc68ae63..315632a5 100644 --- a/juniper_actix/src/lib.rs +++ b/juniper_actix/src/lib.rs @@ -215,7 +215,10 @@ pub async fn playground_handler( /// [1]: https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md #[cfg(feature = "subscriptions")] pub mod subscriptions { - use std::{fmt, sync::Arc}; + use std::{ + fmt, + sync::{Arc, Mutex}, + }; use actix::{prelude::*, Actor, StreamHandler}; use actix_web::{ @@ -224,8 +227,6 @@ pub mod subscriptions { }; use actix_web_actors::ws; - use tokio::sync::Mutex; - use juniper::{ futures::{ stream::{SplitSink, SplitStream, StreamExt}, @@ -328,7 +329,7 @@ pub mod subscriptions { let tx = self.graphql_tx.clone(); async move { - let mut tx = tx.lock().await; + let mut tx = tx.lock().unwrap(); tx.send(msg) .await .expect("Infallible: this should not happen"); @@ -365,7 +366,7 @@ pub mod subscriptions { let addr = ctx.address(); let fut = async move { - let mut stream = stream.lock().await; + let mut stream = stream.lock().unwrap(); while let Some(message) = stream.next().await { // sending the message to self so that it can be forwarded back to the client addr.do_send(ServerMessageWrapper { message }); @@ -383,7 +384,7 @@ pub mod subscriptions { } /// actor -> websocket response - impl Handler> + impl actix::prelude::Handler> for SubscriptionActor where Query: GraphQLTypeAsync + Send + 'static, @@ -401,14 +402,11 @@ pub mod subscriptions { fn handle( &mut self, msg: ServerMessageWrapper, - ctx: &mut ws::WebsocketContext, + ctx: &mut Self::Context, ) -> Self::Result { let msg = serde_json::to_string(&msg.message); - match msg { - Ok(msg) => { - ctx.text(msg); - } + Ok(msg) => ctx.text(msg), Err(e) => { let reason = ws::CloseReason { code: ws::CloseCode::Error, @@ -416,12 +414,12 @@ pub mod subscriptions { }; // TODO: trace - ctx.close(Some(reason)); + ctx.close(Some(reason)) } - } + }; + () } } - #[derive(Message)] #[rtype(result = "()")] struct ServerMessageWrapper @@ -483,6 +481,7 @@ mod tests { }; use super::*; + use actix_web::http::header::ACCEPT; type Schema = juniper::RootNode<'static, Query, EmptyMutation, EmptySubscription>; @@ -523,7 +522,7 @@ mod tests { test::init_service(App::new().route("/", web::get().to(graphql_handler))).await; let req = test::TestRequest::get() .uri("/") - .header("accept", "text/html") + .append_header((ACCEPT, "text/html")) .to_request(); let resp = test::call_service(&mut app, req).await; @@ -539,7 +538,7 @@ mod tests { test::init_service(App::new().route("/", web::get().to(graphql_handler))).await; let req = test::TestRequest::get() .uri("/") - .header("accept", "text/html") + .append_header((ACCEPT, "text/html")) .to_request(); let mut resp = test::call_service(&mut app, req).await; @@ -564,7 +563,7 @@ mod tests { test::init_service(App::new().route("/", web::get().to(graphql_handler))).await; let req = test::TestRequest::get() .uri("/") - .header("accept", "text/html") + .append_header((ACCEPT, "text/html")) .to_request(); let resp = test::call_service(&mut app, req).await; @@ -580,7 +579,7 @@ mod tests { test::init_service(App::new().route("/", web::get().to(graphql_handler))).await; let req = test::TestRequest::get() .uri("/") - .header("accept", "text/html") + .append_header((ACCEPT, "text/html")) .to_request(); let mut resp = test::call_service(&mut app, req).await; @@ -602,7 +601,7 @@ mod tests { ); let req = test::TestRequest::post() - .header("content-type", "application/json; charset=utf-8") + .append_header(("content-type", "application/json; charset=utf-8")) .set_payload( r##"{ "variables": null, "query": "{ hero(episode: NEW_HOPE) { name } }" }"##, ) @@ -634,7 +633,7 @@ mod tests { ); let req = test::TestRequest::get() - .header("content-type", "application/json") + .append_header(("content-type", "application/json")) .uri("/?query=%7B%20hero%28episode%3A%20NEW_HOPE%29%20%7B%20name%20%7D%20%7D&variables=null") .to_request(); @@ -668,7 +667,7 @@ mod tests { ); let req = test::TestRequest::post() - .header("content-type", "application/json") + .append_header(("content-type", "application/json")) .set_payload( r##"[ { "variables": null, "query": "{ hero(episode: NEW_HOPE) { name } }" }, @@ -706,7 +705,7 @@ mod tests { impl TestActixWebIntegration { fn make_request(&self, req: test::TestRequest) -> TestResponse { - actix_web::rt::System::new("request").block_on(async move { + actix_web::rt::System::new().block_on(async move { let schema = Schema::new( Query, EmptyMutation::::new(), @@ -730,7 +729,7 @@ mod tests { fn post_json(&self, url: &str, body: &str) -> TestResponse { self.make_request( test::TestRequest::post() - .header("content-type", "application/json") + .append_header(("content-type", "application/json")) .set_payload(body.to_string()) .uri(url), ) @@ -739,7 +738,7 @@ mod tests { fn post_graphql(&self, url: &str, body: &str) -> TestResponse { self.make_request( test::TestRequest::post() - .header("content-type", "application/graphql") + .append_header(("content-type", "application/graphql")) .set_payload(body.to_string()) .uri(url), ) @@ -768,7 +767,8 @@ mod tests { mod subscription_tests { use std::time::Duration; - use actix_web::{test, web, App, Error, HttpRequest, HttpResponse}; + use actix_test::start; + use actix_web::{web, App, Error, HttpRequest, HttpResponse}; use actix_web_actors::ws; use juniper::{ futures::{SinkExt, StreamExt}, @@ -789,7 +789,7 @@ mod subscription_tests { &self, messages: Vec, ) -> Result<(), anyhow::Error> { - let mut server = test::start(|| { + let mut server = start(|| { App::new() .data(Schema::new( Query, @@ -804,7 +804,7 @@ mod subscription_tests { match message { WsIntegrationMessage::Send(body) => { framed - .send(ws::Message::Text(body.to_owned())) + .send(ws::Message::Text(body.to_owned().into())) .await .map_err(|e| anyhow::anyhow!("WS error: {:?}", e))?; } diff --git a/juniper_benchmarks/Cargo.toml b/juniper_benchmarks/Cargo.toml index 1fc93c32..d2f49993 100644 --- a/juniper_benchmarks/Cargo.toml +++ b/juniper_benchmarks/Cargo.toml @@ -10,7 +10,7 @@ juniper = { path = "../juniper" } [dev-dependencies] criterion = "0.3" -tokio = { version = "0.2", features = ["rt-core", "rt-threaded"] } +tokio = { version = "1", features = ["rt-multi-thread"] } [[bench]] name = "benchmark" diff --git a/juniper_graphql_ws/Cargo.toml b/juniper_graphql_ws/Cargo.toml index c9c4010d..deb8dbef 100644 --- a/juniper_graphql_ws/Cargo.toml +++ b/juniper_graphql_ws/Cargo.toml @@ -13,7 +13,7 @@ keywords = ["apollo", "graphql", "graphql-ws", "juniper"] juniper = { version = "0.15.6", path = "../juniper", default-features = false } juniper_subscriptions = { version = "0.15.5", path = "../juniper_subscriptions" } serde = { version = "1.0.8", features = ["derive"], default-features = false } -tokio = { version = "0.2", features = ["macros", "rt-core", "time"], default-features = false } +tokio = { version = "1", features = ["macros", "rt", "time"], default-features = false } [dev-dependencies] serde_json = "1.0" diff --git a/juniper_graphql_ws/src/lib.rs b/juniper_graphql_ws/src/lib.rs index b832d99d..6ad25029 100644 --- a/juniper_graphql_ws/src/lib.rs +++ b/juniper_graphql_ws/src/lib.rs @@ -176,7 +176,7 @@ impl> ConnectionState { .boxed(); s = s .chain(stream::unfold((), move |_| async move { - tokio::time::delay_for(keep_alive_interval).await; + tokio::time::sleep(keep_alive_interval).await; Some(( Reaction::ServerMessage(ServerMessage::ConnectionKeepAlive), (), @@ -658,7 +658,7 @@ mod test { impl Subscription { /// never never emits anything. async fn never(context: &Context) -> BoxStream<'static, FieldResult> { - tokio::time::delay_for(Duration::from_secs(10000)) + tokio::time::sleep(Duration::from_secs(10000)) .map(|_| unreachable!()) .into_stream() .boxed() @@ -668,7 +668,7 @@ mod test { async fn context(context: &Context) -> BoxStream<'static, FieldResult> { stream::once(future::ready(Ok(context.0))) .chain( - tokio::time::delay_for(Duration::from_secs(10000)) + tokio::time::sleep(Duration::from_secs(10000)) .map(|_| unreachable!()) .into_stream(), ) @@ -682,7 +682,7 @@ mod test { Value::null(), )))) .chain( - tokio::time::delay_for(Duration::from_secs(10000)) + tokio::time::sleep(Duration::from_secs(10000)) .map(|_| unreachable!()) .into_stream(), ) diff --git a/juniper_hyper/Cargo.toml b/juniper_hyper/Cargo.toml index d3b84226..09562812 100644 --- a/juniper_hyper/Cargo.toml +++ b/juniper_hyper/Cargo.toml @@ -11,13 +11,13 @@ repository = "https://github.com/graphql-rust/juniper" [dependencies] futures = "0.3.1" juniper = { version = "0.15.6", path = "../juniper", default-features = false } -hyper = "0.13" +hyper = {version = "0.14", features = ["server", "runtime"]} serde_json = "1.0" -tokio = "0.2" +tokio = "1" url = "2" [dev-dependencies] juniper = { version = "0.15.6", path = "../juniper", features = ["expose-test-schema"] } pretty_env_logger = "0.4" reqwest = { version = "0.11", features = ["blocking", "rustls-tls"] } -tokio = { version = "0.2", features = ["macros"] } +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } diff --git a/juniper_hyper/examples/hyper_server.rs b/juniper_hyper/examples/hyper_server.rs index 58488eb9..3187451e 100644 --- a/juniper_hyper/examples/hyper_server.rs +++ b/juniper_hyper/examples/hyper_server.rs @@ -1,8 +1,9 @@ use std::{convert::Infallible, sync::Arc}; use hyper::{ + server::Server, service::{make_service_fn, service_fn}, - Body, Method, Response, Server, StatusCode, + Body, Method, Response, StatusCode, }; use juniper::{ tests::fixtures::starwars::schema::{Database, Query}, diff --git a/juniper_hyper/src/lib.rs b/juniper_hyper/src/lib.rs index 7e7364d4..52e67a92 100644 --- a/juniper_hyper/src/lib.rs +++ b/juniper_hyper/src/lib.rs @@ -312,8 +312,9 @@ impl Error for GraphQLRequestError { #[cfg(test)] mod tests { use hyper::{ + server::Server, service::{make_service_fn, service_fn}, - Body, Method, Response, Server, StatusCode, + Body, Method, Response, StatusCode, }; use juniper::{ http::tests as http_tests, @@ -421,7 +422,7 @@ mod tests { }); let (shutdown_fut, shutdown) = futures::future::abortable(async { - tokio::time::delay_for(Duration::from_secs(60)).await; + tokio::time::sleep(Duration::from_secs(60)).await; }); let server = Server::bind(&addr) diff --git a/juniper_rocket/Cargo.toml b/juniper_rocket/Cargo.toml index 445baf5d..a8da2c45 100644 --- a/juniper_rocket/Cargo.toml +++ b/juniper_rocket/Cargo.toml @@ -13,7 +13,7 @@ repository = "https://github.com/graphql-rust/juniper" [dependencies] juniper = { version = "0.15.6", path = "../juniper", default-features = false} -rocket = { version = "0.4.9", default-features = false } +rocket = { version = "0.4.10", default-features = false } serde_json = "1.0.2" [dev-dependencies] diff --git a/juniper_subscriptions/Cargo.toml b/juniper_subscriptions/Cargo.toml index 58aa4b44..2a100ae3 100644 --- a/juniper_subscriptions/Cargo.toml +++ b/juniper_subscriptions/Cargo.toml @@ -14,4 +14,4 @@ juniper = { version = "0.15.6", path = "../juniper", default-features = false } [dev-dependencies] serde_json = "1.0" -tokio = { version = "0.2", features = ["macros", "rt-core"] } +tokio = { version = "1", features = ["macros", "rt"] } diff --git a/juniper_warp/Cargo.toml b/juniper_warp/Cargo.toml index ca91f7f2..57fce287 100644 --- a/juniper_warp/Cargo.toml +++ b/juniper_warp/Cargo.toml @@ -13,20 +13,19 @@ subscriptions = ["juniper_graphql_ws"] [dependencies] anyhow = "1.0" -bytes = "0.5" futures = "0.3.1" juniper = { version = "0.15.6", path = "../juniper", default-features = false } juniper_graphql_ws = { version = "0.2.5", path = "../juniper_graphql_ws", optional = true } serde = { version = "1.0.75", features = ["derive"] } serde_json = "1.0.24" thiserror = "1.0" -tokio = { version = "0.2", features = ["blocking", "rt-core"] } -warp = "0.2" +tokio = { version = "1", features = ["rt-multi-thread"] } +warp = "0.3" [dev-dependencies] env_logger = "0.8" juniper = { version = "0.15.6", path = "../juniper", features = ["expose-test-schema"] } log = "0.4" percent-encoding = "2.1" -tokio = { version = "0.2", features = ["blocking", "macros", "rt-core"] } +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } url = "2" diff --git a/juniper_warp/src/lib.rs b/juniper_warp/src/lib.rs index 409085a9..64180d70 100644 --- a/juniper_warp/src/lib.rs +++ b/juniper_warp/src/lib.rs @@ -41,7 +41,6 @@ Check the LICENSE file for details. #![doc(html_root_url = "https://docs.rs/juniper_warp/0.2.0")] use anyhow::anyhow; -use bytes::Bytes; use futures::{FutureExt as _, TryFutureExt}; use juniper::{ http::{GraphQLBatchRequest, GraphQLRequest}, @@ -49,7 +48,7 @@ use juniper::{ }; use std::{collections::HashMap, str, sync::Arc}; use tokio::task; -use warp::{body, filters::BoxedFilter, http, query, Filter}; +use warp::{body, filters::BoxedFilter, http, hyper::body::Bytes, query, Filter}; /// Make a filter for graphql queries/mutations. /// @@ -717,7 +716,7 @@ mod tests_http_harness { } fn make_request(&self, req: warp::test::RequestBuilder) -> TestResponse { - let mut rt = tokio::runtime::Runtime::new().expect("Failed to create tokio::Runtime"); + let rt = tokio::runtime::Runtime::new().expect("Failed to create tokio::Runtime"); make_test_response(rt.block_on(async move { req.filter(&self.filter).await.unwrap_or_else(|rejection| { let code = if rejection.is_not_found() {