38 lines
880 B
Python
38 lines
880 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.
|
|
|
|
Author(s): anatol.ulrich@basebox.io
|
|
|
|
Copyright (c) 2023 basebox GmbH. All rights reserved.
|
|
|
|
"""
|
|
|
|
# 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")
|