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

Custom lifespan handlers #286

Closed
jimtheplant opened this issue Dec 29, 2019 · 1 comment
Closed

Custom lifespan handlers #286

jimtheplant opened this issue Dec 29, 2019 · 1 comment

Comments

@jimtheplant
Copy link

Hi,

I was wondering if there was any plan to implement the lifespan protocol for the provided asgi server. I think this could be done with extensions or a passing new keyword args to the asgi object. Could be nice for things such as closing DB connections, startup error handling, ect.

@rafalp
Copy link
Contributor

rafalp commented Dec 29, 2019

Hey!

Idea behind default server is to provide people with quick way to get their GraphQL server up and running locally so they can play around - write some schema, run some queries against it to see how resolvers are called, etc. etc.

Obviously this approach is unfit for great majority of "real apps" that will want to do things like manage DB connections and other things you've mentioned. But we really don't want to end up maintaining both the GraphQL server and the ASGI/HTTP stack.

If you need the entire thing, the recommended approach is to use the full-fledged ASGI server and mount Ariadne's ASGI application within it. Here's example how to do it with Starlette: https://ariadnegraphql.org/docs/starlette-integration

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

2 participants