1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
//! # graphql-ws-client
//!
//! graphql-ws-client implements asynchronous GraphQL-over-Websocket using the
//! [graphql-transport-ws protocol][protocol]. It is websocket client, graphql
//! client _and_ async runtime agnostic. Built in support is provided for:
//!
//! - [Cynic][cynic] & [Graphql-Client][graphql-client] GraphQL clients.
//! - [async-tungstenite][async-tungstenite] & [ws-stream-wasm][ws-stream-wasm] Websocket Clients .
//! - Any async runtime.
//!
//! If you'd like to use another client or adding support should be trivial.
//!
//! ```rust
//! use graphql_ws_client::Client;
//! use std::future::IntoFuture;
//! use futures::StreamExt;
//! # async fn example() -> Result<(), graphql_ws_client::Error> {
//! # let connection = graphql_ws_client::__doc_utils::Conn;
//! # let subscription = graphql_ws_client::__doc_utils::Subscription;
//!
//! let mut stream = Client::build(connection).subscribe(subscription).await?;
//!
//! while let Some(response) = stream.next().await {
//! // Do something with response
//! }
//! # Ok(())
//! # }
//! ```
//!
//! See the [examples][examples] for more thorough usage details.
//!
//! [protocol]: https://github.com/graphql/graphql-over-http/blob/main/rfcs/GraphQLOverWebSocket.md
//! [cynic]: https://cynic-rs.dev
//! [graphql-client]: https://github.com/graphql-rust/graphql-client
//! [async-tungstenite]: https://github.com/sdroege/async-tungstenite
//! [ws-stream-wasm]: https://github.com/najamelan/ws_stream_wasm
//! [examples]: https://github.com/obmarg/graphql-ws-client/tree/main/examples/examples
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(missing_docs)]
mod error;
mod logging;
mod protocol;
#[doc(hidden)]
pub mod legacy;
#[doc(hidden)]
#[path = "doc_utils.rs"]
pub mod __doc_utils;
pub mod graphql;
mod next;
#[cfg(feature = "ws_stream_wasm")]
#[cfg_attr(docsrs, doc(cfg(feature = "ws_stream_wasm")))]
/// Integration with the ws_stream_wasm library
pub mod ws_stream_wasm;
#[cfg(any(feature = "async-tungstenite", feature = "tungstenite"))]
mod native;
#[allow(deprecated)]
pub use legacy::{
client::{AsyncWebsocketClient, AsyncWebsocketClientBuilder, SubscriptionStream},
websockets,
};
#[cfg(feature = "ws_stream_wasm")]
#[cfg_attr(docsrs, doc(cfg(feature = "ws_stream_wasm")))]
#[allow(deprecated)]
pub use legacy::wasm::{
wasm_websocket_combined_split, FusedWasmWebsocketSink, WasmWebsocketMessage,
};
pub use next::*;
pub use error::Error;
/// A websocket client for the cynic graphql crate
#[cfg(feature = "cynic")]
#[cfg_attr(docsrs, doc(cfg(feature = "cynic")))]
#[allow(deprecated)]
#[deprecated(
since = "0.8.0-rc.1",
note = "graphql-ws-client no longer needs client specific types. Use the general purpose Client instead"
)]
pub type CynicClient<WsMessage> = AsyncWebsocketClient<WsMessage>;
/// A websocket client builder for the cynic graphql crate
#[cfg(feature = "cynic")]
#[cfg_attr(docsrs, doc(cfg(feature = "cynic")))]
#[allow(deprecated)]
#[deprecated(
since = "0.8.0-rc.1",
note = "graphql-ws-client no longer needs client specific types. Use the general purpose Client instead"
)]
pub type CynicClientBuilder = AsyncWebsocketClientBuilder;
/// A websocket client for the graphql_client graphql crate
#[cfg(feature = "client-graphql-client")]
#[cfg_attr(docsrs, doc(cfg(feature = "client-graphql-client")))]
#[allow(deprecated)]
#[deprecated(
since = "0.8.0-rc.1",
note = "graphql-ws-client no longer needs client specific types. Use the general purpose Client instead"
)]
pub type GraphQLClientClient<WsMessage> = AsyncWebsocketClient<WsMessage>;
/// A websocket client builder for the graphql_client graphql crate
#[cfg(feature = "client-graphql-client")]
#[cfg_attr(docsrs, doc(cfg(feature = "client-graphql-client")))]
#[allow(deprecated)]
#[deprecated(
since = "0.8.0-rc.1",
note = "graphql-ws-client no longer needs client specific types. Use the general purpose Client instead"
)]
pub type GraphQLClientClientBuilder = AsyncWebsocketClientBuilder;