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

Architecture using timeouts to call fetch? #14

Open
BrendanBall opened this issue Oct 25, 2018 · 3 comments
Open

Architecture using timeouts to call fetch? #14

BrendanBall opened this issue Oct 25, 2018 · 3 comments

Comments

@BrendanBall
Copy link

I've so far been using graphql in node and have used the facebook dataloader quite a bit. I have some go services that I want to add a graphql api to. Gqlgen seems quite legit and I've read good things about it so far. However the way this dataloader works doesn't feel right. The facebook dataloader in js doesn't have such a weird implementation where you have to wait an arbitrary amount of time to resolve the data. Did you have trouble finding a solution in go that doesn't involve timeouts to know when to resolve the data? I would like to explore this a bit as it's currently preventing me from deciding to use this library. Can you maybe give some info on what you tried and how you decided that timeouts is the best solution? I think it would be good to include this in the readme, as I'm sure I'm not the only one that has concerns about this.

@vektah
Copy link
Owner

vektah commented Nov 5, 2018

IIRC the facebook implementation batches together everything on the same "tick", golang doesn't have ticks. The timeout gives you the freedom to tweak how long you want to wait for a batch.

Now we could kind of simulate a tick in gqlgen right after starting all the concurrent resolvers (and maybe a gosched to make sure they have a chance to run). Given dataloaders are usually in context, this probably needs some smart context magic, and ideally can be done in a way that doesn't tie gqlgen directly to dataloaden and allows other libraries to receive that "resolvers issued" tick, if they want it.

In practice short timeouts (~1ms) work well enough and there are bigger fish to fry, but if someone wants to spec it out properly, and open to a PR that would be awesome :)

@lubo
Copy link

lubo commented Jan 15, 2019

We're currently looking for a better implementation that doesn't depend on timeouts. @vektah Any specific ideas how to implement it? Short timeouts don't work well for us :/

CC @mskrip

@vektah
Copy link
Owner

vektah commented Jan 30, 2019

related 99designs/gqlgen#518 (comment)

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

3 participants