0.0.1 • Published 5 years ago

apollo-link-mutation-queue v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

apollo-link-mutation-queue

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

Why

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.

Use

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 }
  });
}, []);
0.0.1

5 years ago