Registry / storage / apollo-link-queue

apollo-link-queue

JSON →
library3.1.0jsnpmunverified

An Apollo Link that queues GraphQL requests when a condition is met, such as offline mode, and replays them when reconnected. Version 3.1.0 is the current stable release, last updated in 2019. Key differentiator: integrates with Apollo Link chain to buffer requests without custom middleware. Compared to alternatives like apollo-link-retry, it focuses on queueing rather than retrying failed requests.

npm install apollo-link-queue
INSTALL
IMPORT
SIG · APOLLO-LINK-QUEUE
A
apollo-link-queue
storagejavascriptv3.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

QueueLink
import QueueLink from 'apollo-link-queue'
import { QueueLink } from 'apollo-link-queue'
Default export. Named export is not available.
QueueLink (type)
import type QueueLink from 'apollo-link-queue'
import QueueLink from 'apollo-link-queue'
For TypeScript type-only import, use 'import type' if you only need the type.
CommonJS require
const QueueLink = require('apollo-link-queue').default
const QueueLink = require('apollo-link-queue')
With require(), you need .default because it's an ES module default export transpiled to CommonJS.

Shows how to instantiate QueueLink, open/close the gate, and integrate with Apollo Link chain for offline queueing.

import QueueLink from 'apollo-link-queue'; import { ApolloLink } from 'apollo-link'; import { HttpLink } from 'apollo-link-http'; const queueLink = new QueueLink(); // Close the gate to start queuing requests queueLink.close(); // When ready to send queued requests queueLink.open(); // For offline support window.addEventListener('offline', () => queueLink.close()); window.addEventListener('online', () => queueLink.open()); const link = ApolloLink.from([ queueLink, new HttpLink({ uri: '/graphql' }) ]);
Debug
Known issues
breakingQueueLink no longer exports `QueueLink` as a named export; use default import only.
fix
Use `import QueueLink from 'apollo-link-queue'` instead of `import { QueueLink } from 'apollo-link-queue'`.
affects: >=2.0.0
deprecatedThe package has been deprecated in favor of apollo-cache-persist or apollo-link-retry for most use cases.
fix
Consider migrating to apollo-link-retry for retry logic or apollo-cache-persist for offline persistence.
affects: >=3.0.0
gotchaQueueLink does not automatically detect online/offline events; you must add event listeners manually.
fix
Add window.addEventListener('offline', () => queueLink.close()) and window.addEventListener('online', () => queueLink.open()).
affects: >=1.0.0
gotchaQueued requests are lost if the page is refreshed unless you persist them externally.
fix
Use a persistence library like apollo-cache-persist to save queued operations before page unload.
affects: >=1.0.0
breakingIn version 3.0.0, the constructor options changed: `closeOn` and `openOn` callbacks were removed.
fix
Use `queueLink.close()` and `queueLink.open()` directly instead of passing callbacks to constructor.
affects: >=3.0.0
Errors
Common errors & fixes
Uncaught TypeError: QueueLink is not a constructor
Named import instead of default import, e.g., `import { QueueLink } from 'apollo-link-queue'`.
fix
Change to default import: `import QueueLink from 'apollo-link-queue'`.
Module not found: Error: Can't resolve 'apollo-link-queue'
Missing npm installation or incorrect package name.
fix
Run `npm install apollo-link-queue` or check package.json for the correct dependency name.
TypeError: queueLink.close is not a function
The link is not properly instantiated or the package version is outdated (< 2.0.0).
fix
Ensure you are using `new QueueLink()` and upgrade to version 3.x.
Warning: This link expects at least 1 inbound chain; it will be a no-op if called with 0
QueueLink is placed at the end of the link chain without a following link (e.g., HttpLink).
fix
Add an HttpLink or another terminating link after QueueLink in the chain.
Upgrade
Version history
3.1.0latest on npm
Audit
Dependencies
apollo-linkrequiredpeer dependency required for constructing link chains
Agent activity
38 hits · last 30 days
node
32
OpenAI (training)
1
Resources
apollo-link-queue — npm install apollo-link-queue · libregistry