AsyncAPI definition for Hasura GraphQL Engine real-time subscriptions delivered over WebSocket at the `/v1/graphql` endpoint. Hasura supports two WebSocket subprotocols, negotiated via the `Sec-WebSocket-Protocol` HTTP header during the WebSocket handshake: * `graphql-transport-ws` — the modern protocol implemented by the [graphql-ws](https://github.com/enisdenjo/graphql-ws) library. * `graphql-ws` — the legacy protocol implemented by the [subscriptions-transport-ws](https://github.com/apollographql/subscriptions-transport-ws) library (kept for backwards compatibility with Apollo clients). Both protocols share a JSON envelope, but message `type` values, the subscription start/stop semantics, and the keep-alive mechanism differ. Authentication is performed either via the `connection_init` `payload` (where Hasura accepts headers such as `Authorization`, `x-hasura-admin-secret`, and any `x-hasura-*` session variables), or via query-string parameters on the WebSocket URL.
Single WebSocket channel used for all Hasura GraphQL subscription, query, and mutation traffic. The channel multiplexes any number of concurrent operations identified by a client-generated `id`.
Messages
✉
ConnectionInit
connection_init
Client → Server. First message sent after the WebSocket is open. Optionally carries a payload with auth headers and connection parameters that Hasura forwards to its auth layer.
✉
ConnectionAck
connection_ack
Server → Client. Sent after Hasura accepts the connection and the auth handshake completes.
✉
PingClient
ping (client)
Client → Server. Optional keep-alive / latency probe. The peer MUST respond with a `pong`. May also be sent unsolicited as a heartbeat.
✉
PingServer
ping (server)
Server → Client. Optional keep-alive / latency probe. The peer MUST respond with a `pong`. May also be sent unsolicited as a heartbeat.
✉
PongClient
pong (client)
Client → Server. Response to a `ping`. May also be sent unsolicited as a unidirectional heartbeat.
✉
PongServer
pong (server)
Server → Client. Response to a `ping`. May also be sent unsolicited as a unidirectional heartbeat.
✉
Subscribe
subscribe
Client → Server. Requests execution of a GraphQL operation (query, mutation, or subscription). The `id` MUST be unique across the WebSocket session; Hasura streams results back tagged with the same `id`.
✉
Next
next
Server → Client. Carries a single GraphQL execution result for the operation identified by `id`.
✉
Error
error
Server → Client. Communicates one or more GraphQL errors that occurred before execution started (validation or operation errors). Terminates the operation; no further messages with this `id` will be sent.
✉
CompleteClient
complete (client)
Client → Server. Signals that the client wishes to stop the operation identified by `id`. Used to unsubscribe.
✉
CompleteServer
complete (server)
Server → Client. Indicates the operation identified by `id` has completed and no further results will be sent.
✉
LegacyConnectionInit
connection_init (legacy)
Client → Server. First legacy-protocol message. The payload carries `connectionParams` (auth headers / session variables).
✉
LegacyConnectionAck
connection_ack (legacy)
Server → Client. Acknowledges a successful connection.
✉
LegacyConnectionError
connection_error (legacy)
Server → Client. Sent when Hasura rejects the connection (auth failure, parsing error, etc.). The connection will be closed.
✉
LegacyKeepAlive
ka (legacy)
Server → Client. Periodic keep-alive frame sent after `connection_ack` to keep the WebSocket from idling out.
✉
LegacyConnectionTerminate
connection_terminate (legacy)
Client → Server. Asks Hasura to close the connection.
✉
LegacyStart
start (legacy)
Client → Server. Starts a GraphQL operation identified by a unique `id`.
✉
LegacyData
data (legacy)
Server → Client. Carries a GraphQL execution result for the operation identified by `id`.
✉
LegacyError
error (legacy)
Server → Client. Indicates the operation identified by `id` failed before execution.
✉
LegacyComplete
complete (legacy)
Server → Client. Indicates the operation identified by `id` has completed.
✉
LegacyStop
stop (legacy)
Client → Server. Stops the running operation identified by `id` (unsubscribe).
Servers
wss
cloudwss://{project}.hasura.app/v1/graphql
Hasura Cloud project WebSocket endpoint for GraphQL subscriptions. Replace `{project}` with your Hasura Cloud project subdomain.