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

Improve examples using Async::HTTP and Falcon #2

Closed
21 tasks done
trevorturk opened this issue Feb 24, 2021 · 7 comments
Closed
21 tasks done

Improve examples using Async::HTTP and Falcon #2

trevorturk opened this issue Feb 24, 2021 · 7 comments

Comments

@trevorturk
Copy link
Collaborator

trevorturk commented Feb 24, 2021

Issues hit when upgrading my existing Rails app:

Need examples and/or documentation for the proof of concept sample apps in this repo:

Feature requests:

For the examples/documentation issues, I'd like to work in the open and/or contribute back to the relevant projects' documentation wherever possible. I'm finding the async suite of tools to be lovely, but the documentation sparse, and I'm hoping to contribute back in an effort to increase adoption.

For the issues found while upgrading my existing Rails app, I'll need to keep that source code private, but happy to work in the open wherever possible, as illustrated by the VCR cassette issue: socketry/protocol-http1#11 since obviously most of these concerns can be generalized.

@trevorturk trevorturk changed the title Todo Improve examples using async-http and falcon Feb 25, 2021
@josh
Copy link

josh commented Mar 8, 2021

Other approaches more than welcome, favorite so far is rails-async-http-falcon-graphql-batch

Another idea is to return Async::Task objects from resolvers. Then register that class with the GraphQL::Schema.

class Schema < GraphQL::Schema
  query Query
  lazy_resolve Async::Task, :wait
end

Resolver methods can now just return an Async::Task:

def one
  Async {
    response = internet.get("https://httpbin.org/delay/1").read
    JSON.parse(response)["url"]
  }
end

You could probably take things further by injecting something that wraps all resolvers with Async {} to remove that step.

This approach may mean you can avoid the graphql-batch dependency all together.

@trevorturk
Copy link
Collaborator Author

Thanks for the note, @josh -- I'll try to work up an example app using this style for reference today and report back.

I'm also trying working up an example suggested by @ioquatix #3 using async-await but I ran into some trouble there. I'm sure I'm just misunderstanding how this all works, but perhaps this can be a good strategy to avoid graphql batch loaders, which really shouldn't be necessary in my app's use case. (Still, I think the more examples we can provide people the better.)

@trevorturk
Copy link
Collaborator Author

@josh see #4 for my attempt to implement your suggestion. The second commit doesn't work, but I'm not understanding why, but I think this seems like a good approach to avoid the batch loader which isn't really necessary in this use case with the Async::HTTP stuff.

@ioquatix
Copy link
Member

How to enable Accept-Encoding: gzip #7 (?) multiple headers?

We have discussed this and I think this is appropriate for default inclusion into Async::HTTP::Internet. See socketry/async-http#68

@ioquatix
Copy link
Member

We also discussed improving this: socketry/async-http#67

@trevorturk trevorturk changed the title Improve examples using async-http and falcon Improve examples using Async::HTTP and Falcon Apr 23, 2021
@ioquatix
Copy link
Member

Investigate rack-async-http-falcon-graphql-dataloader (should work in Ruby 3.1?)

Investigate how the fiber interface is supposed to be used.

@trevorturk
Copy link
Collaborator Author

I think we covered everything! I have some notes to follow up with docs re preloading and Heroku falcon.rb config once I sort those things out for myself. Thank you again for all of your help so far!

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