Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Update django debug toolbar
IKarbowiakdec881701605
diff --git a/saleor/graphql/middleware.py b/saleor/graphql/middleware.pyindex a12557dff3..c7c9fdba88 100644--- a/saleor/graphql/middleware.py+++ b/saleor/graphql/middleware.py@@ -1,5 +1,6 @@from typing import Optional+from django.conf import settingsfrom django.contrib.auth.models import AnonymousUserfrom django.shortcuts import reversefrom django.utils.functional import SimpleLazyObject@@ -57,3 +58,21 @@ def service_account_middleware(get_response):return get_response(request)return middleware+++if settings.ENABLE_DEBUG_TOOLBAR:+ try:+ from graphiql_debug_toolbar.middleware import DebugToolbarMiddleware+ except ImportError:+ """The graphiql debug toolbar was not installed. Ignore the error.+ settings.py should already have warned the user about it."""+ else:+ from .views import GraphQLView++ def process_view(self, request, view_func, *args):+ if hasattr(view_func, "view_class") and issubclass(+ view_func.view_class, GraphQLView+ ):+ request._graphql_view = True++ DebugToolbarMiddleware.process_view = process_viewdiff --git a/saleor/settings.py b/saleor/settings.pyindex 15285f9387..2fcdc10422 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -273,9 +273,9 @@ INSTALLED_APPS = [ENABLE_DEBUG_TOOLBAR = get_bool_from_env("ENABLE_DEBUG_TOOLBAR", False)if ENABLE_DEBUG_TOOLBAR:- # Ensure the debug toolbar is actually installed before adding it+ # Ensure the graphiql debug toolbar is actually installed before adding ittry:- __import__("debug_toolbar")+ __import__("graphiql_debug_toolbar")except ImportError as exc:msg = (f"{exc} -- Install the missing dependencies by "@@ -283,19 +283,18 @@ if ENABLE_DEBUG_TOOLBAR:)warnings.warn(msg)else:- MIDDLEWARE.append("debug_toolbar.middleware.DebugToolbarMiddleware")- INSTALLED_APPS.append("debug_toolbar")-- DEBUG_TOOLBAR_PANELS = [- # adds a request history to the debug toolbar- "ddt_request_history.panels.request_history.RequestHistoryPanel",- "debug_toolbar.panels.timer.TimerPanel",- "debug_toolbar.panels.headers.HeadersPanel",- "debug_toolbar.panels.request.RequestPanel",- "debug_toolbar.panels.sql.SQLPanel",- "debug_toolbar.panels.profiling.ProfilingPanel",- ]- DEBUG_TOOLBAR_CONFIG = {"RESULTS_CACHE_SIZE": 100}+ INSTALLED_APPS += ["debug_toolbar", "graphiql_debug_toolbar"]+ MIDDLEWARE.append("saleor.graphql.middleware.DebugToolbarMiddleware")++ DEBUG_TOOLBAR_PANELS = [+ "ddt_request_history.panels.request_history.RequestHistoryPanel",+ "debug_toolbar.panels.timer.TimerPanel",+ "debug_toolbar.panels.headers.HeadersPanel",+ "debug_toolbar.panels.request.RequestPanel",+ "debug_toolbar.panels.sql.SQLPanel",+ "debug_toolbar.panels.profiling.ProfilingPanel",+ ]+ DEBUG_TOOLBAR_CONFIG = {"RESULTS_CACHE_SIZE": 100}ENABLE_SILK = get_bool_from_env("ENABLE_SILK", False)if ENABLE_SILK: