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

Question: ApolloLink for remote schemas with cache? #42

Closed
vladar opened this issue Mar 2, 2020 · 8 comments
Closed

Question: ApolloLink for remote schemas with cache? #42

vladar opened this issue Mar 2, 2020 · 8 comments

Comments

@vladar
Copy link

vladar commented Mar 2, 2020

Hey @yaacovCR

First of all, thanks for your fantastic work on graphql-tools-fork! This is truly impressive.

We are going to implement some sort of caching / query batching for gatsby-source-graphql. Before jumping into custom implementation I decided to ask you - maybe you already did something like Apollo Http Link for remote schemas but with cache?

Or maybe it is a straight stupid idea?

I'll appreciate any thoughts/advice. Thanks!

@yaacovCR
Copy link
Owner

yaacovCR commented Mar 2, 2020

Sounds like a great idea to me.

You could simply use https://github.com/prisma-labs/http-link-dataloader

I think that might work great for your use case.

Or you could use Apollo client, fleshed out a bit in my separate apollo-stitcher library. https://yaacovcr.github.io/apollo-stitcher/module-apollo-stitcher.ApolloClientLink.html

But you will see that code is simple, you can roll your own wrapper in a heartbeat.

@yaacovCR
Copy link
Owner

yaacovCR commented Mar 2, 2020

See this discussion here if remote schema supports cacheControl headers:

ardatan#890 (comment)

@yaacovCR
Copy link
Owner

yaacovCR commented Mar 2, 2020

The basic upshot of that is that you need a node fetch polyfill that supports caching like make-fetch-happen

@yaacovCR
Copy link
Owner

yaacovCR commented Mar 2, 2020

@vladar let me know if I can be of any more help, closing for now.

@yaacovCR yaacovCR closed this as completed Mar 2, 2020
@yaacovCR yaacovCR reopened this Mar 2, 2020
@yaacovCR
Copy link
Owner

yaacovCR commented Mar 2, 2020

Ah! I guess you may be talking about cache between runs? So you have to preserve cache to file? Then HttpDataLoader won't work, but Apollo client might be able to persist cache to file?

@yaacovCR
Copy link
Owner

yaacovCR commented Mar 2, 2020

https://github.com/apollographql/apollo-cache-persist/blob/master/README.md

Looks like they don't support persisting to files, but avenue to that might be above package.

@vladar
Copy link
Author

vladar commented Mar 3, 2020

Wow, thanks a ton for those links!

We probably need both - query batching and caching between runs. But the first step would be to try http-link-dataloader.

Thanks again 👍

@vladar vladar closed this as completed Mar 3, 2020
@yaacovCR
Copy link
Owner

yaacovCR commented Mar 3, 2020

@vladar, another option: urql, undocumented, but example available:

https://github.com/FormidableLabs/urql/tree/master/exchanges/graphcache/examples/persisted-store

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