@adobe/apollo-link-mutation-queue
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

apollo-link-mutation-queue

An Apollo link that enqueues mutations so that they do not fire in parallel.

Goals

I was finding that mutations affecting the same underlying data would often return incorrect data if fired in parallel. Instead of blocking UI based on the loading state of the mutations I wrote a link that just enqueues mutations.

Usage

Compose your link chain with the link.

import MutationQueueLink from "apollo-link-mutation-queue";

const link = ApolloLink.from([
  new MutationQueueLink(),
  //... your other links
]);

Debug with debug: true.

import MutationQueueLink from "apollo-link-mutation-queue";

const link = ApolloLink.from([
  new MutationQueueLink({ debug: true }),
  //... your other links
]);

Cut in line with skipQueue: true.

const [mutate] = useMutation(MY_MUTATION);

useEffect(() => {
  mutate({
    context: { skipQueue: true },
  });
}, []);

Contributing

Contributions are welcomed! Read the Contributing Guide for more information.

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.

Note

The upgrade to @apollo/client requires react and react-refresh as dependencies.

Package Sidebar

Install

npm i @adobe/apollo-link-mutation-queue

Weekly Downloads

2,517

Version

1.1.0

License

Apache-2.0

Unpacked Size

28.1 kB

Total Files

12

Last publish

Collaborators

  • dylandepass
  • djaeggi
  • adobehalls
  • fullcolorcoder
  • marbec
  • tripod
  • garthdb
  • lazd
  • adobe-admin
  • patrickfulton
  • trieloff
  • shazron
  • krisnye
  • dcpfsdk
  • natebaldwin
  • devongovett
  • aspro83
  • symanovi
  • dpfister
  • stefan-guggisberg
  • korra
  • rofe
  • kptdobe