Skip to content

Commit aaf28e9

Browse files
authored
Merge juniper_graphql_transport_ws and juniper_graphql_ws crates (#1196, #1022)
1 parent f3a1a0c commit aaf28e9

File tree

29 files changed

+1220
-1361
lines changed

29 files changed

+1220
-1361
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ jobs:
101101
- { feature: time, crate: juniper }
102102
- { feature: url, crate: juniper }
103103
- { feature: uuid, crate: juniper }
104+
- { feature: graphql-transport-ws, crate: juniper_graphql_ws }
105+
- { feature: graphql-ws, crate: juniper_graphql_ws }
104106
- { feature: <none>, crate: juniper_actix }
105107
- { feature: subscriptions, crate: juniper_actix }
106108
- { feature: <none>, crate: juniper_warp }
@@ -134,7 +136,6 @@ jobs:
134136
- juniper_codegen
135137
- juniper
136138
- juniper_subscriptions
137-
- juniper_graphql_transport_ws
138139
- juniper_graphql_ws
139140
#- juniper_actix
140141
- juniper_hyper
@@ -189,7 +190,6 @@ jobs:
189190
- juniper_codegen
190191
- juniper
191192
- juniper_subscriptions
192-
- juniper_graphql_transport_ws
193193
- juniper_graphql_ws
194194
- juniper_integration_tests
195195
- juniper_codegen_tests
@@ -318,7 +318,6 @@ jobs:
318318
- juniper_codegen
319319
- juniper
320320
- juniper_subscriptions
321-
- juniper_graphql_transport_ws
322321
- juniper_graphql_ws
323322
- juniper_actix
324323
- juniper_hyper

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ members = [
88
"juniper_iron",
99
"juniper_rocket",
1010
"juniper_subscriptions",
11-
"juniper_graphql_transport_ws",
1211
"juniper_graphql_ws",
1312
"juniper_warp",
1413
"juniper_actix",

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ ifeq ($(clean),yes)
9494
cargo clean
9595
endif
9696
$(eval target := $(strip $(shell cargo -vV | sed -n 's/host: //p')))
97-
cargo build
97+
cargo build --all-features
9898
mdbook test book -L target/debug/deps $(strip \
9999
$(if $(call eq,$(findstring windows,$(target)),),,\
100100
$(shell cargo metadata -q \

juniper_actix/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ rustdoc-args = ["--cfg", "docsrs"]
2222
subscriptions = [
2323
"dep:actix",
2424
"dep:actix-web-actors",
25-
"dep:juniper_graphql_transport_ws",
2625
"dep:juniper_graphql_ws",
2726
"dep:tokio",
2827
]
@@ -35,8 +34,7 @@ actix-web-actors = { version = "4.1", optional = true }
3534
anyhow = "1.0.47"
3635
futures = "0.3.22"
3736
juniper = { version = "0.16.0-dev", path = "../juniper", default-features = false }
38-
juniper_graphql_transport_ws = { version = "0.4.0-dev", path = "../juniper_graphql_transport_ws", optional = true }
39-
juniper_graphql_ws = { version = "0.4.0-dev", path = "../juniper_graphql_ws", optional = true }
37+
juniper_graphql_ws = { version = "0.4.0-dev", path = "../juniper_graphql_ws", features = ["graphql-transport-ws", "graphql-ws"], optional = true }
4038
http = "0.2.4"
4139
serde = { version = "1.0.122", features = ["derive"] }
4240
serde_json = "1.0.18"

juniper_actix/src/lib.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ pub mod subscriptions {
183183
SinkExt as _, Stream, StreamExt as _,
184184
};
185185
use juniper::{GraphQLSubscriptionType, GraphQLTypeAsync, RootNode, ScalarValue};
186-
use juniper_graphql_transport_ws::{ArcSchema, Init};
186+
use juniper_graphql_ws::{graphql_transport_ws, graphql_ws, ArcSchema, Init};
187187
use tokio::sync::Mutex;
188188

189189
/// Serves by auto-selecting between the
@@ -194,11 +194,10 @@ pub mod subscriptions {
194194
/// The `schema` argument is your [`juniper`] schema.
195195
///
196196
/// The `init` argument is used to provide the custom [`juniper::Context`] and additional
197-
/// configuration for connections. This can be a
198-
/// [`juniper_graphql_transport_ws::ConnectionConfig`] if the context and configuration are
199-
/// already known, or it can be a closure that gets executed asynchronously whenever a client
200-
/// sends the subscription initialization message. Using a closure allows to perform an
201-
/// authentication based on the parameters provided by a client.
197+
/// configuration for connections. This can be a [`juniper_graphql_ws::ConnectionConfig`] if the
198+
/// context and configuration are already known, or it can be a closure that gets executed
199+
/// asynchronously whenever a client sends the subscription initialization message. Using a
200+
/// closure allows to perform an authentication based on the parameters provided by a client.
202201
///
203202
/// [new]: https://github.com/enisdenjo/graphql-ws/blob/v5.14.0/PROTOCOL.md
204203
/// [old]: https://github.com/apollographql/subscriptions-transport-ws/blob/v0.11.0/PROTOCOL.md
@@ -262,8 +261,7 @@ pub mod subscriptions {
262261
S: ScalarValue + Send + Sync + 'static,
263262
I: Init<S, CtxT> + Send,
264263
{
265-
let (s_tx, s_rx) =
266-
juniper_graphql_ws::Connection::new(ArcSchema(schema), init).split::<Message>();
264+
let (s_tx, s_rx) = graphql_ws::Connection::new(ArcSchema(schema), init).split::<Message>();
267265

268266
let mut resp = ws::start(
269267
Actor {
@@ -285,10 +283,10 @@ pub mod subscriptions {
285283
/// Serves the [new `graphql-transport-ws` GraphQL over WebSocket Protocol][new].
286284
///
287285
/// The `init` argument is used to provide the context and additional configuration for
288-
/// connections. This can be a [`juniper_graphql_transport_ws::ConnectionConfig`] if the context
289-
/// and configuration are already known, or it can be a closure that gets executed
290-
/// asynchronously when the client sends the `ConnectionInit` message. Using a closure allows to
291-
/// perform an authentication based on the parameters provided by a client.
286+
/// connections. This can be a [`juniper_graphql_ws::ConnectionConfig`] if the context and
287+
/// configuration are already known, or it can be a closure that gets executed asynchronously
288+
/// when the client sends the `ConnectionInit` message. Using a closure allows to perform an
289+
/// authentication based on the parameters provided by a client.
292290
///
293291
/// [new]: https://github.com/enisdenjo/graphql-ws/blob/v5.14.0/PROTOCOL.md
294292
pub async fn graphql_transport_ws_handler<Query, Mutation, Subscription, CtxT, S, I>(
@@ -308,8 +306,8 @@ pub mod subscriptions {
308306
S: ScalarValue + Send + Sync + 'static,
309307
I: Init<S, CtxT> + Send,
310308
{
311-
let (s_tx, s_rx) = juniper_graphql_transport_ws::Connection::new(ArcSchema(schema), init)
312-
.split::<Message>();
309+
let (s_tx, s_rx) =
310+
graphql_transport_ws::Connection::new(ArcSchema(schema), init).split::<Message>();
313311

314312
let mut resp = ws::start(
315313
Actor {
@@ -429,7 +427,7 @@ pub mod subscriptions {
429427
fn into_ws_response(self) -> Result<String, ws::CloseReason>;
430428
}
431429

432-
impl<S: ScalarValue> IntoWsResponse for juniper_graphql_transport_ws::Output<S> {
430+
impl<S: ScalarValue> IntoWsResponse for graphql_transport_ws::Output<S> {
433431
fn into_ws_response(self) -> Result<String, ws::CloseReason> {
434432
match self {
435433
Self::Message(msg) => serde_json::to_string(&msg).map_err(|e| ws::CloseReason {
@@ -444,7 +442,7 @@ pub mod subscriptions {
444442
}
445443
}
446444

447-
impl<S: ScalarValue> IntoWsResponse for juniper_graphql_ws::ServerMessage<S> {
445+
impl<S: ScalarValue> IntoWsResponse for graphql_ws::ServerMessage<S> {
448446
fn into_ws_response(self) -> Result<String, ws::CloseReason> {
449447
serde_json::to_string(&self).map_err(|e| ws::CloseReason {
450448
code: ws::CloseCode::Error,
@@ -456,7 +454,7 @@ pub mod subscriptions {
456454
#[derive(Debug)]
457455
struct Message(ws::Message);
458456

459-
impl<S: ScalarValue> TryFrom<Message> for juniper_graphql_transport_ws::Input<S> {
457+
impl<S: ScalarValue> TryFrom<Message> for graphql_transport_ws::Input<S> {
460458
type Error = Error;
461459

462460
fn try_from(msg: Message) -> Result<Self, Self::Error> {
@@ -470,7 +468,7 @@ pub mod subscriptions {
470468
}
471469
}
472470

473-
impl<S: ScalarValue> TryFrom<Message> for juniper_graphql_ws::ClientMessage<S> {
471+
impl<S: ScalarValue> TryFrom<Message> for graphql_ws::ClientMessage<S> {
474472
type Error = Error;
475473

476474
fn try_from(msg: Message) -> Result<Self, Self::Error> {

juniper_graphql_transport_ws/CHANGELOG.md

Lines changed: 0 additions & 27 deletions
This file was deleted.

juniper_graphql_transport_ws/Cargo.toml

Lines changed: 0 additions & 25 deletions
This file was deleted.

juniper_graphql_transport_ws/LICENSE

Lines changed: 0 additions & 25 deletions
This file was deleted.

juniper_graphql_transport_ws/README.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

juniper_graphql_transport_ws/release.toml

Lines changed: 0 additions & 24 deletions
This file was deleted.

juniper_graphql_transport_ws/src/schema.rs

Lines changed: 0 additions & 2 deletions
This file was deleted.

juniper_graphql_ws/CHANGELOG.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,24 @@ All user visible changes to `juniper_graphql_ws` crate will be documented in thi
1010

1111
### BC Breaks
1212

13+
- Moved existing implementation to `graphql_ws` module implementing [legacy `graphql-ws` GraphQL over WebSocket Protocol][proto-legacy] behind `graphql-ws` Cargo feature. ([#1196])
1314
- Switched to 0.16 version of [`juniper` crate].
1415
- Switched to 0.17 version of [`juniper_subscriptions` crate].
1516

17+
### Added
18+
19+
- `graphql_transport_ws` module implementing [`graphql-transport-ws` GraphQL over WebSocket Protocol][proto-5.14.0] as of 5.14.0 version of [`graphql-ws` npm package] behind `graphql-transport-ws` Cargo feature. ([#1158], [#1191], [#1196], [#1022])
20+
1621
### Changed
1722

18-
- Made fields of `ConnectionConfig` public to reuse in [`juniper_graphql_transport_ws` crate]. ([#1191])
23+
- Made fields of `ConnectionConfig` public. ([#1191])
1924

25+
[#1022]: /../../issues/1022
26+
[#1158]: /../../pull/1158
2027
[#1191]: /../../pull/1191
28+
[#1196]: /../../pull/1196
29+
[proto-5.14.0]: https://github.com/enisdenjo/graphql-ws/blob/v5.14.0/PROTOCOL.md
30+
[proto-legacy]: https://github.com/apollographql/subscriptions-transport-ws/blob/v0.11.0/PROTOCOL.md
2131

2232

2333

@@ -29,7 +39,7 @@ See [old CHANGELOG](/../../blob/juniper_graphql_ws-v0.3.0/juniper_graphql_ws/CHA
2939

3040

3141

42+
[`graphql-ws` npm package]: https://npmjs.com/package/graphql-ws
3243
[`juniper` crate]: https://docs.rs/juniper
33-
[`juniper_graphql_transport_ws` crate]: https://docs.rs/juniper_graphql_transport_ws
3444
[`juniper_subscriptions` crate]: https://docs.rs/juniper_subscriptions
3545
[Semantic Versioning 2.0.0]: https://semver.org

juniper_graphql_ws/Cargo.toml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,28 @@ name = "juniper_graphql_ws"
33
version = "0.4.0-dev"
44
edition = "2021"
55
rust-version = "1.65"
6-
description = "Legacy `graphql-ws` GraphQL over WebSocket Protocol implementation for `juniper` crate."
6+
description = "GraphQL over WebSocket Protocol implementations for `juniper` crate."
77
license = "BSD-2-Clause"
8-
authors = ["Christopher Brown <[email protected]>"]
8+
authors = [
9+
"Christopher Brown <[email protected]>",
10+
"Kai Ren <[email protected]>",
11+
]
912
documentation = "https://docs.rs/juniper_graphql_ws"
1013
homepage = "https://github.com/graphql-rust/juniper/tree/master/juniper_graphql_ws"
1114
repository = "https://github.com/graphql-rust/juniper"
1215
readme = "README.md"
1316
categories = ["asynchronous", "web-programming", "web-programming::http-server"]
14-
keywords = ["apollo", "graphql", "graphql-ws", "subscription", "websocket"]
17+
keywords = ["apollo", "graphql-transport-ws", "graphql-ws", "subscription", "websocket"]
1518
exclude = ["/release.toml"]
1619

20+
[package.metadata.docs.rs]
21+
all-features = true
22+
rustdoc-args = ["--cfg", "docsrs"]
23+
24+
[features]
25+
graphql-transport-ws = []
26+
graphql-ws = []
27+
1728
[dependencies]
1829
juniper = { version = "0.16.0-dev", path = "../juniper", default-features = false }
1930
juniper_subscriptions = { version = "0.17.0-dev", path = "../juniper_subscriptions" }

juniper_graphql_ws/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88

99
- [Changelog](https://github.com/graphql-rust/juniper/blob/master/juniper_graphql_ws/CHANGELOG.md)
1010

11-
This crate contains an implementation of the [legacy `graphql-ws` GraphQL over WebSocket Protocol][old], as formerly used by [Apollo] and [`subscriptions-transport-ws` npm package]. It has now been deprecated in favor of the [new `graphql-transport-ws` GraphQL over WebSocket Protocol][new], implemented by the new [`juniper_graphql_transport_ws` crate] and new [`graphql-ws` npm package].
11+
This crate contains implementations of 2 protocols:
12+
13+
1. (`graphql-transport-ws` feature) The [new `graphql-transport-ws` GraphQL over WebSocket Protocol][new], as now used by [Apollo] and [`graphql-ws` npm package].
14+
15+
2. (`graphql-ws` feature) The [legacy `graphql-ws` GraphQL over WebSocket Protocol][old], as formerly used by [Apollo] and [`subscriptions-transport-ws` npm package] (deprecated in favor of the [new `graphql-transport-ws` GraphQL over WebSocket Protocol][new] mentioned above).
1216

1317

1418

@@ -21,7 +25,6 @@ This project is licensed under [BSD 2-Clause License](https://github.com/graphql
2125

2226

2327
[`graphql-ws` npm package]: https://npmjs.com/package/graphql-ws
24-
[`juniper_graphql_transport_ws` crate]: https://docs.rs/juniper_graphql_transport_ws
2528
[`subscriptions-transport-ws` npm package]: https://npmjs.com/package/subscriptions-transport-ws
2629
[Apollo]: https://www.apollographql.com
2730
[new]: https://github.com/enisdenjo/graphql-ws/blob/v5.14.0/PROTOCOL.md

juniper_graphql_transport_ws/src/client_message.rs renamed to juniper_graphql_ws/src/graphql_transport_ws/client_message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use juniper::Variables;
22
use serde::Deserialize;
33

4-
use crate::utils::default_for_null;
4+
use crate::util::default_for_null;
55

66
/// The payload for a client's "start" message. This triggers execution of a query, mutation, or
77
/// subscription.

0 commit comments

Comments
 (0)