0.0.19 • Published 2 years ago

@graphql-sse/apollo-client v0.0.19

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

@graphql-sse/apollo-client

A client for GraphQL subscription using Server Sent Events.

Installation

npm install @graphql-sse/apollo-client

Usage

Basic Example

The snippet below is from the Example React App where you have a full working example App.

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(),
});
0.0.19

2 years ago

0.0.17

3 years ago

0.0.18

3 years ago

0.0.16

3 years ago

0.0.11

3 years ago

0.0.9

3 years ago

0.0.6

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago