Repository: strawberry-graphql/strawberry

Issue:
GraphiQl explorer tries to use websockets and falls with 500 error and “Connection reset by peer” (with Django)
There is a path to Graph**i**Ql explorer in `urls.py:`:

```
from strawberry.django.views import GraphQLView

urlpatterns = [
    ...
    path('graphql', GraphQLView.as_view(schema=schema)),
]
```
And while there is an active browser tab with `http://127.0.0.1:8000/graphql`, it continuously makes requests to `ws://127.0.0.1:8000/graphql` each 10 seconds, that causes next errors on back each request:

```
Internal Server Error: /api/
Traceback (most recent call last):
  File "/Users/Max/Documents/env/py38/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/Users/Max/Documents/env/py38/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/Max/Documents/env/py38/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/Max/Documents/env/py38/lib/python3.8/site-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/Users/Max/Documents/env/py38/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/Users/Max/Documents/env/py38/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/Users/Max/Documents/env/py38/lib/python3.8/site-packages/strawberry/django/views.py", line 50, in dispatch
    data = json.loads(request.body)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[02/Jun/2020 00:22:45] "GET /api/ HTTP/1.1" 500 92779
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 57288)
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 720, in __init__
    self.handle()
  File "/Users/Max/Documents/env/py38/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 174, in handle
    self.handle_one_request()
  File "/Users/Max/Documents/env/py38/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 182, in handle_one_request
    self.raw_requestline = self.rfile.readline(65537)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socket.py", line 669, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer
```

**So, can it be disabled of fixed somehow? It's annoying, but everything works**

P.S. There is no such thing using Graphene


Discussion:
@ssrjs oh, good catch! I'll check! I think we can disable it when using Django!

I'll try to make a PR today or tomorrow, unless someone else does it first :)

Resolving patch:
diff --git a/strawberry/asgi/utils.py b/strawberry/asgi/utils.py
--- a/strawberry/asgi/utils.py
+++ b/strawberry/asgi/utils.py
@@ -8,4 +8,4 @@ def get_graphiql_html() -> str:
     with open(path) as f:
         template = f.read()
 
-    return template
+    return template.replace("{{ SUBSCRIPTION_ENABLED }}", "true")
diff --git a/strawberry/django/views.py b/strawberry/django/views.py
--- a/strawberry/django/views.py
+++ b/strawberry/django/views.py
@@ -90,6 +90,9 @@ def _render_graphiql(self, request, context=None):
                 ).read()
             )
 
+        context = context or {}
+        context.update({"SUBSCRIPTION_ENABLED": "false"})
+
         response = TemplateResponse(request=request, template=None, context=context)
         response.content = template.render(RequestContext(request, context))
 
diff --git a/strawberry/flask/graphiql.py b/strawberry/flask/graphiql.py
--- a/strawberry/flask/graphiql.py
+++ b/strawberry/flask/graphiql.py
@@ -6,6 +6,8 @@ def render_graphiql_page():
     graphiql_html_file = f"{dir_path}/static/graphiql.html"
 
     html_string = None
+
     with open(graphiql_html_file, "r") as f:
         html_string = f.read()
-    return html_string
+
+    return html_string.replace("{{ SUBSCRIPTION_ENABLED }}", "false")


Test patch: