Skip to content

hoangvvo/benzene-ws-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

benzene-ws-client

npm minizipped

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.

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

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

About

Tiny WebSocket client for GraphQL over WebSocket Protocol

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published