0.0.1 • Published 4 years ago

benzene-ws-client v0.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

benzene-ws-client

Super ligt

This package is only experimental and not tested.

Only works with @benzene/ws for now.

Install

yarn add benzene-ws-client

Usage

import { SubscriptionClient } from 'benzene-ws-client';

const subscriptionClient = new SubscriptionClient('wss://localhost/graphql', options);

urql

import { Client, defaultExchanges, subscriptionExchange } from 'urql';

const client = new Client({
  url: '/graphql',
  exchanges: [
    ...defaultExchanges,
    subscriptionExchange({
      forwardSubscription(operation) {
        return subscriptionClient.request(operation);
      },
    }),
  ],
});

@apollo/client

import { WebSocketLink } from "@apollo/client/link/ws";

const link = new WebSocketLink(subscriptionClient);

Options

optiondescriptiondefault
reconnectionAttemptsNumber of attempts to try reconnect on disconnection. Set to 0 to disable0 (disabled)
genIdA function to generate unique subscription ids. Default to incremental ids.undefined