From 280db9480dcf6e7af79267e30fda2951e7688091 Mon Sep 17 00:00:00 2001 From: tyranron Date: Mon, 16 Oct 2023 20:11:15 +0300 Subject: [PATCH] Put behind Cargo features --- .github/workflows/ci.yml | 2 ++ juniper_actix/Cargo.toml | 2 +- juniper_graphql_ws/CHANGELOG.md | 4 ++-- juniper_graphql_ws/Cargo.toml | 17 ++++++++++++++--- juniper_graphql_ws/README.md | 6 +++++- juniper_graphql_ws/src/lib.rs | 8 ++++++++ juniper_warp/Cargo.toml | 2 +- 7 files changed, 33 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f0ae8795..37f11917a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -101,6 +101,8 @@ jobs: - { feature: time, crate: juniper } - { feature: url, crate: juniper } - { feature: uuid, crate: juniper } + - { feature: graphql-transport-ws, crate: juniper_graphql_ws } + - { feature: graphql-ws, crate: juniper_graphql_ws } - { feature: , crate: juniper_actix } - { feature: subscriptions, crate: juniper_actix } - { feature: , crate: juniper_warp } diff --git a/juniper_actix/Cargo.toml b/juniper_actix/Cargo.toml index 1fdf90b38..7b5d02466 100644 --- a/juniper_actix/Cargo.toml +++ b/juniper_actix/Cargo.toml @@ -34,7 +34,7 @@ actix-web-actors = { version = "4.1", optional = true } anyhow = "1.0.47" futures = "0.3.22" juniper = { version = "0.16.0-dev", path = "../juniper", default-features = false } -juniper_graphql_ws = { version = "0.4.0-dev", path = "../juniper_graphql_ws", optional = true } +juniper_graphql_ws = { version = "0.4.0-dev", path = "../juniper_graphql_ws", features = ["graphql-transport-ws", "graphql-ws"], optional = true } http = "0.2.4" serde = { version = "1.0.122", features = ["derive"] } serde_json = "1.0.18" diff --git a/juniper_graphql_ws/CHANGELOG.md b/juniper_graphql_ws/CHANGELOG.md index d525af5f2..5c84f57f1 100644 --- a/juniper_graphql_ws/CHANGELOG.md +++ b/juniper_graphql_ws/CHANGELOG.md @@ -10,13 +10,13 @@ All user visible changes to `juniper_graphql_ws` crate will be documented in thi ### BC Breaks -- Moved existing implementation to `graphql_ws` module implementing [legacy `graphql-ws` GraphQL over WebSocket Protocol][proto-legacy]. ([#1196]) +- Moved existing implementation to `graphql_ws` module implementing [legacy `graphql-ws` GraphQL over WebSocket Protocol][proto-legacy] behind `graphql-ws` Cargo feature. ([#1196]) - Switched to 0.16 version of [`juniper` crate]. - Switched to 0.17 version of [`juniper_subscriptions` crate]. ### Added -- `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]. ([#1158], [#1191], [#1196], [#1022]) +- `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]) ### Changed diff --git a/juniper_graphql_ws/Cargo.toml b/juniper_graphql_ws/Cargo.toml index 51e39e5c8..385e95121 100644 --- a/juniper_graphql_ws/Cargo.toml +++ b/juniper_graphql_ws/Cargo.toml @@ -3,17 +3,28 @@ name = "juniper_graphql_ws" version = "0.4.0-dev" edition = "2021" rust-version = "1.65" -description = "Legacy `graphql-ws` GraphQL over WebSocket Protocol implementation for `juniper` crate." +description = "GraphQL over WebSocket Protocol implementations for `juniper` crate." license = "BSD-2-Clause" -authors = ["Christopher Brown "] +authors = [ + "Christopher Brown ", + "Kai Ren ", +] documentation = "https://docs.rs/juniper_graphql_ws" homepage = "https://github.com/graphql-rust/juniper/tree/master/juniper_graphql_ws" repository = "https://github.com/graphql-rust/juniper" readme = "README.md" categories = ["asynchronous", "web-programming", "web-programming::http-server"] -keywords = ["apollo", "graphql", "graphql-ws", "subscription", "websocket"] +keywords = ["apollo", "graphql-transport-ws", "graphql-ws", "subscription", "websocket"] exclude = ["/release.toml"] +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[features] +graphql-transport-ws = [] +graphql-ws = [] + [dependencies] juniper = { version = "0.16.0-dev", path = "../juniper", default-features = false } juniper_subscriptions = { version = "0.17.0-dev", path = "../juniper_subscriptions" } diff --git a/juniper_graphql_ws/README.md b/juniper_graphql_ws/README.md index 110577149..5710b8cf6 100644 --- a/juniper_graphql_ws/README.md +++ b/juniper_graphql_ws/README.md @@ -8,7 +8,11 @@ - [Changelog](https://github.com/graphql-rust/juniper/blob/master/juniper_graphql_ws/CHANGELOG.md) -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 and new [`graphql-ws` npm package]. +This crate contains implementations of 2 protocols: + +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]. + +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). diff --git a/juniper_graphql_ws/src/lib.rs b/juniper_graphql_ws/src/lib.rs index a788ee8c8..b8aceed4b 100644 --- a/juniper_graphql_ws/src/lib.rs +++ b/juniper_graphql_ws/src/lib.rs @@ -1,7 +1,15 @@ #![doc = include_str!("../README.md")] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![deny(missing_docs, warnings)] +#[cfg(not(any(feature = "graphql-transport-ws", feature = "graphql-ws")))] +compile_error!( + r#"at least one feature must be enabled (either "graphql-transport-ws" or "graphql-ws")"# +); + +#[cfg(feature = "graphql-transport-ws")] pub mod graphql_transport_ws; +#[cfg(feature = "graphql-ws")] pub mod graphql_ws; mod schema; mod server_message; diff --git a/juniper_warp/Cargo.toml b/juniper_warp/Cargo.toml index 14d35f2da..3c124b4ab 100644 --- a/juniper_warp/Cargo.toml +++ b/juniper_warp/Cargo.toml @@ -29,7 +29,7 @@ subscriptions = [ anyhow = "1.0.47" futures = "0.3.22" juniper = { version = "0.16.0-dev", path = "../juniper", default-features = false } -juniper_graphql_ws = { version = "0.4.0-dev", path = "../juniper_graphql_ws", optional = true } +juniper_graphql_ws = { version = "0.4.0-dev", path = "../juniper_graphql_ws", features = ["graphql-transport-ws", "graphql-ws"], optional = true } log = { version = "0.4", optional = true } serde = { version = "1.0.122", features = ["derive"] } serde_json = "1.0.18"