-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
mutations for afterware to support retrying requests #1274
Conversation
@tscanlin: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/ |
Hi @tscanlin 👋 I think this is a great way of handling this, as long as you don't somehow end up in a loop. Since the change to source code is very minimal, I'm more than happy to merge this. Thanks a lot for the PR! |
Sweet, thanks @helfer! Loving the Apollo project so far 👍 |
@tscanlin Do you just store |
@Multiply that is a really great question. :) In the file where I declare all the middleware and afterware I declared a But having this piece of external state is probably not the best solution. It would be better if the request got passed in to the afterware as well. @helfer would you accept a PR to pass the request in to the |
@tscanlin I tried the same, but since many requests could fire at the same time I eventually set However, I would be ALL for the proposed change, of having both the request and response as properties. |
That's a good point. Glad you thought of a solution that accounts for simultaneous requests. Thanks for sharing it. Is there any reason you couldn't just pass the whole request to the afterware via the options object? |
@tscanlin I guess that makes more sense, as I wouldn't have to maintain an object somewhere else in my authentication middleware, but I actually wanted a specific request id, so I could track it better when it went back and re-requested the resource. I guess I'll do both, until we have a better solution. I am still really liking the idea of having the |
Yeah, I'd still be up for making that change if they agree to it. I'm curious what you mean by "so I could track it better when it went back and re-requested the resource", what's your use case here? Maybe its something I haven't thought of yet. |
@tscanlin In dev-mode I track all incoming and outgoing requests, with a request and response id, and push that to Arangodb, both on the client and any of my several backends, and I then end up with a nice graph of the full session. In this case it'll also store a parent request ID, that is then marked with a 401, and I can then easily find all failing requests and see how they resolved. There's a lot of different use cases :) |
That's a very cool use case :) Arangodb looks pretty awesome. Are you using Apollo to query it? I can imagine it would really help to have the global map of requests like you say especially for debugging. Have you noticed any performance hits with having that giant map of requests? Or do you have caching / only use for dev? |
@tscanlin I am using arangojs, and then Apollo on top, yes. I am going to try do some 'smart' graph queries to optimize the performance of GraphQL overall. Fingers crossed, my prototype will work soon enough. I only use it for dev at the moment, but I have no problems with even millions of records. I've optimized my indexes a lot over the last few weeks, so that helps a lot. |
Touched on in #439.
This is an attempt at implementing a request retry when a request returns with a
401
.Changes in this PR plus the below afterware seem to work for our purposes.
Is this the best way to handle this? Or do you guys have something else in mind?
I mostly just wanted to share my approach here to get feedback and share in case anyone else is trying to solve the same problem.
TODO: