# @graphql-sse/apollo-client

> Apollo Client link for Subscriptions over SSE

Latest version **0.0.19** (published 2022-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @graphql-sse/apollo-client
pnpm add @graphql-sse/apollo-client
yarn add @graphql-sse/apollo-client
bun add @graphql-sse/apollo-client
```

## Health

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

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

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.19 |
| Published | 2022-11-07 |
| First published | 2021-09-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 9.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | faboulaws |
| Keywords | Graphql Subscription, Apollo CLient, Server Sent Event |

## Links

- npm: https://www.npmjs.com/package/@graphql-sse/apollo-client
- npm.io page: https://npm.io/package/@graphql-sse/apollo-client

## Dependencies (2)

- [graphql](https://npm.io/package/graphql.md) ^15.5.3
- [@graphql-sse/client](https://npm.io/package/@graphql-sse/client.md) ^0.0.16

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 0.0.19 (latest) — 2022-11-07
- 0.0.18 — 2021-10-10
- 0.0.17 — 2021-10-10
- 0.0.16 — 2021-09-22
- 0.0.11 — 2021-09-22
- 0.0.9 — 2021-09-22
- 0.0.6 — 2021-09-21
- 0.0.2 — 2021-09-21
- 0.0.1 — 2021-09-21

## README

# @graphql-sse/apollo-client

A client for GraphQL subscription using Server Sent Events.

## Installation

```shell
npm install @graphql-sse/apollo-client
```

## Usage

### Basic Example

The snippet below is from the [Example React App](htts://github.com/faboulaws/grahql-sse/apps/react-app-example) where you have a full working example App.

```typescript
import { split, HttpLink, ApolloClient, InMemoryCache } from '@apollo/client';
import { getMainDefinition } from '@apollo/client/utilities';
import { ServerSentEventsLink } from '@graphql-sse/apollo-client';

const httpLink = new HttpLink({
  uri: 'http://localhost:4000/graphql',
});

const sseLink = new ServerSentEventsLink({
  graphQlSubscriptionUrl: 'http://localhost:4000/graphql',
});

const splitLink = split(
  ({ query }) => {
    const definition = getMainDefinition(query);
    return (
      definition.kind === 'OperationDefinition' &&
      definition.operation === 'subscription'
    );
  },
  sseLink,
  httpLink
);

export const client = new ApolloClient({
  link: splitLink,
  cache: new InMemoryCache(),
});

```

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