Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

ApolloLink.from doesn't work with custom links #133

Closed
jchavarri opened this issue Oct 6, 2017 · 2 comments
Closed

ApolloLink.from doesn't work with custom links #133

jchavarri opened this issue Oct 6, 2017 · 2 comments

Comments

@jchavarri
Copy link

jchavarri commented Oct 6, 2017

In 0.7.0, when using ApolloLink.from with a custom made link, the (operation, forward) => ... callback is not called.

Intended outcome:
After reading the docs:

from is typically used when you have many links to join together all at once. The alternative way to join links is the concat method which joins two links together into one.

I was expecting I could implement my own authLink and the operations could be forwarded like with concat.

Actual outcome:
The custom link forwarding callback is never called.

How to reproduce the issue:
Create a custom link and then join it with an Apollo Link using from:

import { HttpLink } from 'apollo-link-http';
...
const logLink = new ApolloLink((operation, forward) => {
  return forward(operation).map((data) => {
    console.log('logging');
    return forward(operation);
  })
});
const link = ApolloLink.from([
   new HttpLink({ uri }),
   logLink,
]);
const client = new ApolloClient({
  cache: new InMemoryCache()
  link,
});
// `logging` will never be printed
@jchavarri
Copy link
Author

Hm, my bad, seems logLink has to go first :)

@jonasdumas
Copy link

Thanks, it solve 2 hours of debbuging !
The httplink need to go at the end when use from()
HM!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants