Changeset View
Changeset View
Standalone View
Standalone View
swh/graphql/server.py
# Copyright (C) 2022 The Software Heritage developers | |||||
# See the AUTHORS file at the top-level directory of this distribution | |||||
# License: GNU General Public License version 3, or any later version | |||||
# See top-level LICENSE file for more information | |||||
import os | import os | ||||
from typing import Any, Dict, Optional | from typing import Any, Dict, Optional | ||||
from swh.core import config | from swh.core import config | ||||
from swh.storage import get_storage as get_swhstorage | from swh.storage import get_storage as get_swhstorage | ||||
graphql_cfg = None | graphql_cfg = None | ||||
storage = None | storage = None | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | def make_app_from_configfile(): | ||||
from .app import schema | from .app import schema | ||||
global graphql_cfg | global graphql_cfg | ||||
if not graphql_cfg: | if not graphql_cfg: | ||||
config_path = os.environ.get("SWH_CONFIG_FILENAME") | config_path = os.environ.get("SWH_CONFIG_FILENAME") | ||||
graphql_cfg = load_and_check_config(config_path) | graphql_cfg = load_and_check_config(config_path) | ||||
if graphql_cfg.get("server-type") == "asgi": | server_type = graphql_cfg.get("server-type") | ||||
if server_type == "asgi": | |||||
from ariadne.asgi import GraphQL | from ariadne.asgi import GraphQL | ||||
application = GraphQL(schema) | application = GraphQL(schema) | ||||
else: | else: | ||||
from ariadne.wsgi import GraphQL | from ariadne.wsgi import GraphQL | ||||
application = GraphQL(schema) | application = GraphQL(schema) | ||||
return application | return application | ||||
anlambert: s/falsk/flask/ | |||||
Done Inline ActionsIf this only used by test, you should move this code in conftest.py and wraps it in a session scope fixture. anlambert: If this only used by test, you should move this code in `conftest.py` and wraps it in a session… |
s/falsk/flask/