GraphQL Subscriptions in GQless.
@gqless/subscriptions into your project's dependencies:
If you activated
subscriptions in the CLI Configuration you should have something like this in your generated client file:
It basically enables subscriptions only on client side, in case you are using SSR.
It's important to note that
wsEndpoint can be a
function that returns a
string or and an
async function that returns a
subscriptionsClient returns a helper in where you can set the connection parameters for the websocket connection, normally used for
The second parameter is an optional boolean flag that automatically will reset the websocket connection if it's already connected.
By default the subscriptions client uses a
lazy behavior, which means that it will create the connection only when you actually make a subscription, and disconnect after a couple seconds on last unsubscribe.
|reconnect||Should the websocket connection try to reconnect|
|maxReconnectAttempts||Amount of reconnection attempts|
|connectionCallback||Callback after successful connection|
|failedConnectionCallback||Callback after failed connection|
|failedReconnectCallback||Callback after last reconnection attempt failed|
|connectionInitPayload||Connection init payload, or async function to get the init payload before connection, overridable with setConnectionParams|
|headers||Might not be actually supported by browsers, use connection params. Headers to be set on websocket connection|
|lazy||See Lazy behavior|