Registry / storage / apollo-link-queue-persist

apollo-link-queue-persist

JSON →
library0.0.23jsnpmunverified

Apollo Client persistence library for queued GraphQL mutations and queries using apollo-link-queue. Current version 0.0.23, actively maintained fork of the original SocialAutoTransport package. Provides automatic restore and persistence of queued requests via AsyncStorage, localStorage, or custom wrappers. Includes beforeRestore, onCompleted, and onError hooks. Supports web and React Native. Key differentiator: integrates with apollo-link-queue to handle offline mutations and retry them when online. Requires @apollo/client ^3.2.5.

npm install apollo-link-queue-persist
INSTALL
IMPORT
SIG · APOLLO-LINK-QUEUE-
A
apollo-link-queue-persist
storagejavascriptv0.0.23
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.

persistQueue
import { persistQueue } from 'apollo-link-queue-persist'
const persistQueue = require('apollo-link-queue-persist')
ESM-only package; CommonJS require will fail
AsyncStorageWrapper
import { AsyncStorageWrapper } from 'apollo-link-queue-persist'
Used for React Native AsyncStorage; also exports LocalStorageWrapper and custom Wrapper
Wrapper
import { Wrapper } from 'apollo-link-queue-persist'
Class to implement custom storage wrappers

Initializes QueueLink with Apollo Client and persists queued mutations to AsyncStorage.

import AsyncStorage from '@react-native-async-storage/async-storage'; import { persistQueue } from 'apollo-link-queue-persist'; import QueueLink from 'apollo-link-queue'; import { ApolloClient, InMemoryCache, HttpLink, ApolloLink } from '@apollo/client'; const queueLink = new QueueLink(); const client = new ApolloClient({ link: ApolloLink.from([queueLink, new HttpLink({ uri: 'https://api.example.com/graphql' })]), cache: new InMemoryCache(), }); await persistQueue({ queueLink, storage: AsyncStorage, client, onCompleted: (request, response) => { console.log('Request completed:', request.operationName); }, onError: (request, error) => { console.error('Request failed:', request.operationName, error); }, });
Debug
Known issues
gotchaThe queueLink must be created before the ApolloClient and passed to persistQueue exactly once.
fix
Create a single QueueLink instance and reuse it for both client construction and persistQueue.
affects: >=0.0.1
gotchaAsyncStorage is not included; you must install @react-native-async-storage/async-storage separately.
fix
npm install @react-native-async-storage/async-storage
affects: >=0.0.1
deprecatedThe original package @SocialAutoTransport/apollo-link-queue-persist is unmaintained. This fork (Asolvi) is the active version.
fix
Use apollo-link-queue-persist (published by Asolvi) instead of @SocialAutoTransport/apollo-link-queue-persist.
affects: >=0.0.1
gotchaStorage wrapper must be either AsyncStorageWrapper, LocalStorageWrapper, or a custom Wrapper implementation. Passing raw storage will fail.
fix
Wrap storage: import { AsyncStorageWrapper } from 'apollo-link-queue-persist' and pass new AsyncStorageWrapper(AsyncStorage) or use the storage directly if supported.
affects: >=0.0.1
breakingVersion 0.0.23 removed the need for separate QueueLink from apollo-link-queue; now bundles its own queue implementation.
fix
Ensure you are using version 0.0.23 or later. Older versions required @SocialAutoTransport/apollo-link-queue.
affects: 0.0.23
gotchaThe persistQueue function is async and must be awaited. Do not call it synchronously.
fix
Use await persistQueue(...) or .then() to ensure restoration completes.
affects: >=0.0.1
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'mutate')
ApolloClient instance not passed or passed before mutation handler is attached.
fix
Ensure client is passed to persistQueue and that the ApolloClient has a link that includes the queueLink.
Module not found: Can't resolve 'apollo-link-queue'
Missing apollo-link-queue peer dependency.
fix
Install apollo-link-queue: npm install apollo-link-queue
Invalid storage provider. Must be a Wrapper instance or one of AsyncStorageWrapper/LocalStorageWrapper.
Passed raw AsyncStorage object without wrapping.
fix
Use new AsyncStorageWrapper(AsyncStorage) or import the wrapper from the package.
Error: Cannot find module '@react-native-async-storage/async-storage'
React Native AsyncStorage not installed.
fix
Install: npm install @react-native-async-storage/async-storage
queueLink is required
Missing queueLink option in persistQueue call.
fix
Pass a QueueLink instance: persistQueue({ queueLink: new QueueLink(), ... })
Upgrade
Version history
0.0.23latest on npm
Audit
Dependencies
@apollo/clientrequiredPeer dependency for Apollo Client types and client.mutate/query
apollo-link-queuerequiredRequired to create QueueLink instance passed to persistQueue
Agent activity
43 hits · last 30 days
node
38
OpenAI (training)
2
Resources