Repository: strawberry-graphql/strawberry

Issue:
Incompatible with latest version of Starlette (v0.18.0)
## Overview

The newest version of starlette gives a crash when initializing the sub_response on [this line](https://github.com/strawberry-graphql/strawberry/blob/b10f98878ea51a2ed1cb0c998c5be35b7acb189b/strawberry/asgi/handlers/http_handler.py#L40).

Specifically, setting `status_code=None` prevents the Response from initializing due to the code in Starlette's `Response.init_headers()` on [this line](https://github.com/encode/starlette/blob/2d6ddd386199e9e6cf0df0849e1de7d1a8c86b9d/starlette/responses.py#L77).

## Stack Trace
```
.tox/python-framework_strawberry-py39-strawberrylatest/lib/python3.9/site-packages/strawberry/asgi/__init__.py:45: in __call__
    await self.http_handler_class(
.tox/python-framework_strawberry-py39-strawberrylatest/lib/python3.9/site-packages/strawberry/asgi/handlers/http_handler.py:38: in handle
    sub_response = Response(
../../Packages/starlette/starlette/responses.py:50: in __init__
    self.init_headers(headers)

    def init_headers(self, headers: typing.Mapping[str, str] = None) -> None:
        if headers is None:
            raw_headers: typing.List[typing.Tuple[bytes, bytes]] = []
            populate_content_length = True
            populate_content_type = True
        else:
            raw_headers = [
                (k.lower().encode("latin-1"), v.encode("latin-1"))
                for k, v in headers.items()
            ]
            keys = [h[0] for h in raw_headers]
            populate_content_length = b"content-length" not in keys
            populate_content_type = b"content-type" not in keys
    
        body = getattr(self, "body", None)
        if (
            body is not None
            and populate_content_length
>           and not (self.status_code < 200 or self.status_code in (204, 304))
        ):
E       TypeError: '<' not supported between instances of 'NoneType' and 'int'
```


Discussion:

Resolving patch:
diff --git a/strawberry/asgi/handlers/http_handler.py b/strawberry/asgi/handlers/http_handler.py
--- a/strawberry/asgi/handlers/http_handler.py
+++ b/strawberry/asgi/handlers/http_handler.py
@@ -39,13 +39,9 @@ async def handle(self, scope: Scope, receive: Receive, send: Send):
         request = Request(scope=scope, receive=receive)
         root_value = await self.get_root_value(request)
 
-        sub_response = Response(
-            content=None,
-            status_code=None,  # type: ignore
-            headers=None,
-            media_type=None,
-            background=None,
-        )
+        sub_response = Response()
+        sub_response.status_code = None  # type: ignore
+        del sub_response.headers["content-length"]
 
         context = await self.get_context(request=request, response=sub_response)
 
diff --git a/strawberry/fastapi/router.py b/strawberry/fastapi/router.py
--- a/strawberry/fastapi/router.py
+++ b/strawberry/fastapi/router.py
@@ -251,7 +251,7 @@ def pick_preferred_protocol(self, ws: WebSocket) -> Optional[str]:
         intersection = set(protocols) & set(self.protocols)
         return min(
             intersection,
-            key=lambda i: protocols.index(i),  # type: ignore
+            key=lambda i: protocols.index(i),
             default=None,
         )
 
diff --git a/strawberry/types/info.py b/strawberry/types/info.py
--- a/strawberry/types/info.py
+++ b/strawberry/types/info.py
@@ -41,6 +41,7 @@ def field_nodes(self) -> List[FieldNode]:  # deprecated
             "`info.field_nodes` is deprecated, use `selected_fields` instead",
             DeprecationWarning,
         )
+
         return self._raw_info.field_nodes
 
     @cached_property


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -120,8 +120,7 @@ jobs:
   starlette-unit-tests:
     strategy:
       matrix:
-        # starlette: ["0.17.1", "0.18.0", "0.19.1", "0.20.0"]
-        starlette: ["0.17.1"]
+        starlette: ["0.17.1", "0.18.0", "0.19.1", "0.20.0"]
 
     name: Starlette ${{ matrix.starlette }}
     runs-on: ubuntu-latest
@@ -139,8 +138,8 @@ jobs:
       - run: poetry install
         if: steps.setup-python.outputs.cache-hit != 'true'
 
-      - name: Install django ${{ matrix.starlette }}
-        run: poetry add --python ^3.10 starlette@^${{ matrix.starlette }}
+      - name: Install starlette ${{ matrix.starlette }}
+        run: poetry run pip install starlette==${{ matrix.starlette }}
 
       - name: pytest
         run:
diff --git a/tests/asgi/conftest.py b/tests/asgi/conftest.py
--- a/tests/asgi/conftest.py
+++ b/tests/asgi/conftest.py
@@ -38,14 +38,12 @@ def graphql_client(test_client):
 
 
 def pytest_collection_modifyitems(config, items):
-    # automatically mark tests with 'starlette' if
-    # they are in the asgi or fastapi subfolder
+    # automatically mark tests with 'starlette' if they are in the asgi subfolder
 
     rootdir = pathlib.Path(config.rootdir)
 
     for item in items:
         rel_path = pathlib.Path(item.fspath).relative_to(rootdir)
-        p = str(rel_path)
 
-        if p.startswith("tests/asgi") or p.startswith("tests/fastapi"):
+        if str(rel_path).startswith("tests/asgi"):
             item.add_marker(pytest.mark.starlette)