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
title: WebSocket Link
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 tooptions
: a set of options to pass to a new Subscription ClientwebSocketImpl
: 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.