# apollo-link-ws

> WebSocket transport layer for GraphQL

Latest version **1.0.20** (published 2020-04-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install apollo-link-ws
pnpm add apollo-link-ws
yarn add apollo-link-ws
bun add apollo-link-ws
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.20 |
| Published | 2020-04-09 |
| First published | 2017-08-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 17.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1423 |
| Author | Evans Hauser |
| Maintainers | apollo-bot, evanshauser, jbaxleyiii |

## Links

- npm: https://www.npmjs.com/package/apollo-link-ws
- Repository: https://github.com/apollographql/apollo-link
- Homepage: https://github.com/apollographql/apollo-link#readme
- Issues: https://github.com/apollographql/apollo-link/issues
- npm.io page: https://npm.io/package/apollo-link-ws

## Dependencies (2)

- [tslib](https://npm.io/package/tslib.md) ^1.9.3
- [apollo-link](https://npm.io/package/apollo-link.md) ^1.2.14

## Recent versions

- 1.0.20 (latest) — 2020-04-09
- 2.0.0-beta.0 (beta) — 2019-11-15
- 1.0.19 — 2019-09-06
- 1.0.18 — 2019-06-14
- 1.0.17 — 2019-03-14
- 1.0.16 — 2019-03-14
- 1.0.15 — 2019-03-05
- 1.0.14 — 2019-02-01
- 1.0.13 — 2019-02-01
- 1.0.12 — 2018-12-15
- 1.0.11 — 2018-12-13
- 1.0.10 — 2018-11-21
- 1.0.9 — 2018-09-15
- 1.0.8 — 2018-04-12
- 1.0.7 — 2018-02-23
- … 23 more at https://npm.io/package/apollo-link-ws/versions

## 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.

```js
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](https://github.com/apollographql/subscriptions-transport-ws) library for the transport.

---
_Source: https://npm.io/package/apollo-link-ws · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
