3.1.7 • Published 2 years ago

@t.voslar/apollo-link-queue v3.1.7

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

apollo-link-queue

npm version Build Status codecov

An Apollo Link that acts as a gate and queues requests when the gate is closed. This can be used when there is no internet connection or when the user has explicitly set an app to offline mode.

On top of original library added storage, which stores queue when app is closed.

Installation

npm install @t.voslar/apollo-link-queue

or

yarn add @t.voslar/apollo-link-queue

Usage

import QueueLink from 'apollo-link-queue';

const queueLink = new QueueLink();

// To start queueing requests
queueLink.close();

// To let requests pass (and execute all queued requests)
queueLink.open();

Offline mode example with queueing and retry

import { ApolloLink } from 'apollo-link';
import { HttpLink } from 'apollo-link-http';
import { RetryLink } from 'apollo-link-retry';

import QueueLink from 'apollo-link-queue';

const offlineLink = new QueueLink();

this.link = ApolloLink.from([
    new RetryLink(),
    offlineLink,
    new HttpLink({ uri: URI_TO_YOUR_GRAPHQL_SERVER }),
]);

const client = new ApolloClient...

offlineLink.setApolloClient(client);
3.1.7

2 years ago

3.1.6

2 years ago

3.1.5

3 years ago

3.1.4

3 years ago

3.1.3

3 years ago

3.1.2

3 years ago

3.1.1

3 years ago

3.1.0

3 years ago