py-microservice/app.py
2023-10-04 21:08:37 +02:00

34 lines
788 B
Python

#!/usr/bin/env python3
"""
Basebox microservices example app
this defines an `app:app` module which is loaded from `main.py` or directly via `uvicorn app:app`.
in the latter case configuration can only be passed via OS environment or an env file (`--env-file`), not TOML.
"""
# stdlib imports
import logging
# dependencies imports
from fastapi import FastAPI
from strawberry.fastapi import GraphQLRouter
# app imports
import schema
import consts
import auth
logger = logging.getLogger(consts.LOG_ROOT)
logger.debug('starting app')
# configure GraphQL with `schema.schema` and additional auth context
graphql_app = GraphQLRouter(schema.schema, context_getter=auth.get_context)
# create app with GraphQL routing
app = FastAPI()
app.include_router(graphql_app, prefix="/graphql")