diff options
Diffstat (limited to 'src/services/api')
-rw-r--r-- | src/services/api/graphql/routers.py | 10 | ||||
-rw-r--r-- | src/services/api/rest/routers.py | 8 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/services/api/graphql/routers.py b/src/services/api/graphql/routers.py index d04375a49..f02380cdc 100644 --- a/src/services/api/graphql/routers.py +++ b/src/services/api/graphql/routers.py @@ -38,6 +38,10 @@ def graphql_init(app: "FastAPI"): in_spec = state.introspection + # remove route and reinstall below, for any changes; alternatively, test + # for config_diff before proceeding + graphql_clear(app) + if state.origins: origins = state.origins app.add_route('/graphql', CORSMiddleware(GraphQL(schema, @@ -52,3 +56,9 @@ def graphql_init(app: "FastAPI"): context_value=get_user_context, debug=True, introspection=in_spec)) + + +def graphql_clear(app: "FastAPI"): + for r in app.routes: + if r.path == '/graphql': + app.routes.remove(r) diff --git a/src/services/api/rest/routers.py b/src/services/api/rest/routers.py index 1568f7d0c..38b10ef7d 100644 --- a/src/services/api/rest/routers.py +++ b/src/services/api/rest/routers.py @@ -682,4 +682,12 @@ def poweroff_op(data: PoweroffModel): def rest_init(app: "FastAPI"): + if all(r in app.routes for r in router.routes): + return app.include_router(router) + + +def rest_clear(app: "FastAPI"): + for r in router.routes: + if r in app.routes: + app.routes.remove(r) |