This package is only experimental and not tested. Only works with
@benzene/ws
for now.
The tiny client for the modified GraphQL over WebSocket Protocol.
yarn add benzene-ws-client
import { SubscriptionClient } from 'benzene-ws-client';
const subscriptionClient = new SubscriptionClient('wss://localhost/graphql', options);
import { Client, defaultExchanges, subscriptionExchange } from 'urql';
const client = new Client({
url: '/graphql',
exchanges: [
...defaultExchanges,
subscriptionExchange({
forwardSubscription(operation) {
return subscriptionClient.request(operation);
},
}),
],
});
import { WebSocketLink } from "@apollo/client/link/ws";
const link = new WebSocketLink(subscriptionClient);
option | description | default |
---|---|---|
reconnectionAttempts | Number of attempts to try reconnect on disconnection. | 0 (disabled) |
genId | A function to generate unique subscription ids. Default to incremental ids. | undefined |