Skip to content
This repository has been archived by the owner on Jan 27, 2022. It is now read-only.

Possible to combine with apollo-link-batch-http? #8

Closed
kamsar opened this issue Dec 27, 2017 · 3 comments
Closed

Possible to combine with apollo-link-batch-http? #8

kamsar opened this issue Dec 27, 2017 · 3 comments

Comments

@kamsar
Copy link

kamsar commented Dec 27, 2017

Is there a way to combine automatic persisted queries with a batched link? Guessing not yet, at least it didn't work if I replaced the concat to the HTTP link with a batched instance, but thought I'd ask.

Great idea, really reduces bandwidth :)

Edit: to be more detailed, this is how I tried to combine them:

import { BatchHttpLink } from 'apollo-link-batch-http';
import { createPersistedQueryLink } from 'apollo-link-persisted-queries';

const http = new BatchHttpLink({ uri: httpEndpointUrl });
const persistHttp = createPersistedQueryLink().concat(http);

It does send the queries, but the negotiation of hashes doesn't happen so there is no bandwidth savings. The batch elements have both the complete query text as well as the hash extension added to them.

@wmertens
Copy link

I wonder if apollographql/apollo-link#364 will make it work with batching. I'm going to guess "no" :)

@kamsar
Copy link
Author

kamsar commented Jan 24, 2018

@wmertens I suspect that it will, because on further reflection I think the reason it doesn't work with BatchHttpLink today is that it is using apollo-fetch which may have a different internal API (speculating here) than the plain old HTTP link. It definitely works a lot different if you want to pass credentials with requests.

@kamsar
Copy link
Author

kamsar commented Mar 29, 2018

As of apollo-link-batch-http 1.2, this now just works, because apollo-fetch is no longer a dependency of the batcher. Thanks @evans :)

@kamsar kamsar closed this as completed Mar 29, 2018
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