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

How to use Dataloader with Apollo server ? #47

Closed
nghiepdev opened this issue Jul 11, 2016 · 3 comments
Closed

How to use Dataloader with Apollo server ? #47

nghiepdev opened this issue Jul 11, 2016 · 3 comments

Comments

@nghiepdev
Copy link

nghiepdev commented Jul 11, 2016

I see great https://youtu.be/UBGzsb2UkeY?t=24m45s use Dataloader.
How to use Dataloader with Apollo server? I'm using MongoDB.

Please give me an example.

Tks.

@nghiepdev nghiepdev changed the title How to use Dataloader with Apollo sever ? How to use Dataloader with Apollo server ? Jul 11, 2016
@nnance
Copy link
Contributor

nnance commented Jul 18, 2016

@tronghiep92 there are a couple of projects that are based on Apollo Server and uses Dataloader as well:

https://github.com/apollostack/GitHunt
https://github.com/nnance/swapi-apollo

Let me know you need a better example

@helfer
Copy link
Contributor

helfer commented Jul 27, 2016

@tronghiep92 please feel free to re-open the issue, or ask questions on the slack channel if you still need more info.

@helfer helfer closed this as completed Jul 27, 2016
@wmertens
Copy link
Contributor

@tronghiep92 So basically all you need to do is wrap your item loader with DataLoader and it will automatically group calls, batching them if possible: https://github.com/nnance/swapi-apollo/blob/5e2208db6cb3e91dbb7aa34b531454a57c6a973f/src/connectors/swapi.ts#L10-L16

However, these examples work with data that does not expire, and you may need to implement cache clearing. The documentation at https://github.com/facebook/dataloader/blob/master/README.md is good, I think.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
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

4 participants