graphql_ws_client/lib.rs
1//! # graphql-ws-client
2//!
3//! graphql-ws-client implements asynchronous GraphQL-over-Websocket using the
4//! [graphql-transport-ws protocol][protocol]. It is websocket client, graphql
5//! client _and_ async runtime agnostic. Built in support is provided for:
6//!
7//! - [Cynic][cynic] & [Graphql-Client][graphql-client] GraphQL clients.
8//! - [async-tungstenite][async-tungstenite], [tokio-tungstenite][tokio-tungstenite]
9//! & [ws-stream-wasm][ws-stream-wasm] Websocket Clients .
10//! - Any async runtime.
11//!
12//! If you'd like to use another client or adding support should be trivial.
13//!
14//! ```rust
15//! use graphql_ws_client::Client;
16//! use std::future::IntoFuture;
17//! use futures_lite::StreamExt;
18//! # async fn example() -> Result<(), graphql_ws_client::Error> {
19//! # let connection = graphql_ws_client::__doc_utils::Conn;
20//! # let subscription = graphql_ws_client::__doc_utils::Subscription;
21//!
22//! let mut stream = Client::build(connection).subscribe(subscription).await?;
23//!
24//! while let Some(response) = stream.next().await {
25//! // Do something with response
26//! }
27//! # Ok(())
28//! # }
29//! ```
30//!
31//! See the [examples][examples] for more thorough usage details.
32//!
33//! [protocol]: https://github.com/graphql/graphql-over-http/blob/main/rfcs/GraphQLOverWebSocket.md
34//! [cynic]: https://cynic-rs.dev
35//! [graphql-client]: https://github.com/graphql-rust/graphql-client
36//! [async-tungstenite]: https://github.com/sdroege/async-tungstenite
37//! [tokio-tungstenite]: https://github.com/snapview/tokio-tungstenite
38//! [ws-stream-wasm]: https://github.com/najamelan/ws_stream_wasm
39//! [examples]: https://github.com/obmarg/graphql-ws-client/tree/main/examples/examples
40
41#![cfg_attr(docsrs, feature(doc_cfg))]
42#![warn(missing_docs)]
43
44mod error;
45mod logging;
46mod protocol;
47mod sink_ext;
48
49#[doc(hidden)]
50#[path = "doc_utils.rs"]
51pub mod __doc_utils;
52
53pub mod graphql;
54
55mod next;
56
57#[cfg(feature = "ws_stream_wasm")]
58#[cfg_attr(docsrs, doc(cfg(feature = "ws_stream_wasm")))]
59/// Integration with the [ws_stream_wasm][1] library
60///
61/// [1]: https://docs.rs/ws_stream/latest/ws_stream
62pub mod ws_stream_wasm;
63
64#[cfg(feature = "tungstenite")]
65#[cfg_attr(docsrs, doc(cfg(feature = "tungstenite")))]
66mod native;
67
68pub use next::*;
69
70pub use error::Error;