From 13d2d8224351da9e4a96809f3224b7382bad626c Mon Sep 17 00:00:00 2001 From: Ryan Lim Date: Thu, 3 Oct 2024 17:11:34 -0400 Subject: [PATCH] allow ability to add global dependencies --- platformics/graphql_api/setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformics/graphql_api/setup.py b/platformics/graphql_api/setup.py index 0c98118..3f32a00 100644 --- a/platformics/graphql_api/setup.py +++ b/platformics/graphql_api/setup.py @@ -50,7 +50,7 @@ def get_graphql_name(self, obj: HasGraphQLName) -> str: return super().get_graphql_name(obj) -def get_app(settings: APISettings, schema: strawberry.Schema, db_module: typing.Any) -> FastAPI: +def get_app(settings: APISettings, schema: strawberry.Schema, db_module: typing.Any, dependencies: typing.Optional[typing.Sequence[Depends]]) -> FastAPI: """ Make sure tests can get their own instances of the app. """ @@ -59,7 +59,7 @@ def get_app(settings: APISettings, schema: strawberry.Schema, db_module: typing. title = settings.SERVICE_NAME graphql_app: GraphQLRouter = GraphQLRouter(schema, context_getter=get_context) - _app = FastAPI(title=title, debug=settings.DEBUG) + _app = FastAPI(title=title, debug=settings.DEBUG, dependencies=dependencies) _app.include_router(graphql_app, prefix="/graphql") # Add a global settings object to the app that we can use as a dependency _app.state.settings = settings