Name: apollo-link-queue
Owner: Spectrum
Description: A link to queue GraphQL requests when offline
Created: 2018-03-01 13:59:29.0
Updated: 2018-04-04 00:56:08.0
Pushed: 2018-03-02 08:00:52.0
Homepage: null
Size: 81
Language: TypeScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
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.
install apollo-link-queue
or
add apollo-link-queue
rt QueueLink from 'apollo-link-queue';
t queueLink = new QueueLink();
o start queueing requests
eLink.close();
o let requests pass (and execute all queued requests)
eLink.open();
rt { ApolloLink } from 'apollo-link';
rt { HttpLink } from 'apollo-link-http';
rt { RetryLink } from 'apollo-link-retry';
rt QueueLink from 'apollo-link-queue';
t offlineLink = new QueueLink();
ote: remove these listeners when your app is shut down to avoid leaking listeners.
ow.addEventListener('offline', () => offlineLink.close());
ow.addEventListener('online', () => offlineLink.open());
.link = ApolloLink.from([
new RetryLink(),
offlineLink,
new HttpLink({ uri: URI_TO_YOUR_GRAPHQL_SERVER }),