Skip to content

Commit 3d97deb

Browse files
committed
Merge branch 'main' into kristjan/validate-in-task
2 parents e43aca8 + 56172dc commit 3d97deb

File tree

140 files changed

+4093
-3478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+4093
-3478
lines changed

.alexrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"execution",
1212
"special",
1313
"primitive",
14-
"invalid"
14+
"invalid",
15+
"crash"
1516
]
1617
}

.github/workflows/test.yml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ jobs:
2424
sessions: ${{ steps.set-matrix.outputs.sessions }}
2525
steps:
2626
- uses: actions/checkout@v4
27-
- run: pip install poetry nox nox-poetry
27+
- name: Install uv
28+
uses: astral-sh/setup-uv@v3
29+
- run: uv venv
30+
- run: uv pip install poetry nox nox-poetry
2831
- id: set-matrix
2932
shell: bash
3033
run: |
34+
. .venv/bin/activate
3135
echo sessions=$(
3236
nox --json -t tests -l |
3337
jq 'map(
@@ -57,20 +61,7 @@ jobs:
5761
3.10
5862
3.11
5963
3.12
60-
61-
- name: Pip and nox cache
62-
id: cache
63-
uses: actions/cache@v4
64-
with:
65-
path: |
66-
~/.cache
67-
~/.nox
68-
.nox
69-
key:
70-
${{ runner.os }}-nox-${{ matrix.session.session }}-${{ env.pythonLocation }}-${{
71-
hashFiles('**/poetry.lock') }}-${{ hashFiles('**/noxfile.py') }}
72-
restore-keys: |
73-
${{ runner.os }}-nox-${{ matrix.session.session }}-${{ env.pythonLocation }}
64+
3.13
7465
7566
- run: pip install poetry nox nox-poetry uv
7667
- run: nox -r -t tests -s "${{ matrix.session.session }}"
@@ -95,7 +86,9 @@ jobs:
9586

9687
benchmarks:
9788
name: 📈 Benchmarks
98-
runs-on: ubuntu-latest
89+
90+
# Using this version because CodSpeed doesn't support Ubuntu 24.04 LTS yet
91+
runs-on: ubuntu-22.04
9992

10093
steps:
10194
- uses: actions/checkout@v4
@@ -112,7 +105,7 @@ jobs:
112105
if: steps.setup-python.outputs.cache-hit != 'true'
113106

114107
- name: Run benchmarks
115-
uses: CodSpeedHQ/action@v2
108+
uses: CodSpeedHQ/action@v3
116109
with:
117110
token: ${{ secrets.CODSPEED_TOKEN }}
118111
run: poetry run pytest tests/benchmarks --codspeed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.6.3
3+
rev: v0.6.9
44
hooks:
55
- id: ruff-format
66
exclude: ^tests/\w+/snapshots/
@@ -20,7 +20,7 @@ repos:
2020
files: '^docs/.*\.mdx?$'
2121

2222
- repo: https://github.com/pre-commit/pre-commit-hooks
23-
rev: v4.6.0
23+
rev: v5.0.0
2424
hooks:
2525
- id: trailing-whitespace
2626
- id: check-merge-conflict
@@ -31,7 +31,7 @@ repos:
3131
args: ["--branch", "main"]
3232

3333
- repo: https://github.com/adamchainz/blacken-docs
34-
rev: 1.18.0
34+
rev: 1.19.0
3535
hooks:
3636
- id: blacken-docs
3737
args: [--skip-errors]

CHANGELOG.md

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,242 @@
11
CHANGELOG
22
=========
33

4+
0.246.2 - 2024-10-12
5+
--------------------
6+
7+
This release tweaks the Flask integration's `render_graphql_ide` method to be stricter typed internally, making type checkers ever so slightly happier.
8+
9+
Contributed by [Jonathan Ehwald](https://github.com/DoctorJohn) via [PR #3666](https://github.com/strawberry-graphql/strawberry/pull/3666/)
10+
11+
12+
0.246.1 - 2024-10-09
13+
--------------------
14+
15+
This release adds support for using raw Python enum types in your schema
16+
(enums that are not decorated with `@strawberry.enum`)
17+
18+
This is useful if you have enum types from other places in your code
19+
that you want to use in strawberry.
20+
i.e
21+
```py
22+
# somewhere.py
23+
from enum import Enum
24+
25+
26+
class AnimalKind(Enum):
27+
AXOLOTL, CAPYBARA = range(2)
28+
29+
30+
# gql/animals
31+
from somewhere import AnimalKind
32+
33+
34+
@strawberry.type
35+
class AnimalType:
36+
kind: AnimalKind
37+
```
38+
39+
Contributed by [ניר](https://github.com/nrbnlulu) via [PR #3639](https://github.com/strawberry-graphql/strawberry/pull/3639/)
40+
41+
42+
0.246.0 - 2024-10-07
43+
--------------------
44+
45+
The AIOHTTP, ASGI, and Django test clients' `asserts_errors` option has been renamed to `assert_no_errors` to better reflect its purpose.
46+
This change is backwards-compatible, but the old option name will raise a deprecation warning.
47+
48+
Contributed by [Jonathan Ehwald](https://github.com/DoctorJohn) via [PR #3661](https://github.com/strawberry-graphql/strawberry/pull/3661/)
49+
50+
51+
0.245.0 - 2024-10-07
52+
--------------------
53+
54+
This release removes the dated `subscriptions_enabled` setting from the Django and Channels integrations.
55+
Instead, WebSocket support is now enabled by default in all GraphQL IDEs.
56+
57+
Contributed by [Jonathan Ehwald](https://github.com/DoctorJohn) via [PR #3660](https://github.com/strawberry-graphql/strawberry/pull/3660/)
58+
59+
60+
0.244.1 - 2024-10-06
61+
--------------------
62+
63+
Fixes an issue where the codegen tool would crash when working with a nullable list of types.
64+
65+
Contributed by [Jacob Allen](https://github.com/enoua5) via [PR #3653](https://github.com/strawberry-graphql/strawberry/pull/3653/)
66+
67+
68+
0.244.0 - 2024-10-05
69+
--------------------
70+
71+
Starting with this release, WebSocket logic now lives in the base class shared between all HTTP integrations.
72+
This makes the behaviour of WebSockets much more consistent between integrations and easier to maintain.
73+
74+
Contributed by [Jonathan Ehwald](https://github.com/DoctorJohn) via [PR #3638](https://github.com/strawberry-graphql/strawberry/pull/3638/)
75+
76+
77+
0.243.1 - 2024-09-26
78+
--------------------
79+
80+
This releases adds support for Pydantic 2.9.0's Mypy plugin
81+
82+
Contributed by [Krisque](https://github.com/chrisemke) via [PR #3632](https://github.com/strawberry-graphql/strawberry/pull/3632/)
83+
84+
85+
0.243.0 - 2024-09-25
86+
--------------------
87+
88+
Starting with this release, multipart uploads are disabled by default and Strawberry Django view is no longer implicitly exempted from Django's CSRF protection.
89+
Both changes relieve users from implicit security implications inherited from the GraphQL multipart request specification which was enabled in Strawberry by default.
90+
91+
These are breaking changes if you are using multipart uploads OR the Strawberry Django view.
92+
Migrations guides including further information are available on the Strawberry website.
93+
94+
Contributed by [Jonathan Ehwald](https://github.com/DoctorJohn) via [PR #3645](https://github.com/strawberry-graphql/strawberry/pull/3645/)
95+
96+
97+
0.242.0 - 2024-09-19
98+
--------------------
99+
100+
Starting with this release, clients using the legacy graphql-ws subprotocol will receive an error when they try to send binary data frames.
101+
Before, binary data frames were silently ignored.
102+
103+
While vaguely defined in the protocol, the legacy graphql-ws subprotocol is generally understood to only support text data frames.
104+
105+
Contributed by [Jonathan Ehwald](https://github.com/DoctorJohn) via [PR #3633](https://github.com/strawberry-graphql/strawberry/pull/3633/)
106+
107+
108+
0.241.0 - 2024-09-16
109+
--------------------
110+
111+
You can now configure your schemas to provide a custom subclass of
112+
`strawberry.types.Info` to your types and queries.
113+
114+
```py
115+
import strawberry
116+
from strawberry.schema.config import StrawberryConfig
117+
118+
from .models import ProductModel
119+
120+
121+
class CustomInfo(strawberry.Info):
122+
@property
123+
def selected_group_id(self) -> int | None:
124+
"""Get the ID of the group you're logged in as."""
125+
return self.context["request"].headers.get("Group-ID")
126+
127+
128+
@strawberry.type
129+
class Group:
130+
id: strawberry.ID
131+
name: str
132+
133+
134+
@strawberry.type
135+
class User:
136+
id: strawberry.ID
137+
name: str
138+
group: Group
139+
140+
141+
@strawberry.type
142+
class Query:
143+
@strawberry.field
144+
def user(self, id: strawberry.ID, info: CustomInfo) -> Product:
145+
kwargs = {"id": id, "name": ...}
146+
147+
if info.selected_group_id is not None:
148+
# Get information about the group you're a part of, if
149+
# available.
150+
kwargs["group"] = ...
151+
152+
return User(**kwargs)
153+
154+
155+
schema = strawberry.Schema(
156+
Query,
157+
config=StrawberryConfig(info_class=CustomInfo),
158+
)
159+
```
160+
161+
Contributed by [Ethan Henderson](https://github.com/parafoxia) via [PR #3592](https://github.com/strawberry-graphql/strawberry/pull/3592/)
162+
163+
164+
0.240.4 - 2024-09-13
165+
--------------------
166+
167+
This release fixes how we check for multipart subscriptions to be
168+
in line with the latest changes in the spec.
169+
170+
Contributed by [Patrick Arminio](https://github.com/patrick91) via [PR #3627](https://github.com/strawberry-graphql/strawberry/pull/3627/)
171+
172+
173+
0.240.3 - 2024-09-12
174+
--------------------
175+
176+
This release fixes an issue that prevented extensions to receive the result from
177+
the execution context when executing operations in async.
178+
179+
Contributed by [ניר](https://github.com/nrbnlulu) via [PR #3629](https://github.com/strawberry-graphql/strawberry/pull/3629/)
180+
181+
182+
0.240.2 - 2024-09-11
183+
--------------------
184+
185+
This release updates how we check for GraphQL core's version to remove a
186+
dependency on the `packaging` package.
187+
188+
Contributed by [Nicholas Bollweg](https://github.com/bollwyvl) via [PR #3622](https://github.com/strawberry-graphql/strawberry/pull/3622/)
189+
190+
191+
0.240.1 - 2024-09-11
192+
--------------------
193+
194+
This release adds support for Python 3.13 (which will be out soon!)
195+
196+
Contributed by [Patrick Arminio](https://github.com/patrick91) via [PR #3510](https://github.com/strawberry-graphql/strawberry/pull/3510/)
197+
198+
199+
0.240.0 - 2024-09-10
200+
--------------------
201+
202+
This release adds support for schema-extensions in subscriptions.
203+
204+
Here's a small example of how to use them (they work the same way as query and
205+
mutation extensions):
206+
207+
```python
208+
import asyncio
209+
from typing import AsyncIterator
210+
211+
import strawberry
212+
from strawberry.extensions.base_extension import SchemaExtension
213+
214+
215+
@strawberry.type
216+
class Subscription:
217+
@strawberry.subscription
218+
async def notifications(self, info: strawberry.Info) -> AsyncIterator[str]:
219+
for _ in range(3):
220+
yield "Hello"
221+
222+
223+
class MyExtension(SchemaExtension):
224+
async def on_operation(self):
225+
# This would run when the subscription starts
226+
print("Subscription started")
227+
yield
228+
# The subscription has ended
229+
print("Subscription ended")
230+
231+
232+
schema = strawberry.Schema(
233+
query=Query, subscription=Subscription, extensions=[MyExtension]
234+
)
235+
```
236+
237+
Contributed by [ניר](https://github.com/nrbnlulu) via [PR #3554](https://github.com/strawberry-graphql/strawberry/pull/3554/)
238+
239+
4240
0.239.2 - 2024-09-03
5241
--------------------
6242

docs/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ title: Strawberry docs
8989
- [Sanic](./integrations/sanic.md)
9090
- [Chalice](./integrations/chalice.md)
9191
- [Starlette](./integrations/starlette.md)
92-
- [Starlite](./integrations/starlite.md)
9392
- [Litestar](./integrations/litestar.md)
9493
- [Creating an integration](./integrations/creating-an-integration.md)
9594
- [Pydantic **experimental**](./integrations/pydantic.md)

docs/breaking-changes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ title: List of breaking changes and deprecations
44

55
# List of breaking changes and deprecations
66

7+
- [Version 0.243.0 - 25 September 2024](./breaking-changes/0.243.0.md)
8+
- [Version 0.240.0 - 10 September 2024](./breaking-changes/0.240.0.md)
79
- [Version 0.236.0 - 17 July 2024](./breaking-changes/0.236.0.md)
810
- [Version 0.233.0 - 29 May 2024](./breaking-changes/0.233.0.md)
911
- [Version 0.217.0 - 18 December 2023](./breaking-changes/0.217.0.md)

docs/breaking-changes/0.240.0.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: 0.240.0 Breaking Changes
3+
slug: breaking-changes/0.240.0
4+
---
5+
6+
# v0.240.0 updates `Schema.subscribe`'s signature
7+
8+
In order to support schema extensions in subscriptions and errors that can be
9+
raised before the execution of the subscription, we had to update the signature
10+
of `Schema.subscribe`.
11+
12+
Previously it was:
13+
14+
```python
15+
async def subscribe(
16+
self,
17+
query: str,
18+
variable_values: Optional[Dict[str, Any]] = None,
19+
context_value: Optional[Any] = None,
20+
root_value: Optional[Any] = None,
21+
operation_name: Optional[str] = None,
22+
) -> Union[AsyncIterator[GraphQLExecutionResult], GraphQLExecutionResult]:
23+
```
24+
25+
Now it is:
26+
27+
```python
28+
async def subscribe(
29+
self,
30+
query: Optional[str],
31+
variable_values: Optional[Dict[str, Any]] = None,
32+
context_value: Optional[Any] = None,
33+
root_value: Optional[Any] = None,
34+
operation_name: Optional[str] = None,
35+
) -> Union[AsyncGenerator[ExecutionResult, None], PreExecutionError]:
36+
```

0 commit comments

Comments
 (0)