Skip to content

Commit b6276e8

Browse files
committed
Merge branch 'master' into dependabot/cargo/tokio-tungstenite-0.27
2 parents d71fecb + 4b14c01 commit b6276e8

File tree

4 files changed

+27
-46
lines changed

4 files changed

+27
-46
lines changed

juniper/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ All user visible changes to `juniper` crate will be documented in this file. Thi
9292
- `From` and `Display` implementations are not derived anymore (recommended way is to use [`derive_more` crate] for this).
9393
- `#[derive(GraphQLScalar)]` and `#[graphql_scalar]` macros: ([#1327])
9494
- Made provided `from_input()` function to accept `ScalarValue` (or anything `TryScalarValueTo`-convertible) directly instead of `InputValue`.
95+
- Removed `LocalBoxFuture` usage from `http::tests::WsIntegration` trait. ([todo])
9596

9697
### Added
9798

@@ -145,6 +146,7 @@ All user visible changes to `juniper` crate will be documented in this file. Thi
145146
[#1327]: /../../pull/1327
146147
[1b1fc618]: /../../commit/1b1fc61879ffdd640d741e187dc20678bf7ab295
147148
[20609366]: /../../commit/2060936635609b0186d46d8fbd06eb30fce660e3
149+
[todo]: /../../commit/todo
148150

149151

150152

juniper/src/http/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,6 @@ pub mod tests {
376376

377377
use serde_json::Value as Json;
378378

379-
use crate::LocalBoxFuture;
380-
381379
/// Normalized response content we expect to get back from
382380
/// the http framework integration we are testing.
383381
#[derive(Debug)]
@@ -653,7 +651,7 @@ pub mod tests {
653651
fn run(
654652
&self,
655653
messages: Vec<WsIntegrationMessage>,
656-
) -> LocalBoxFuture<Result<(), anyhow::Error>>;
654+
) -> impl Future<Output = Result<(), anyhow::Error>>;
657655
}
658656

659657
/// WebSocket framework integration message.

juniper_actix/src/lib.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ mod subscription_tests {
758758
use actix_test::start;
759759
use actix_web::{App, Error, HttpRequest, HttpResponse, web};
760760
use juniper::{
761-
EmptyMutation, LocalBoxFuture,
761+
EmptyMutation,
762762
futures::{SinkExt, StreamExt},
763763
http::tests::{WsIntegration, WsIntegrationMessage, graphql_transport_ws, graphql_ws},
764764
tests::fixtures::starwars::schema::{Database, Query, Subscription},
@@ -770,11 +770,8 @@ mod subscription_tests {
770770

771771
struct TestWsIntegration(&'static str);
772772

773-
impl TestWsIntegration {
774-
async fn run_async(
775-
&self,
776-
messages: Vec<WsIntegrationMessage>,
777-
) -> Result<(), anyhow::Error> {
773+
impl WsIntegration for TestWsIntegration {
774+
async fn run(&self, messages: Vec<WsIntegrationMessage>) -> Result<(), anyhow::Error> {
778775
let proto = self.0;
779776

780777
let mut server = start(|| {
@@ -837,15 +834,6 @@ mod subscription_tests {
837834
}
838835
}
839836

840-
impl WsIntegration for TestWsIntegration {
841-
fn run(
842-
&self,
843-
messages: Vec<WsIntegrationMessage>,
844-
) -> LocalBoxFuture<'_, Result<(), anyhow::Error>> {
845-
Box::pin(self.run_async(messages))
846-
}
847-
}
848-
849837
type Schema = juniper::RootNode<Query, EmptyMutation<Database>, Subscription>;
850838

851839
fn subscription(

juniper_axum/tests/ws_test_suite.rs

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use anyhow::anyhow;
99
use axum::{Extension, Router, routing::get};
1010
use futures::{SinkExt, StreamExt};
1111
use juniper::{
12-
EmptyMutation, LocalBoxFuture, RootNode,
12+
EmptyMutation, RootNode,
1313
http::tests::{WsIntegration, WsIntegrationMessage, graphql_transport_ws, graphql_ws},
1414
tests::fixtures::starwars::schema::{Database, Query, Subscription},
1515
};
@@ -23,7 +23,6 @@ use tokio_tungstenite::{MaybeTlsStream, WebSocketStream, connect_async, tungsten
2323

2424
type Schema = RootNode<Query, EmptyMutation<Database>, Subscription>;
2525

26-
#[derive(Clone)]
2726
struct TestApp(Router);
2827

2928
impl TestApp {
@@ -51,27 +50,6 @@ impl TestApp {
5150
Self(router)
5251
}
5352

54-
async fn run(self, messages: Vec<WsIntegrationMessage>) -> Result<(), anyhow::Error> {
55-
let listener = TcpListener::bind("0.0.0.0:0".parse::<SocketAddr>().unwrap())
56-
.await
57-
.unwrap();
58-
let addr = listener.local_addr().unwrap();
59-
60-
tokio::spawn(async move {
61-
axum::serve(listener, self.0).await.unwrap();
62-
});
63-
64-
let (mut websocket, _) = connect_async(format!("ws://{}/subscriptions", addr))
65-
.await
66-
.unwrap();
67-
68-
for msg in messages {
69-
Self::process_message(&mut websocket, msg).await?;
70-
}
71-
72-
Ok(())
73-
}
74-
7553
async fn process_message(
7654
websocket: &mut WebSocketStream<MaybeTlsStream<TcpStream>>,
7755
message: WsIntegrationMessage,
@@ -122,11 +100,26 @@ impl TestApp {
122100
}
123101

124102
impl WsIntegration for TestApp {
125-
fn run(
126-
&self,
127-
messages: Vec<WsIntegrationMessage>,
128-
) -> LocalBoxFuture<'_, Result<(), anyhow::Error>> {
129-
Box::pin(self.clone().run(messages))
103+
async fn run(&self, messages: Vec<WsIntegrationMessage>) -> Result<(), anyhow::Error> {
104+
let listener = TcpListener::bind("0.0.0.0:0".parse::<SocketAddr>().unwrap())
105+
.await
106+
.unwrap();
107+
let addr = listener.local_addr().unwrap();
108+
109+
let router = self.0.clone();
110+
tokio::spawn(async move {
111+
axum::serve(listener, router).await.unwrap();
112+
});
113+
114+
let (mut websocket, _) = connect_async(format!("ws://{}/subscriptions", addr))
115+
.await
116+
.unwrap();
117+
118+
for msg in messages {
119+
Self::process_message(&mut websocket, msg).await?;
120+
}
121+
122+
Ok(())
130123
}
131124
}
132125

0 commit comments

Comments
 (0)