diff --git a/CHANGELOG.md b/CHANGELOG.md index a4818e1..c47077f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,12 +15,15 @@ all APIs might be changed. - Fixed ping responses not following the graphql-transport-ws protocol ([#116](https://github.com/obmarg/graphql-ws-client/pull/116)) +- `graphql-transport-ws` ping messages are now sent, instead of websocket ping + frames, when using the `KeepAliveSettings` ([#117](https://github.com/obmarg/graphql-ws-client/pull/117)) ### Contributors Thanks to the people who contributed to this release: - @vorporeal +- @szgupta ## v0.10.1 - 2024-06-08 diff --git a/src/next/actor.rs b/src/next/actor.rs index b05016a..8fc8807 100644 --- a/src/next/actor.rs +++ b/src/next/actor.rs @@ -96,7 +96,7 @@ impl ConnectionActor { code: Some(code), reason: Some(reason), }), - ConnectionCommand::Ping => Some(Message::Ping), + ConnectionCommand::Ping => Some(Message::graphql_ping()), } } diff --git a/src/next/connection.rs b/src/next/connection.rs index 7ce83ac..d46891d 100644 --- a/src/next/connection.rs +++ b/src/next/connection.rs @@ -59,6 +59,10 @@ impl Message { Self::Text(serde_json::to_string(&crate::protocol::Message::Pong::<()>).unwrap()) } + pub(crate) fn graphql_ping() -> Self { + Self::Text(serde_json::to_string(&crate::protocol::Message::Ping::<()>).unwrap()) + } + pub(crate) fn complete(id: usize) -> Self { Self::Text( serde_json::to_string(&crate::protocol::Message::Complete::<()> { id: id.to_string() }) diff --git a/src/protocol.rs b/src/protocol.rs index 8f7fe9d..4ae5865 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -39,6 +39,8 @@ pub enum Message<'a, Operation> { Subscribe { id: String, payload: &'a Operation }, #[serde(rename = "complete")] Complete { id: String }, + #[serde(rename = "ping")] + Ping, #[serde(rename = "pong")] Pong, }