Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit to mutations only #13

Closed
aavelyn opened this issue Sep 6, 2018 · 4 comments
Closed

Limit to mutations only #13

aavelyn opened this issue Sep 6, 2018 · 4 comments

Comments

@aavelyn
Copy link

aavelyn commented Sep 6, 2018

Is is possible to queue only muatations and not queries?

@pl12133
Copy link

pl12133 commented Sep 11, 2018

I think you can write a wrapper that only calls the queue link for mutations:

import { ApolloLink } from 'apollo-link';

function isMutationOperation(operation) {
    return operation.query.definitions.filter((e) => e.operation === 'mutation').length > 0;
}

const queueLink = new QueueLink();

const onlyQueueMutationsLink = new ApolloLink((operation, forward) =>
  isMutationOperation(operation) ? queueLink.request(operation, forward) : forward(operation)
);

@wtrocki
Copy link
Contributor

wtrocki commented Oct 19, 2018

I'm happy to write this along with #3.

Idea will be to be able to pass filter and storage interface to queue.

const queueLink = new QueueLink({store,filter});

@wtrocki
Copy link
Contributor

wtrocki commented Oct 21, 2018

Done in: #14

@helfer
Copy link
Owner

helfer commented Dec 7, 2018

Thanks for the effort @wtrocki. I like to keep things as simple as possible and separate concerns, so I would recommend using @pl12133 's approach here. The philosophy of apollo link is like the Unix philosophy where each utility is small and limited in scope but input and output can be piped. More complex things can then be done by combining simple links together.

@helfer helfer closed this as completed Dec 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants