Ariadne provides a
GraphQL class that implements a production-ready ASGI application.
Using with an ASGI server
First create an application instance pointing it to the schema to serve:
# in myasgi.py import os from ariadne import make_executable_schema from ariadne.asgi import GraphQL from mygraphql import type_defs, resolvers schema = make_executable_schema(type_defs, resolvers) application = GraphQL(schema)
Then point an ASGI server such as uvicorn at the above instance.
Example using uvicorn:
GraphQL takes mostly the same options that
graphql does, but with two differences:
context_valuecan be callable that will be called with single argument (
Requestinstance) and its return value will be used for rest of query execution as
keepaliveoption that is specific to ASGI app and takes float with number of seconds for how long should connection be kept alive if no data is being exchanged.