Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

apollo-link-ws

apollographql337.6kMIT1.0.20TypeScript support: included

WebSocket transport layer for GraphQL

readme


title: apollo-link-ws

description: Send GraphQL operations over a WebSocket. Works with GraphQL Subscriptions.

This link is particularly useful to use GraphQL Subscriptions, but it will also allow you to send GraphQL queries and mutations over WebSockets as well.

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.

changelog

Change log


NOTE: This changelog is no longer maintained. Changes are now tracked in the top level CHANGELOG.md.


1.0.10

  • No changes

1.0.9

  • Added graphql 14 to peer and dev deps; Updated @types/graphql to 14
    @hwillson in #789

1.0.8

  • Update apollo-link #559

1.0.7

  • update apollo link with zen-observable-ts PR#515

1.0.6

  • ApolloLink upgrade

1.0.5

  • ApolloLink upgrade

1.0.4

  • ApolloLink upgrade

1.0.3

  • export options as named interface [TypeScript]

1.0.2

  • changed peer-dependency of apollo-link to actual dependency

1.0.1

  • moved to better rollup build

1.0.0

  • moved from default export to named to be consistent with rest of link ecosystem