We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `strawberry/flask/graphiql.py`
Content:
```
1 from os.path import abspath, dirname, join
2 
3 
4 def render_graphiql_page():
5     dir_path = abspath(join(dirname(__file__), ".."))
6     graphiql_html_file = f"{dir_path}/static/graphiql.html"
7 
8     html_string = None
9     with open(graphiql_html_file, "r") as f:
10         html_string = f.read()
11     return html_string
12
```

Path: `strawberry/django/views.py`
Content:
```
1 import json
2 import os
3 
4 from django.http import Http404, HttpResponseNotAllowed, JsonResponse
5 from django.http.response import HttpResponseBadRequest
6 from django.template import RequestContext, Template
7 from django.template.exceptions import TemplateDoesNotExist
8 from django.template.loader import render_to_string
9 from django.template.response import TemplateResponse
10 from django.utils.decorators import method_decorator
11 from django.views.decorators.csrf import csrf_exempt
12 from django.views.generic import View
13 
14 import strawberry
15 from graphql import graphql_sync
16 from graphql.error import format_error as format_graphql_error
17 from graphql.type.schema import GraphQLSchema
18 
19 
20 class GraphQLView(View):
21     schema = None
22     graphiql = True
23 
24     def __init__(self, schema=None, graphiql=True):
25         if not schema:
26             raise ValueError("You must pass in a schema to GraphQLView")
27 
28         if not isinstance(schema, GraphQLSchema):
29             raise ValueError("You must pass in a valid schema to GraphQLView")
30 
31         self.schema = schema
32         self.graphiql = graphiql
33 
34     def get_root_value(self):
35         return None
36 
37     @method_decorator(csrf_exempt)
38     def dispatch(self, request, *args, **kwargs):
39         if request.method.lower() not in ("get", "post"):
40             return HttpResponseNotAllowed(
41                 ["GET", "POST"], "GraphQL only supports GET and POST requests."
42             )
43 
44         if "text/html" in request.META.get("HTTP_ACCEPT", ""):
45             if not self.graphiql:
46                 raise Http404("GraphiQL has been disabled")
47 
48             return self._render_graphiql(request)
49 
50         data = json.loads(request.body)
51 
52         try:
53             query = data["query"]
54             variables = data.get("variables")
55             operation_name = data.get("operationName")
56         except KeyError:
57             return HttpResponseBadRequest("No GraphQL query found in the request")
58 
59         context = {"request": request}
60 
61         result = graphql_sync(
62             self.schema,
63             query,
64             root_value=self.get_root_value(),
65             variable_values=variables,
66             context_value=context,
67             operation_name=operation_name,
68         )
69 
70         response_data = {"data": result.data}
71 
72         if result.errors:
73             response_data["errors"] = [
74                 format_graphql_error(err) for err in result.errors
75             ]
76 
77         return JsonResponse(response_data)
78 
79     def _render_graphiql(self, request, context=None):
80         try:
81             template = Template(render_to_string("graphql/graphiql.html"))
82         except TemplateDoesNotExist:
83             template = Template(
84                 open(
85                     os.path.join(
86                         os.path.dirname(os.path.abspath(strawberry.__file__)),
87                         "static/graphiql.html",
88                     ),
89                     "r",
90                 ).read()
91             )
92 
93         response = TemplateResponse(request=request, template=None, context=context)
94         response.content = template.render(RequestContext(request, context))
95 
96         return response
97
```

