Add feature gate `websocket` for async-graphql-tide.

This commit is contained in:
Sunli 2021-09-17 08:39:28 +08:00
parent 024a143f11
commit e342610d29
4 changed files with 9 additions and 1 deletions

View File

@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
- Add support for `graphql-ws` pings. [#635](https://github.com/async-graphql/async-graphql/issues/635)
- Add feature gate `websocket` for async-graphql-tide. [#636](https://github.com/async-graphql/async-graphql/issues/636)
## [2.9.15] 2021-09-10

View File

@ -11,6 +11,10 @@ repository = "https://github.com/async-graphql/async-graphql"
keywords = ["futures", "async", "graphql"]
categories = ["network-programming", "asynchronous"]
[features]
default = ["websocket"]
websocket = ["tide-websockets"]
[dependencies]
async-graphql = { path = "../..", version = "=2.9.15" }
async-trait = "0.1.48"
@ -18,7 +22,7 @@ futures-util = "0.3.13"
serde_json = "1.0.64"
tide = { version = "0.16.0", default-features = false, features = ["h1-server"] }
tide-websockets = "0.3.0"
tide-websockets = { version = "0.4.0", optional = true }
[dev-dependencies]
# Surf lacks multipart support

View File

@ -8,6 +8,7 @@
#![allow(clippy::needless_doctest_main)]
#![forbid(unsafe_code)]
#[cfg(feature = "websocket")]
mod subscription;
use async_graphql::http::MultipartOptions;
@ -21,6 +22,7 @@ use tide::{
Body, Request, Response, StatusCode,
};
#[cfg(feature = "websocket")]
pub use subscription::Subscription;
/// Create a new GraphQL endpoint with the schema.

View File

@ -9,6 +9,7 @@ use tide::{Endpoint, Request, Response};
use tide_websockets::Message;
/// GraphQL subscription endpoint.
#[cfg_attr(docsrs, doc(cfg(feature = "websocket")))]
pub struct Subscription<S> {
inner: Pin<Box<dyn Endpoint<S>>>,
}