Repository: mirumee/ariadne

Issue:
Support Starlette 0.21.0
Starlette 0.21.0 fix important issues on the BaseHttpMiddleware side. 

https://github.com/encode/starlette/pull/1715
https://github.com/tiangolo/fastapi/issues/4544


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -33,7 +33,7 @@
     include_package_data=True,
     install_requires=[
         "graphql-core>=3.2.0,<3.3",
-        "starlette>0.17,<0.21",
+        "starlette>0.17,<1.0",
         "typing_extensions>=3.6.0",
     ],
     extras_require={"asgi-file-uploads": ["python-multipart>=0.0.5"]},


Test patch:
diff --git a/tests/asgi/test_http_methods.py b/tests/asgi/test_http_methods.py
--- a/tests/asgi/test_http_methods.py
+++ b/tests/asgi/test_http_methods.py
@@ -31,7 +31,7 @@ def test_put_is_not_supported(client):
 
 
 def test_delete_is_not_supported(client):
-    response = client.delete("/", json={})
+    response = client.delete("/")
     assert response.status_code == 405
     assert response.headers["Allow"] == "OPTIONS, POST, GET"
 
diff --git a/tests/asgi/test_query_execution.py b/tests/asgi/test_query_execution.py
--- a/tests/asgi/test_query_execution.py
+++ b/tests/asgi/test_query_execution.py
@@ -161,7 +161,7 @@ def test_query_is_executed_for_multipart_form_request_with_file(
             ),
             "map": json.dumps({"0": ["variables.file"]}),
         },
-        files={"0": ("test.txt", "hello")},
+        files={"0": ("test.txt", "hello".encode("utf-8"))},
     )
     assert response.status_code == 200
     snapshot.assert_match(response.json())
diff --git a/tests/asgi/test_request_data_reading.py b/tests/asgi/test_request_data_reading.py
--- a/tests/asgi/test_request_data_reading.py
+++ b/tests/asgi/test_request_data_reading.py
@@ -4,19 +4,21 @@
 def test_attempt_parse_request_missing_content_type_raises_bad_request_error(
     client, snapshot
 ):
-    response = client.post("/", data="")
+    response = client.post("/", content="")
     assert response.status_code == 400
     snapshot.assert_match(response.text)
 
 
 def test_attempt_parse_non_json_request_raises_bad_request_error(client, snapshot):
-    response = client.post("/", data="", headers={"content-type": "text/plain"})
+    response = client.post("/", content="", headers={"content-type": "text/plain"})
     assert response.status_code == 400
     snapshot.assert_match(response.text)
 
 
 def test_attempt_parse_non_json_request_body_raises_bad_request_error(client, snapshot):
-    response = client.post("/", data="", headers={"content-type": "application/json"})
+    response = client.post(
+        "/", content="", headers={"content-type": "application/json"}
+    )
     assert response.status_code == 400
     snapshot.assert_match(response.text)
 
@@ -44,7 +46,7 @@ def test_multipart_form_request_fails_if_operations_is_not_valid_json(client, sn
             "operations": "not a valid json",
             "map": json.dumps({"0": ["variables.file"]}),
         },
-        files={"0": ("test.txt", "hello")},
+        files={"0": ("test.txt", "hello".encode("utf-8"))},
     )
     assert response.status_code == 400
     snapshot.assert_match(response.content)
@@ -62,7 +64,7 @@ def test_multipart_form_request_fails_if_map_is_not_valid_json(client, snapshot)
             ),
             "map": "not a valid json",
         },
-        files={"0": ("test.txt", "hello")},
+        files={"0": ("test.txt", "hello".encode("utf-8"))},
     )
     assert response.status_code == 400
     snapshot.assert_match(response.content)