From a368131b3596717af0831551585bf658ca2dd0f5 Mon Sep 17 00:00:00 2001 From: Ryan Lim Date: Thu, 10 Oct 2024 17:12:01 -0700 Subject: [PATCH] test passing in app to get_app --- 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 1dc4a56..9322bf9 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, dependencies: typing.Optional[typing.Sequence[Depends]] = []) -> FastAPI: +def get_app(settings: APISettings, schema: strawberry.Schema, db_module: typing.Any, dependencies: typing.Optional[typing.Sequence[Depends]] = [], app: typing.Optional[FastAPI] = None) -> 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, dependencies=dependencies) + _app = app if app else 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