Repository: mirumee/ariadne (language: python)

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 / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 485edc8b4..2ffedd603 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@
 - Added `explorer` option to ASGI and WSGI `GraphQL` applications that enables API explorer customization.
 - Added `ExplorerHttp405` API explorer that returns `405 Method Not Allowed` for GET HTTP requests.
 - Added implementations for GraphiQL2, GraphQL-Playground and Apollo Sandbox explorers.
+- Updated `starlette` dependency in setup.py to `<1.0`.
 
 
 ## 0.16.1 (2022-09-26)
diff --git a/requirements-dev.in b/requirements-dev.in
index e1270b230..9152094b6 100644
--- a/requirements-dev.in
+++ b/requirements-dev.in
@@ -1,6 +1,7 @@
 black
 codecov
 freezegun
+httpx
 mypy
 opentracing
 pylint
diff --git a/requirements-dev.txt b/requirements-dev.txt
index e480c17ab..dec8f380d 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -1,9 +1,11 @@
 #
-# This file is autogenerated by pip-compile with python 3.8
+# This file is autogenerated by pip-compile with python 3.10
 # To update, run:
 #
 #    pip-compile --output-file=requirements-dev.txt requirements-dev.in
 #
+anyio==3.6.2
+    # via httpcore
 astroid==2.11.5
     # via pylint
 attrs==19.3.0
@@ -13,7 +15,10 @@ black==22.8.0
 build==0.8.0
     # via pip-tools
 certifi==2019.9.11
-    # via requests
+    # via
+    #   httpcore
+    #   httpx
+    #   requests
 charset-normalizer==2.0.3
     # via requests
 click==8.0.3
@@ -32,8 +37,17 @@ fastdiff==0.2.0
     # via snapshottest
 freezegun==1.2.2
     # via -r requirements-dev.in
+h11==0.12.0
+    # via httpcore
+httpcore==0.15.0
+    # via httpx
+httpx==0.23.0
+    # via -r requirements-dev.in
 idna==2.8
-    # via requests
+    # via
+    #   anyio
+    #   requests
+    #   rfc3986
 iniconfig==1.0.1
     # via pytest
 isort==4.3.21
@@ -101,6 +115,8 @@ requests==2.28.1
     # via
     #   -r requirements-dev.in
     #   codecov
+rfc3986[idna2008]==1.5.0
+    # via httpx
 six==1.13.0
     # via
     #   packaging
@@ -109,10 +125,17 @@ six==1.13.0
     #   snapshottest
 snapshottest==0.6.0
     # via -r requirements-dev.in
+sniffio==1.3.0
+    # via
+    #   anyio
+    #   httpcore
+    #   httpx
 termcolor==1.1.0
     # via snapshottest
 toml==0.10.2
-    # via coverage
+    # via
+    #   coverage
+    #   pep517
 tomli==1.2.3
     # via
     #   black
diff --git a/requirements.txt b/requirements.txt
index 09eb1c464..1ee342e8a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -12,7 +12,7 @@ idna==3.3
     # via anyio
 sniffio==1.2.0
     # via anyio
-starlette==0.20.4
+starlette==0.21.0
     # via ariadne (setup.py)
 typing-extensions==4.3.0
     # via ariadne (setup.py)
diff --git a/setup.py b/setup.py
index f5406b857..fac8a2a13 100755
--- 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
index 338dbb9d8..dc1302923 100644
--- 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
index 41b285eca..7043643e0 100644
--- 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
index 8729d6d47..af10b9477 100644
--- 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)