from aiohttp import web from ariadne import make_executable_schema, load_schema_from_path from ariadne.asgi import GraphQL from services.redis import redis from resolvers import resolvers type_defs = load_schema_from_path("inbox.graphql") schema = make_executable_schema(type_defs, resolvers) async def on_startup(_app): await redis.connect() async def on_cleanup(_app): await redis.disconnect() # Run the aiohttp server if __name__ == "__main__": app = web.Application() app.on_startup.append(on_startup) app.on_cleanup.append(on_cleanup) app.router.add_route( "*", "/graphql", GraphQL(schema), ) web.run_app(app)