Skip to content

Commit

Permalink
Skipped exceptions #4
Browse files Browse the repository at this point in the history
  • Loading branch information
mongkok committed Mar 25, 2018
1 parent 822a93c commit 1a75956
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions graphiql_debug_toolbar/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from django.template.loader import render_to_string
from django.utils.encoding import force_text

from debug_toolbar.middleware import \
DebugToolbarMiddleware as BaseDebugToolbarMiddleware
from debug_toolbar import middleware
from graphene_django.views import GraphQLView

from .serializers import CallableJSONEncoder
Expand Down Expand Up @@ -48,7 +47,7 @@ def get_payload(request, response, toolbar):
return payload


class DebugToolbarMiddleware(BaseDebugToolbarMiddleware):
class DebugToolbarMiddleware(middleware.DebugToolbarMiddleware):

def process_request(self, request):
request.is_graphiql = False
Expand All @@ -68,12 +67,18 @@ def process_response(self, request, response):
threading.current_thread().ident, None)

response = super().process_response(request, response)
content_type = response.get('Content-Type', '').split(';')[0]

if (response.status_code == 200 and
toolbar is not None and
request.is_graphiql and
not is_query):

if toolbar is not None and request.is_graphiql and not is_query:
template = render_to_string('graphiql_debug_toolbar/base.html')
set_content(response, get_content(response) + template)

if toolbar is None or not is_query:
if (toolbar is None or not is_query or
content_type in middleware._HTML_TYPES):
return response

payload = get_payload(request, response, toolbar)
Expand Down

0 comments on commit 1a75956

Please sign in to comment.