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

ASGI support #215

Closed
florimondmanca opened this issue Apr 18, 2019 · 19 comments
Closed

ASGI support #215

florimondmanca opened this issue Apr 18, 2019 · 19 comments

Comments

@florimondmanca
Copy link
Contributor

florimondmanca commented Apr 18, 2019

Request a feature

Hi, I saw that Tartiflette supports HTTP as a transport layer via tartiflette-aiohttp. That's pretty cool, but I think there may be a better option to enable interoperability with other parts of the Python async web stack: ASGI.

It's the equivalent of WSGI for async: the de-facto standard interface between async web apps and async web servers (eg uvicorn). AFAIK, Tartiflette doesn't have support for ASGI yet.

I think providing an ASGI adapter for Tartiflette would foster interest in the project, as it would allow any web framework based on ASGI (i.e. all of them now) to mount a Tartiflette endpoint. The most popular option for now is Graphene, which Starlette provides an ASGI adapter for, but it is synchronous and thus insufficient.

To be honest, I am considering a potential integration with Bocadillo, an async web framework I am the maintainer of, but for now there doesn't seem to be a way to serve a Tartiflette GraphQL endpoint through ASGI.

I'm not that familiar with aiohttp, and perhaps it has a feature that would already enable this. If so, I'd be glad to read more!

P.S.: I'm not sure whether I should have opened this on tartiflette-aiohttp. If necessary I can transfer the issue!

@abusi
Copy link
Contributor

abusi commented Apr 19, 2019

We'll be very happy if you'll provide an integration of tartiflette in bocadillo.

Tartiflette, per se, doesn't care about the transport. Tartiflette-aiohttp is just an example of integration into a webserver.

You can use tartiflette anywhere you want.

We are also studying the creation of a tartiflette-starlette example.

Feel free to provide a bocadillo integration, we'll link it in the doc/readme when available.

@abusi
Copy link
Contributor

abusi commented Apr 19, 2019

What is blocking you from serving tartiflette executed graphql requests from bocadillo ?

@florimondmanca
Copy link
Contributor Author

Thanks for your answer!

What is blocking you from serving tartiflette executed graphql requests from bocadillo ?

To be honest, I haven’t digged into the problem just yet. :-) I thought that since Tartiflette had an aiohttp integration there was some kind of special/advanced work required to make it work in a web environment.

It’s good hearing that this should be easy enough. I’d love working on a Bocadillo integration, though I think the more sustainable/reusable approach would be to provide an ASGI adapter which Bocadillo and other frameworks can integrate in their own way later on.

I’ll have to dig into Tartiflette internals to see how this could work. :-)

@abusi
Copy link
Contributor

abusi commented Apr 19, 2019

Basicly tartiflette is a simple thing.
You initialize a tartiflette.engine with a sdl and a package list containing your resolvers, and then, on this engine instance you call the execute method with 'query, vars_val, operation_name, user_context).
Nothing links tartiflette to aoihttp, or even http, the only think requiered is async python ;).

@florimondmanca
Copy link
Contributor Author

Yes, sooo — I took inspiration from tartiflette-aiohttp and Starlette's GraphQL ASGI app, and… There it is! tartiflette-asgi 🎉

Feel free to take a look and share your thoughts! Still need to add tests and publish to PyPI, but it's working pretty smoothly already.

@abusi
Copy link
Contributor

abusi commented Apr 19, 2019

Very nice !! Since it's a starlette integration, can you name it tartiflette-starlette ?
But nonetheless this is pretty cool !
I'll look at it more closely next week.
Thanks again !

@florimondmanca
Copy link
Contributor Author

I’m not sure it should be named after Starlette, since in practice it can be plugged into any ASGI framework regardless of whether said framework uses Starlette itself.
But I can see why this would be clearer — it does depend on Starlette, and we inject the Starlette request and a background task factory into the GraphQL context. So I’m not against it! Will update the project name and description. :-)

@tsunammis
Copy link
Contributor

I think that it could be a good opportunity for your project (and us) to join the « tartiflette » organization on github.
To become an official implementation of tartiflette through asgi.

@florimondmanca what do you think ?

@florimondmanca
Copy link
Contributor Author

@tsunammis I think it makes sense from a maintenance and future-proofing perspective. To be honest I'm concerned with ownership over the project — will I remain one of the maintainers? Are there any rules/processes/standards/guidelines for repos under the dailymotion org?

@tsunammis
Copy link
Contributor

@florimondmanca We created a new organization called tartiflette, which not belongs to the dailymotion one. The idea is to officially host and support some projects from the community, like yours. You will keep the ownership over the project, obviously, we will work closely to bring a consistent and good developer experience over all the tartiflette projects.

@florimondmanca
Copy link
Contributor Author

Brilliant! Very good idea to create a separate organization to help Tartiflette stand on its own feet.

I can initiate the repo transfer. I read in Transferring a repository that you'll receive an email to accept the transfer, then I'll be added as a collaborator to the transferred repo (i.e. tartiflette/tartiflette-starlette) and you can add me as maintainer/owner there. :-) Does that sound good?

@tsunammis
Copy link
Contributor

@florimondmanca perfect! I'd be delighted to chat with you through slack about our vision, the next subjects we will tackle and the DevExp we want to provide, are you interested in?

@tsunammis
Copy link
Contributor

@florimondmanca You can initiate the transfer, I will accept it.

@florimondmanca
Copy link
Contributor Author

@tsunammis I tried to transfer the repo but got this permission error:

You don’t have the permission to create repositories on tartiflette

But the docs read "The target account must not have a repository with the same name" so I think you need to add me to the org w/ write access beforehand.

@florimondmanca
Copy link
Contributor Author

I'd be delighted to chat with you through slack about our vision, the next subjects we will tackle and the DevExp we want to provide, are you interested in?

Sure! Can't promise anything on how much I'll contribute but I'm interested in knowing where Tartiflette is heading at. :-) You can send me a Slack invite for florimond.manca[@]gmail.com

@tsunammis
Copy link
Contributor

@florimondmanca I sent you an invitation to join the organization.

@florimondmanca
Copy link
Contributor Author

florimondmanca commented Apr 20, 2019

@tsunammis Roger that. Transfer complete 🎉 Do I already have write access for https://github.com/tartiflette/tartiflette-starlette?

@tsunammis
Copy link
Contributor

@florimondmanca Yes, you already have the right access ;-)

@abusi
Copy link
Contributor

abusi commented Apr 22, 2019

I'll consider this issue closed now ;)
Thanks again Florimond.

@abusi abusi closed this as completed Apr 22, 2019
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