From 13a80718ba2e6e188ea4223d1070b9c88edd8e20 Mon Sep 17 00:00:00 2001 From: Joe Grund Date: Sat, 28 Dec 2024 12:18:24 -0500 Subject: [PATCH 1/2] Bump juniper_axum crate to axum 0.8 Signed-off-by: Joe Grund --- juniper_axum/Cargo.toml | 4 ++-- juniper_axum/src/extract.rs | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/juniper_axum/Cargo.toml b/juniper_axum/Cargo.toml index 0b664775c..b2c8273f0 100644 --- a/juniper_axum/Cargo.toml +++ b/juniper_axum/Cargo.toml @@ -25,7 +25,7 @@ rustdoc-args = ["--cfg", "docsrs"] subscriptions = ["axum/ws", "juniper_graphql_ws/graphql-ws", "dep:futures"] [dependencies] -axum = { version = "0.7", features = ["json", "query"], default-features = false } +axum = { version = "=0.8.1", features = ["json", "query"], default-features = false } futures = { version = "0.3.22", optional = true } juniper = { version = "0.16", path = "../juniper", default-features = false } juniper_graphql_ws = { version = "0.4.0", path = "../juniper_graphql_ws", features = ["graphql-transport-ws"] } @@ -38,7 +38,7 @@ bytes = "1.2" [dev-dependencies] anyhow = "1.0" -axum = { version = "0.7", features = ["http1", "macros", "tokio"] } +axum = { version = "0.8", features = ["http1", "macros", "tokio"] } futures = "0.3.22" juniper = { version = "0.16", path = "../juniper", features = ["expose-test-schema"] } tokio = { version = "1.20", features = ["macros", "net", "rt-multi-thread", "time"] } diff --git a/juniper_axum/src/extract.rs b/juniper_axum/src/extract.rs index 1029d05e0..c8caec708 100644 --- a/juniper_axum/src/extract.rs +++ b/juniper_axum/src/extract.rs @@ -3,7 +3,6 @@ use std::fmt; use axum::{ - async_trait, body::Body, extract::{FromRequest, FromRequestParts, Query}, http::{header, HeaderValue, Method, Request, StatusCode}, @@ -70,7 +69,6 @@ pub struct JuniperRequest(pub GraphQLBatchRequest) where S: ScalarValue; -#[async_trait] impl FromRequest for JuniperRequest where S: ScalarValue, From 838cbe3cd0fcca31dc05a9b0defd2f2e3ddbbdb1 Mon Sep 17 00:00:00 2001 From: Joe Grund Date: Wed, 1 Jan 2025 12:33:58 -0500 Subject: [PATCH 2/2] Fix subscription Signed-off-by: Joe Grund --- juniper_axum/src/subscriptions.rs | 4 ++-- juniper_axum/tests/ws_test_suite.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/juniper_axum/src/subscriptions.rs b/juniper_axum/src/subscriptions.rs index cc1ec7d70..9ca12b8bd 100644 --- a/juniper_axum/src/subscriptions.rs +++ b/juniper_axum/src/subscriptions.rs @@ -488,7 +488,7 @@ where Ok(match output { graphql_transport_ws::Output::Message(msg) => { serde_json::to_string(&msg) - .map(ws::Message::Text) + .map(ws::Message::text) .unwrap_or_else(|e| { ws::Message::Close(Some(ws::CloseFrame { code: 1011, // CloseCode::Error @@ -618,7 +618,7 @@ where let output = s_rx .map(|msg| { Ok(serde_json::to_string(&msg) - .map(ws::Message::Text) + .map(ws::Message::text) .unwrap_or_else(|e| { ws::Message::Close(Some(ws::CloseFrame { code: 1011, // CloseCode::Error diff --git a/juniper_axum/tests/ws_test_suite.rs b/juniper_axum/tests/ws_test_suite.rs index f60f671e1..92d7de1ca 100644 --- a/juniper_axum/tests/ws_test_suite.rs +++ b/juniper_axum/tests/ws_test_suite.rs @@ -88,7 +88,7 @@ impl TestApp { None => Err(anyhow!("No message received")), Some(Err(e)) => Err(anyhow!("WebSocket error: {e}")), Some(Ok(Message::Text(json))) => { - let actual: serde_json::Value = serde_json::from_str(&*json) + let actual: serde_json::Value = serde_json::from_str(&json) .map_err(|e| anyhow!("Cannot deserialize received message: {e}"))?; if actual != expected { return Err(anyhow!(