diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fef6d85ea3..1c8730076c 100644 --- 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/RELEASE.md b/RELEASE.md new file mode 100644 index 0000000000..f74230bb71 --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,7 @@ +Release type: minor + +This release adds support for Starlette 0.18 to 0.20 + +It also removes upper bound dependencies limit for starlette, +allowing you to install the latest version without having to +wait for a new release of Strawberry diff --git a/poetry.lock b/poetry.lock index 3ba4bc078c..fd356c1173 100644 --- a/poetry.lock +++ b/poetry.lock @@ -357,7 +357,7 @@ python-versions = "*" [[package]] name = "fastapi" -version = "0.70.1" +version = "0.76.0" description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production" category = "main" optional = false @@ -365,13 +365,13 @@ python-versions = ">=3.6.1" [package.dependencies] pydantic = ">=1.6.2,<1.7 || >1.7,<1.7.1 || >1.7.1,<1.7.2 || >1.7.2,<1.7.3 || >1.7.3,<1.8 || >1.8,<1.8.1 || >1.8.1,<2.0.0" -starlette = "0.16.0" +starlette = "0.18.0" [package.extras] -all = ["requests (>=2.24.0,<3.0.0)", "jinja2 (>=2.11.2,<4.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "itsdangerous (>=1.1.0,<3.0.0)", "pyyaml (>=5.3.1,<6.0.0)", "ujson (>=4.0.1,<5.0.0)", "orjson (>=3.2.1,<4.0.0)", "email_validator (>=1.1.1,<2.0.0)", "uvicorn[standard] (>=0.12.0,<0.16.0)"] -dev = ["python-jose[cryptography] (>=3.3.0,<4.0.0)", "passlib[bcrypt] (>=1.7.2,<2.0.0)", "autoflake (>=1.4.0,<2.0.0)", "flake8 (>=3.8.3,<4.0.0)", "uvicorn[standard] (>=0.12.0,<0.16.0)"] -doc = ["mkdocs (>=1.1.2,<2.0.0)", "mkdocs-material (>=7.1.9,<8.0.0)", "mdx-include (>=1.4.1,<2.0.0)", "mkdocs-markdownextradata-plugin (>=0.1.7,<0.3.0)", "typer-cli (>=0.0.12,<0.0.13)", "pyyaml (>=5.3.1,<6.0.0)"] -test = ["pytest (>=6.2.4,<7.0.0)", "pytest-cov (>=2.12.0,<4.0.0)", "mypy (==0.910)", "flake8 (>=3.8.3,<4.0.0)", "black (==21.9b0)", "isort (>=5.0.6,<6.0.0)", "requests (>=2.24.0,<3.0.0)", "httpx (>=0.14.0,<0.19.0)", "email_validator (>=1.1.1,<2.0.0)", "sqlalchemy (>=1.3.18,<1.5.0)", "peewee (>=3.13.3,<4.0.0)", "databases[sqlite] (>=0.3.2,<0.6.0)", "orjson (>=3.2.1,<4.0.0)", "ujson (>=4.0.1,<5.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "flask (>=1.1.2,<3.0.0)", "anyio[trio] (>=3.2.1,<4.0.0)", "types-ujson (==0.1.1)", "types-orjson (==3.6.0)", "types-dataclasses (==0.1.7)"] +all = ["requests (>=2.24.0,<3.0.0)", "jinja2 (>=2.11.2,<4.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "itsdangerous (>=1.1.0,<3.0.0)", "pyyaml (>=5.3.1,<7.0.0)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0,<6.0.0)", "orjson (>=3.2.1,<4.0.0)", "email_validator (>=1.1.1,<2.0.0)", "uvicorn[standard] (>=0.12.0,<0.18.0)"] +dev = ["python-jose[cryptography] (>=3.3.0,<4.0.0)", "passlib[bcrypt] (>=1.7.2,<2.0.0)", "autoflake (>=1.4.0,<2.0.0)", "flake8 (>=3.8.3,<4.0.0)", "uvicorn[standard] (>=0.12.0,<0.18.0)"] +doc = ["mkdocs (>=1.1.2,<2.0.0)", "mkdocs-material (>=8.1.4,<9.0.0)", "mdx-include (>=1.4.1,<2.0.0)", "mkdocs-markdownextradata-plugin (>=0.1.7,<0.3.0)", "typer (>=0.4.1,<0.5.0)", "pyyaml (>=5.3.1,<7.0.0)"] +test = ["pytest (>=6.2.4,<7.0.0)", "pytest-cov (>=2.12.0,<4.0.0)", "mypy (==0.910)", "flake8 (>=3.8.3,<4.0.0)", "black (==22.3.0)", "isort (>=5.0.6,<6.0.0)", "requests (>=2.24.0,<3.0.0)", "httpx (>=0.14.0,<0.19.0)", "email_validator (>=1.1.1,<2.0.0)", "sqlalchemy (>=1.3.18,<1.5.0)", "peewee (>=3.13.3,<4.0.0)", "databases[sqlite] (>=0.3.2,<0.6.0)", "orjson (>=3.2.1,<4.0.0)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0,<6.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "flask (>=1.1.2,<3.0.0)", "anyio[trio] (>=3.2.1,<4.0.0)", "types-ujson (==4.2.1)", "types-orjson (==3.6.2)", "types-dataclasses (==0.6.5)"] [[package]] name = "filelock" @@ -1244,7 +1244,7 @@ python-versions = ">=3.5" [[package]] name = "starlette" -version = "0.16.0" +version = "0.18.0" description = "The little ASGI library that shines." category = "main" optional = false @@ -1252,10 +1252,10 @@ python-versions = ">=3.6" [package.dependencies] anyio = ">=3.0.0,<4" -typing-extensions = {version = "*", markers = "python_version < \"3.8\""} +typing-extensions = {version = "*", markers = "python_version < \"3.10\""} [package.extras] -full = ["itsdangerous", "jinja2", "python-multipart", "pyyaml", "requests", "graphene"] +full = ["itsdangerous", "jinja2", "python-multipart", "pyyaml", "requests"] [[package]] name = "testfixtures" @@ -1538,7 +1538,7 @@ sanic = ["sanic"] [metadata] lock-version = "1.1" python-versions = "^3.7" -content-hash = "af82d5643a95bb51c6ad9086fc3979dd9362bb0ca5b5160801616f79f25c6393" +content-hash = "0602fe5053113b31cddd218b3754d0218ebe8578f559a6fc4a3e70e1687061a3" [metadata.files] aiofiles = [ @@ -1788,8 +1788,8 @@ eradicate = [ {file = "eradicate-2.1.0.tar.gz", hash = "sha256:aac7384ab25b1bf21c4c012de9b4bf8398945a14c98c911545b2ea50ab558014"}, ] fastapi = [ - {file = "fastapi-0.70.1-py3-none-any.whl", hash = "sha256:5367226c7bcd7bfb2e17edaf225fd9a983095b1372281e9a3eb661336fb93748"}, - {file = "fastapi-0.70.1.tar.gz", hash = "sha256:21d03979b5336375c66fa5d1f3126c6beca650d5d2166fbb78345a30d33c8d06"}, + {file = "fastapi-0.76.0-py3-none-any.whl", hash = "sha256:1e05c868651e3935bd9b290c61a3661a54e37471d3a0700bc5e4380f9ed935ae"}, + {file = "fastapi-0.76.0.tar.gz", hash = "sha256:a5f99f6e827c7108a8efaf1d7f19d6cf2d735ad984f5e44d33ccec6ee88a7da1"}, ] filelock = [ {file = "filelock-3.7.0-py3-none-any.whl", hash = "sha256:c7b5fdb219b398a5b28c8e4c1893ef5f98ece6a38c6ab2c22e26ec161556fed6"}, @@ -2470,8 +2470,8 @@ sqlparse = [ {file = "sqlparse-0.4.2.tar.gz", hash = "sha256:0c00730c74263a94e5a9919ade150dfc3b19c574389985446148402998287dae"}, ] starlette = [ - {file = "starlette-0.16.0-py3-none-any.whl", hash = "sha256:38eb24bf705a2c317e15868e384c1b8a12ca396e5a3c3a003db7e667c43f939f"}, - {file = "starlette-0.16.0.tar.gz", hash = "sha256:e1904b5d0007aee24bdd3c43994be9b3b729f4f58e740200de1d623f8c3a8870"}, + {file = "starlette-0.18.0-py3-none-any.whl", hash = "sha256:377d64737a0e03560cb8eaa57604afee143cea5a4996933242798a7820e64f53"}, + {file = "starlette-0.18.0.tar.gz", hash = "sha256:b45c6e9a617ecb5caf7e6446bd8d767b0084d6217e8e1b08187ca5191e10f097"}, ] testfixtures = [ {file = "testfixtures-6.18.5-py2.py3-none-any.whl", hash = "sha256:7de200e24f50a4a5d6da7019fb1197aaf5abd475efb2ec2422fdcf2f2eb98c1d"}, diff --git a/pyproject.toml b/pyproject.toml index 6603bd7353..e8970eb42b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ build-backend = "poetry.masonry.api" [tool.poetry.dependencies] python = "^3.7" -starlette = {version = ">=0.13.6,<0.17.0", optional = true} +starlette = {version = ">=0.13.6", optional = true} click = {version = ">=7.0,<9.0", optional = true} pygments = "^2.3" uvicorn = {version = ">=0.11.6,<0.18.0", optional = true} @@ -76,8 +76,8 @@ flake8-black = "^0.3" Django = ">=3.2" pydantic = {version = "<2", optional = false} email-validator = {version = "^1.1.3", optional = false} -starlette = ">=0.13.6,<0.17.0" -uvicorn = ">=0.11.6,<0.18.0" +uvicorn = ">=0.11.6" +starlette = ">=0.13.6" sanic = ">=20.12.2,<22.0.0" aiohttp = "^3.7.4.post0" pytest-aiohttp = "^1.0.3" diff --git a/strawberry/asgi/handlers/http_handler.py b/strawberry/asgi/handlers/http_handler.py index 2b3c808fd4..3e1fef71da 100644 --- 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 index baaccc6b32..4f7f4e6d6d 100644 --- 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 index 3c8d3840b6..a172c04aa1 100644 --- 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 diff --git a/tests/asgi/conftest.py b/tests/asgi/conftest.py index 6f97e6633c..de8cd8a279 100644 --- 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)