Universal heartbeat/ping-pong support
Describe the feature
esclating from https://github.com/enisdenjo/graphql-ws/pull/630#issuecomment-2859184545 (/cc @enisdenjo @m1212e)
Spec: https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers#pings_and_pongs_the_heartbeat_of_websockets
(TODO: need to do some research about runtime-specific impl)
Additional information
- [ ] Would you be willing to help implement this feature?
Just some small info on my side: it's always the server doing the pinging because native WebSocket clients (like the ones in the browser), don't have the imperative "ping" methods to ping the server (even though pinging is bidirectional). From what I've seen implementing adapters in graphql-ws, you pretty much always have to manually implement the ping/pong mechanism on the server side, yet the API is quite often unchanged: ws.ping() to issue and socket.on('pong', () => {}) to recieve.