Path: `strawberry/asgi/utils.py`
Content:
```
1 import pathlib
2 
3 
4 def get_graphiql_html() -> str:
5     here = pathlib.Path(__file__).parents[1]
6     path = here / "static/graphiql.html"
7 
8     with open(path) as f:
9         template = f.read()
10 
11     return template
12
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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 @@
     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 @@
                 ).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 @@
     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")

{"golden_diff": "diff --git a/strawberry/asgi/utils.py b/strawberry/asgi/utils.py\n--- a/strawberry/asgi/utils.py\n+++ b/strawberry/asgi/utils.py\n@@ -8,4 +8,4 @@\n     with open(path) as f:\n         template = f.read()\n \n-    return template\n+    return template.replace(\"{{ SUBSCRIPTION_ENABLED }}\", \"true\")\ndiff --git a/strawberry/django/views.py b/strawberry/django/views.py\n--- a/strawberry/django/views.py\n+++ b/strawberry/django/views.py\n@@ -90,6 +90,9 @@\n                 ).read()\n             )\n \n+        context = context or {}\n+        context.update({\"SUBSCRIPTION_ENABLED\": \"false\"})\n+\n         response = TemplateResponse(request=request, template=None, context=context)\n         response.content = template.render(RequestContext(request, context))\n \ndiff --git a/strawberry/flask/graphiql.py b/strawberry/flask/graphiql.py\n--- a/strawberry/flask/graphiql.py\n+++ b/strawberry/flask/graphiql.py\n@@ -6,6 +6,8 @@\n     graphiql_html_file = f\"{dir_path}/static/graphiql.html\"\n \n     html_string = None\n+\n     with open(graphiql_html_file, \"r\") as f:\n         html_string = f.read()\n-    return html_string\n+\n+    return html_string.replace(\"{{ SUBSCRIPTION_ENABLED }}\", \"false\")\n", "issue": "GraphiQl explorer tries to use websockets and falls with 500 error and \u201cConnection reset by peer\u201d (with Django)\nThere is a path to Graph**i**Ql explorer in `urls.py:`:\r\n\r\n```\r\nfrom strawberry.django.views import GraphQLView\r\n\r\nurlpatterns = [\r\n    ...\r\n    path('graphql', GraphQLView.as_view(schema=schema)),\r\n]\r\n```\r\nAnd 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:\r\n\r\n```\r\nInternal Server Error: /api/\r\nTraceback (most recent call last):\r\n  File \"/Users/Max/Documents/env/py38/lib/python3.8/site-packages/django/core/handlers/exception.py\", line 34, in inner\r\n    response = get_response(request)\r\n  File \"/Users/Max/Documents/env/py38/lib/python3.8/site-packages/django/core/handlers/base.py\", line 115, in _get_response\r\n    response = self.process_exception_by_middleware(e, request)\r\n  File \"/Users/Max/Documents/env/py38/lib/python3.8/site-packages/django/core/handlers/base.py\", line 113, in _get_response\r\n    response = wrapped_callback(request, *callback_args, **callback_kwargs)\r\n  File \"/Users/Max/Documents/env/py38/lib/python3.8/site-packages/django/views/generic/base.py\", line 71, in view\r\n    return self.dispatch(request, *args, **kwargs)\r\n  File \"/Users/Max/Documents/env/py38/lib/python3.8/site-packages/django/utils/decorators.py\", line 43, in _wrapper\r\n    return bound_method(*args, **kwargs)\r\n  File \"/Users/Max/Documents/env/py38/lib/python3.8/site-packages/django/views/decorators/csrf.py\", line 54, in wrapped_view\r\n    return view_func(*args, **kwargs)\r\n  File \"/Users/Max/Documents/env/py38/lib/python3.8/site-packages/strawberry/django/views.py\", line 50, in dispatch\r\n    data = json.loads(request.body)\r\n  File \"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/__init__.py\", line 357, in loads\r\n    return _default_decoder.decode(s)\r\n  File \"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py\", line 337, in decode\r\n    obj, end = self.raw_decode(s, idx=_w(s, 0).end())\r\n  File \"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py\", line 355, in raw_decode\r\n    raise JSONDecodeError(\"Expecting value\", s, err.value) from None\r\njson.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)\r\n[02/Jun/2020 00:22:45] \"GET /api/ HTTP/1.1\" 500 92779\r\n----------------------------------------\r\nException happened during processing of request from ('127.0.0.1', 57288)\r\nTraceback (most recent call last):\r\n  File \"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py\", line 650, in process_request_thread\r\n    self.finish_request(request, client_address)\r\n  File \"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py\", line 360, in finish_request\r\n    self.RequestHandlerClass(request, client_address, self)\r\n  File \"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py\", line 720, in __init__\r\n    self.handle()\r\n  File \"/Users/Max/Documents/env/py38/lib/python3.8/site-packages/django/core/servers/basehttp.py\", line 174, in handle\r\n    self.handle_one_request()\r\n  File \"/Users/Max/Documents/env/py38/lib/python3.8/site-packages/django/core/servers/basehttp.py\", line 182, in handle_one_request\r\n    self.raw_requestline = self.rfile.readline(65537)\r\n  File \"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socket.py\", line 669, in readinto\r\n    return self._sock.recv_into(b)\r\nConnectionResetError: [Errno 54] Connection reset by peer\r\n```\r\n\r\n**So, can it be disabled of fixed somehow? It's annoying, but everything works**\r\n\r\nP.S. There is no such thing using Graphene\n", "before_files": [{"content": "from os.path import abspath, dirname, join\n\n\ndef render_graphiql_page():\n    dir_path = abspath(join(dirname(__file__), \"..\"))\n    graphiql_html_file = f\"{dir_path}/static/graphiql.html\"\n\n    html_string = None\n    with open(graphiql_html_file, \"r\") as f:\n        html_string = f.read()\n    return html_string\n", "path": "strawberry/flask/graphiql.py"}, {"content": "import json\nimport os\n\nfrom django.http import Http404, HttpResponseNotAllowed, JsonResponse\nfrom django.http.response import HttpResponseBadRequest\nfrom django.template import RequestContext, Template\nfrom django.template.exceptions import TemplateDoesNotExist\nfrom django.template.loader import render_to_string\nfrom django.template.response import TemplateResponse\nfrom django.utils.decorators import method_decorator\nfrom django.views.decorators.csrf import csrf_exempt\nfrom django.views.generic import View\n\nimport strawberry\nfrom graphql import graphql_sync\nfrom graphql.error import format_error as format_graphql_error\nfrom graphql.type.schema import GraphQLSchema\n\n\nclass GraphQLView(View):\n    schema = None\n    graphiql = True\n\n    def __init__(self, schema=None, graphiql=True):\n        if not schema:\n            raise ValueError(\"You must pass in a schema to GraphQLView\")\n\n        if not isinstance(schema, GraphQLSchema):\n            raise ValueError(\"You must pass in a valid schema to GraphQLView\")\n\n        self.schema = schema\n        self.graphiql = graphiql\n\n    def get_root_value(self):\n        return None\n\n    @method_decorator(csrf_exempt)\n    def dispatch(self, request, *args, **kwargs):\n        if request.method.lower() not in (\"get\", \"post\"):\n            return HttpResponseNotAllowed(\n                [\"GET\", \"POST\"], \"GraphQL only supports GET and POST requests.\"\n            )\n\n        if \"text/html\" in request.META.get(\"HTTP_ACCEPT\", \"\"):\n            if not self.graphiql:\n                raise Http404(\"GraphiQL has been disabled\")\n\n            return self._render_graphiql(request)\n\n        data = json.loads(request.body)\n\n        try:\n            query = data[\"query\"]\n            variables = data.get(\"variables\")\n            operation_name = data.get(\"operationName\")\n        except KeyError:\n            return HttpResponseBadRequest(\"No GraphQL query found in the request\")\n\n        context = {\"request\": request}\n\n        result = graphql_sync(\n            self.schema,\n            query,\n            root_value=self.get_root_value(),\n            variable_values=variables,\n            context_value=context,\n            operation_name=operation_name,\n        )\n\n        response_data = {\"data\": result.data}\n\n        if result.errors:\n            response_data[\"errors\"] = [\n                format_graphql_error(err) for err in result.errors\n            ]\n\n        return JsonResponse(response_data)\n\n    def _render_graphiql(self, request, context=None):\n        try:\n            template = Template(render_to_string(\"graphql/graphiql.html\"))\n        except TemplateDoesNotExist:\n            template = Template(\n                open(\n                    os.path.join(\n                        os.path.dirname(os.path.abspath(strawberry.__file__)),\n                        \"static/graphiql.html\",\n                    ),\n                    \"r\",\n                ).read()\n            )\n\n        response = TemplateResponse(request=request, template=None, context=context)\n        response.content = template.render(RequestContext(request, context))\n\n        return response\n", "path": "strawberry/django/views.py"}, {"content": "import pathlib\n\n\ndef get_graphiql_html() -> str:\n    here = pathlib.Path(__file__).parents[1]\n    path = here / \"static/graphiql.html\"\n\n    with open(path) as f:\n        template = f.read()\n\n    return template\n", "path": "strawberry/asgi/utils.py"}], "after_files": [{"content": "from os.path import abspath, dirname, join\n\n\ndef render_graphiql_page():\n    dir_path = abspath(join(dirname(__file__), \"..\"))\n    graphiql_html_file = f\"{dir_path}/static/graphiql.html\"\n\n    html_string = None\n\n    with open(graphiql_html_file, \"r\") as f:\n        html_string = f.read()\n\n    return html_string.replace(\"{{ SUBSCRIPTION_ENABLED }}\", \"false\")\n", "path": "strawberry/flask/graphiql.py"}, {"content": "import json\nimport os\n\nfrom django.http import Http404, HttpResponseNotAllowed, JsonResponse\nfrom django.http.response import HttpResponseBadRequest\nfrom django.template import RequestContext, Template\nfrom django.template.exceptions import TemplateDoesNotExist\nfrom django.template.loader import render_to_string\nfrom django.template.response import TemplateResponse\nfrom django.utils.decorators import method_decorator\nfrom django.views.decorators.csrf import csrf_exempt\nfrom django.views.generic import View\n\nimport strawberry\nfrom graphql import graphql_sync\nfrom graphql.error import format_error as format_graphql_error\nfrom graphql.type.schema import GraphQLSchema\n\n\nclass GraphQLView(View):\n    schema = None\n    graphiql = True\n\n    def __init__(self, schema=None, graphiql=True):\n        if not schema:\n            raise ValueError(\"You must pass in a schema to GraphQLView\")\n\n        if not isinstance(schema, GraphQLSchema):\n            raise ValueError(\"You must pass in a valid schema to GraphQLView\")\n\n        self.schema = schema\n        self.graphiql = graphiql\n\n    def get_root_value(self):\n        return None\n\n    @method_decorator(csrf_exempt)\n    def dispatch(self, request, *args, **kwargs):\n        if request.method.lower() not in (\"get\", \"post\"):\n            return HttpResponseNotAllowed(\n                [\"GET\", \"POST\"], \"GraphQL only supports GET and POST requests.\"\n            )\n\n        if \"text/html\" in request.META.get(\"HTTP_ACCEPT\", \"\"):\n            if not self.graphiql:\n                raise Http404(\"GraphiQL has been disabled\")\n\n            return self._render_graphiql(request)\n\n        data = json.loads(request.body)\n\n        try:\n            query = data[\"query\"]\n            variables = data.get(\"variables\")\n            operation_name = data.get(\"operationName\")\n        except KeyError:\n            return HttpResponseBadRequest(\"No GraphQL query found in the request\")\n\n        context = {\"request\": request}\n\n        result = graphql_sync(\n            self.schema,\n            query,\n            root_value=self.get_root_value(),\n            variable_values=variables,\n            context_value=context,\n            operation_name=operation_name,\n        )\n\n        response_data = {\"data\": result.data}\n\n        if result.errors:\n            response_data[\"errors\"] = [\n                format_graphql_error(err) for err in result.errors\n            ]\n\n        return JsonResponse(response_data)\n\n    def _render_graphiql(self, request, context=None):\n        try:\n            template = Template(render_to_string(\"graphql/graphiql.html\"))\n        except TemplateDoesNotExist:\n            template = Template(\n                open(\n                    os.path.join(\n                        os.path.dirname(os.path.abspath(strawberry.__file__)),\n                        \"static/graphiql.html\",\n                    ),\n                    \"r\",\n                ).read()\n            )\n\n        context = context or {}\n        context.update({\"SUBSCRIPTION_ENABLED\": \"false\"})\n\n        response = TemplateResponse(request=request, template=None, context=context)\n        response.content = template.render(RequestContext(request, context))\n\n        return response\n", "path": "strawberry/django/views.py"}, {"content": "import pathlib\n\n\ndef get_graphiql_html() -> str:\n    here = pathlib.Path(__file__).parents[1]\n    path = here / \"static/graphiql.html\"\n\n    with open(path) as f:\n        template = f.read()\n\n    return template.replace(\"{{ SUBSCRIPTION_ENABLED }}\", \"true\")\n", "path": "strawberry/asgi/utils.py"}]}