JSPM

  • Created
  • Published
  • Downloads 78449
  • Score
    100M100P100Q154126F
  • License MIT

WebSocket transport layer for GraphQL

Package Exports

  • apollo-link-ws

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (apollo-link-ws) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme


Purpose

An Apollo Link to allow sending a request over a web socket.

Installation

npm install apollo-link-ws --save

Usage

import { WebSocketLink } from "apollo-link-ws";
import { SubscriptionClient } from 'subscriptions-transport-ws';

const GRAPHQL_ENDPOINT = 'ws://localhost:3000/graphql';

const client = new SubscriptionClient(GRAPHQL_ENDPOINT, {
  reconnect: true,
});

const link = new WebSocketLink(client);

Options

WS Link takes either a subscription client or an object with three options on it to customize the behavior of the link. Takes the following possible keys in the configuration object:

  • uri: a string endpoint to connect to
  • options: a set of options to pass to a new Subscription Client
  • webSocketImpl: a custom WebSocket implementation

By default, this link uses the subscriptions-transport-ws library for the transport.

Context

The WS Link does not use any keys on the context.