summaryrefslogtreecommitdiff
path: root/src/services/api/graphql/routers.py
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2024-09-30 20:40:02 -0500
committerJohn Estabrook <jestabro@vyos.io>2024-09-30 21:56:06 -0500
commit7e23fd9da028b3c623b69fda8a6bcfd887f1c18c (patch)
treeb3b4e32a845f7635a1107feaa6a287eb9121818f /src/services/api/graphql/routers.py
parent40d966310cb5d8d758f7fa801facd0a560795783 (diff)
downloadvyos-1x-7e23fd9da028b3c623b69fda8a6bcfd887f1c18c.tar.gz
vyos-1x-7e23fd9da028b3c623b69fda8a6bcfd887f1c18c.zip
http-api: T6736: normalize formatting
Diffstat (limited to 'src/services/api/graphql/routers.py')
-rw-r--r--src/services/api/graphql/routers.py41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/services/api/graphql/routers.py b/src/services/api/graphql/routers.py
index f02380cdc..ed3ee1e8c 100644
--- a/src/services/api/graphql/routers.py
+++ b/src/services/api/graphql/routers.py
@@ -26,14 +26,15 @@ if typing.TYPE_CHECKING:
from fastapi import FastAPI
-def graphql_init(app: "FastAPI"):
- from .. session import SessionState
+def graphql_init(app: 'FastAPI'):
+ from ..session import SessionState
from .libs.token_auth import get_user_context
state = SessionState()
# import after initializaion of state
from .bindings import generate_schema
+
schema = generate_schema()
in_spec = state.introspection
@@ -44,21 +45,33 @@ def graphql_init(app: "FastAPI"):
if state.origins:
origins = state.origins
- app.add_route('/graphql', CORSMiddleware(GraphQL(schema,
- context_value=get_user_context,
- debug=True,
- introspection=in_spec),
- allow_origins=origins,
- allow_methods=("GET", "POST", "OPTIONS"),
- allow_headers=("Authorization",)))
+ app.add_route(
+ '/graphql',
+ CORSMiddleware(
+ GraphQL(
+ schema,
+ context_value=get_user_context,
+ debug=True,
+ introspection=in_spec,
+ ),
+ allow_origins=origins,
+ allow_methods=('GET', 'POST', 'OPTIONS'),
+ allow_headers=('Authorization',),
+ ),
+ )
else:
- app.add_route('/graphql', GraphQL(schema,
- context_value=get_user_context,
- debug=True,
- introspection=in_spec))
+ app.add_route(
+ '/graphql',
+ GraphQL(
+ schema,
+ context_value=get_user_context,
+ debug=True,
+ introspection=in_spec,
+ ),
+ )
-def graphql_clear(app: "FastAPI"):
+def graphql_clear(app: 'FastAPI'):
for r in app.routes:
if r.path == '/graphql':
app.routes.remove(r)