Skip to content

Commit f0f092b

Browse files
committed
Merge branch 'main' into issue-3998
2 parents d0bf71e + 043d685 commit f0f092b

36 files changed

+738
-249
lines changed

CHANGELOG.md

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

4+
0.285.0 - 2025-11-10
5+
--------------------
6+
7+
This release removes support for Apollo Federation v1 and improves Federation v2 support with explicit version control and new directives.
8+
9+
## Breaking Changes
10+
11+
- **Removed support for Apollo Federation v1**: All schemas now use Federation v2
12+
- **Removed `enable_federation_2` parameter**: Replaced with `federation_version` parameter
13+
- Federation v2 is now always enabled with version 2.11 as the default
14+
15+
## Migration
16+
17+
### If you were using `enable_federation_2=True`
18+
19+
Remove the parameter:
20+
21+
```python
22+
# Before
23+
schema = strawberry.federation.Schema(query=Query, enable_federation_2=True)
24+
25+
# After
26+
schema = strawberry.federation.Schema(query=Query)
27+
```
28+
29+
### If you were using Federation v1
30+
31+
You must migrate to Federation v2. See the [breaking changes documentation](https://strawberry.rocks/docs/breaking-changes/0.285.0) for detailed migration instructions.
32+
33+
## New Features
34+
35+
- **Version control**: Specify Federation v2 versions (2.0 - 2.11):
36+
37+
```python
38+
schema = strawberry.federation.Schema(
39+
query=Query, federation_version="2.5" # Specify a specific version if needed
40+
)
41+
```
42+
43+
- **New directives**: Added support for `@context`, `@fromContext`, `@cost`, and `@listSize` directives (v2.7+)
44+
- **Automatic validation**: Ensures directives are compatible with your chosen federation version
45+
- **Improved performance**: Faster version parsing using dictionary lookups
46+
47+
Contributed by [Patrick Arminio](https://github.com/patrick91) via [PR #4045](https://github.com/strawberry-graphql/strawberry/pull/4045/)
48+
49+
50+
0.284.4 - 2025-11-10
51+
--------------------
52+
53+
Bumped minimum Typer version to fix strawberry CLI commands.
54+
55+
Contributed by [Val Liu](https://github.com/valliu) via [PR #4049](https://github.com/strawberry-graphql/strawberry/pull/4049/)
56+
57+
58+
0.284.3 - 2025-11-10
59+
--------------------
60+
61+
Removed `Transfer-Encoding: chunked` header from multipart streaming responses. This fixes HTTP 405 errors on Vercel and other serverless platforms. The server/gateway will handle chunked encoding automatically when needed.
62+
63+
Contributed by [Louis Amon](https://github.com/LouisAmon) via [PR #4047](https://github.com/strawberry-graphql/strawberry/pull/4047/)
64+
65+
66+
0.284.2 - 2025-11-05
67+
--------------------
68+
69+
Update typing of `variables` in the test clients to match the actual flexibility of this field.
70+
71+
Contributed by [Ben XO](https://github.com/ben-xo) via [PR #4044](https://github.com/strawberry-graphql/strawberry/pull/4044/)
72+
73+
474
0.284.1 - 2025-10-18
575
--------------------
676

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.285.0 - 10 November 2025](./breaking-changes/0.285.0.md)
8+
- [Version 0.285.0 - 6 October 2025](./breaking-changes/0.283.0.md)
79
- [Version 0.279.0 - 19 August 2025](./breaking-changes/0.279.0.md)
810
- [Version 0.278.1 - 5 August 2025](./breaking-changes/0.278.1.md)
911
- [Version 0.268.0 - 10 May 2025](./breaking-changes/0.268.0.md)

docs/breaking-changes/0.285.0.md

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
---
2+
title: 0.285.0 Breaking Changes
3+
slug: breaking-changes/0.285.0
4+
---
5+
6+
# v0.285.0 Breaking Changes
7+
8+
This release removes support for Apollo Federation v1 and updates the federation
9+
API to always use Federation v2.
10+
11+
## What Changed
12+
13+
The `enable_federation_2` parameter has been removed and replaced with
14+
`federation_version`. Federation v2 is now always enabled, with version 2.11 as
15+
the default.
16+
17+
```python
18+
# Before (0.284.x and earlier)
19+
schema = strawberry.federation.Schema(
20+
query=Query, enable_federation_2=True # Opt-in to Federation 2
21+
)
22+
23+
# After (0.285.0+)
24+
schema = strawberry.federation.Schema(
25+
query=Query, federation_version="2.11" # Defaults to "2.11", always Federation 2
26+
)
27+
```
28+
29+
## Impact on Your Code
30+
31+
### Federation v2 Users
32+
33+
If you were already using `enable_federation_2=True`, you can remove that
34+
parameter:
35+
36+
```python
37+
# Before
38+
schema = strawberry.federation.Schema(query=Query, enable_federation_2=True)
39+
40+
# After
41+
schema = strawberry.federation.Schema(query=Query)
42+
```
43+
44+
Your schemas will continue to work without changes and will now default to
45+
Federation v2.11.
46+
47+
### Federation v1 Users
48+
49+
If you were using Federation v1 (without `enable_federation_2`), you **must**
50+
migrate to Federation v2. Apollo Federation v1 is no longer supported by
51+
Strawberry.
52+
53+
Federation v2 provides better schema composition and additional features. Most
54+
v1 schemas can be migrated with minimal changes:
55+
56+
```python
57+
# Before (Federation v1)
58+
schema = strawberry.federation.Schema(query=Query)
59+
60+
# After (Federation v2)
61+
schema = strawberry.federation.Schema(query=Query) # Now uses v2.11
62+
```
63+
64+
Key differences in Federation v2:
65+
66+
1. **No `extend` keyword needed**: Types no longer need to be marked as
67+
extensions
68+
2. **No `@external` required**: The `@key` directive alone is sufficient in most
69+
cases
70+
3. **`@shareable` directive**: Use this to indicate fields that can be resolved
71+
by multiple subgraphs
72+
4. **`@link` directive**: Automatically added to declare federation spec version
73+
74+
See the
75+
[Apollo Federation v2 migration guide](https://www.apollographql.com/docs/federation/federation-2/moving-to-federation-2/)
76+
for more details.
77+
78+
## Specifying Federation Version
79+
80+
You can now specify which Federation v2 version to use:
81+
82+
```python
83+
schema = strawberry.federation.Schema(
84+
query=Query, federation_version="2.5" # Use a specific version
85+
)
86+
```
87+
88+
Supported versions: 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 2.10, 2.11
89+
90+
This is useful if you need to ensure compatibility with a specific Apollo Router
91+
or Gateway version, or if you want to avoid using newer directives.
92+
93+
### Version Validation
94+
95+
Strawberry validates that directives are compatible with your chosen federation
96+
version:
97+
98+
```python
99+
from strawberry.federation.schema_directives import Cost
100+
101+
102+
@strawberry.federation.type
103+
class Product:
104+
name: str = strawberry.federation.field(
105+
directives=[Cost(weight=10)] # Requires v2.9+
106+
)
107+
108+
109+
# This will raise an error because @cost requires v2.9+
110+
schema = strawberry.federation.Schema(
111+
query=Query, federation_version="2.5" # Too old for @cost
112+
)
113+
```
114+
115+
## Why This Change?
116+
117+
1. **Apollo Federation v1 is deprecated**: Apollo has moved to Federation v2 as
118+
the standard
119+
2. **Simpler API**: Removes the boolean flag in favor of explicit version
120+
control
121+
3. **Better features**: Federation v2 provides improved schema composition and
122+
new directives
123+
4. **Version control**: Users can now specify exact federation versions for
124+
compatibility
125+
126+
## Migration Steps
127+
128+
### Step 1: Check Your Current Usage
129+
130+
If you're using `enable_federation_2=False` or not setting it at all, you're
131+
using Federation v1 and need to migrate.
132+
133+
### Step 2: Remove Federation v1 Code
134+
135+
```python
136+
# Remove this parameter
137+
schema = strawberry.federation.Schema(
138+
query=Query, enable_federation_2=True # Remove this line
139+
)
140+
```
141+
142+
### Step 3: Update Federation v1 Patterns
143+
144+
If you were using Federation v1 patterns like `extend=True` and explicit
145+
`@external` fields, you can simplify:
146+
147+
```python
148+
# Before (Federation v1)
149+
@strawberry.federation.type(keys=["id"], extend=True)
150+
class Product:
151+
id: strawberry.ID = strawberry.federation.field(external=True)
152+
reviews: list[Review]
153+
154+
155+
# After (Federation v2)
156+
@strawberry.federation.type(keys=["id"])
157+
class Product:
158+
id: strawberry.ID
159+
reviews: list[Review]
160+
```
161+
162+
### Step 4: Test Your Schema
163+
164+
Run your schema composition and tests to ensure everything works correctly with
165+
Federation v2.
166+
167+
## Need Help?
168+
169+
- See the [Federation guide](../guides/federation.md) for comprehensive usage
170+
examples
171+
- Review the
172+
[Apollo Federation v2 documentation](https://www.apollographql.com/docs/federation/federation-2/new-in-federation-2/)
173+
- If you encounter issues, please
174+
[report them on GitHub](https://github.com/strawberry-graphql/strawberry/issues)

docs/guides/federation.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,22 @@ class Query:
7070
all_books: List[Book] = strawberry.field(resolver=get_all_books)
7171

7272

73-
schema = strawberry.federation.Schema(query=Query, enable_federation_2=True)
73+
schema = strawberry.federation.Schema(query=Query)
7474
```
7575

7676
<Note>
7777

78-
`enable_federation_2=True` is used to enable Apollo Federation 2 and currently
79-
defaults to `False`. This will change in a future version of Strawberry.
78+
Strawberry supports Apollo Federation 2 only. By default, schemas use Federation
79+
version 2.11 (the latest supported version). You can specify a different version
80+
if needed:
81+
82+
```python
83+
schema = strawberry.federation.Schema(
84+
query=Query, federation_version="2.5" # Specify a specific version if needed
85+
)
86+
```
87+
88+
Supported versions: 2.0 - 2.11
8089

8190
</Note>
8291

@@ -142,9 +151,7 @@ class Query:
142151
_hi: str = strawberry.field(resolver=lambda: "Hello World!")
143152

144153

145-
schema = strawberry.federation.Schema(
146-
query=Query, types=[Book, Review], enable_federation_2=True
147-
)
154+
schema = strawberry.federation.Schema(query=Query, types=[Book, Review])
148155
```
149156

150157
Now things are looking more interesting; the `Review` type is a GraphQL type
@@ -327,7 +334,7 @@ Strawberry and Federation. The repo is available here:
327334

328335
Strawberry provides implementations for
329336
[Apollo federation-specific GraphQL directives](https://www.apollographql.com/docs/federation/federated-types/federated-directives/)
330-
up to federation spec v2.7.
337+
up to federation spec v2.11.
331338

332339
Some of these directives may not be necessary to directly include in your code,
333340
and are accessed through other means.
@@ -376,7 +383,7 @@ Will result in the following GraphQL schema:
376383
```graphql
377384
schema
378385
@link(
379-
url: "https://specs.apollo.dev/federation/v2.7"
386+
url: "https://specs.apollo.dev/federation/v2.11"
380387
import: ["@key", "@inaccessible", "@shareable", "@tag"]
381388
) {
382389
query: Query

federation-compatibility/schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,5 +309,5 @@ def deprecated_product(self, sku: str, package: str) -> DeprecatedProduct | None
309309

310310

311311
schema = strawberry.federation.Schema(
312-
query=Query, enable_federation_2=True, types=[Inventory]
312+
query=Query, types=[Inventory], federation_version="2.7"
313313
)

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "strawberry-graphql"
3-
version = "0.284.1"
3+
version = "0.285.0"
44
description = "A library for creating GraphQL APIs"
55
authors = [{ name = "Patrick Arminio", email = "[email protected]" }]
66
license = { text = "MIT" }
@@ -45,7 +45,7 @@ debug-server = [
4545
"uvicorn>=0.11.6",
4646
"websockets>=15.0.1,<16",
4747
"python-multipart>=0.0.7",
48-
"typer>=0.7.0",
48+
"typer>=0.12.4",
4949
"pygments~=2.3",
5050
"rich>=12.0.0",
5151
"libcst",
@@ -60,7 +60,7 @@ sanic = ["sanic>=20.12.2"]
6060
fastapi = ["fastapi>=0.65.2", "python-multipart>=0.0.7"]
6161
chalice = ["chalice~=1.22"]
6262
cli = [
63-
"typer>=0.7.0",
63+
"typer>=0.12.4",
6464
"pygments~=2.3",
6565
"rich>=12.0.0",
6666
"libcst",
@@ -97,7 +97,7 @@ dev = [
9797
"python-multipart (>=0.0.7)",
9898
"rich (>=12.5.1)",
9999
"sanic-testing (>=22.9,<24.0)",
100-
"typer (>=0.7.0)",
100+
"typer (>=0.12.4)",
101101
"types-aiofiles (>=24.1.0.20250326,<25.0.0.0)",
102102
"types-certifi (>=2021.10.8,<2022.0.0)",
103103
"types-chardet (>=5.0.4,<6.0.0)",
@@ -225,6 +225,8 @@ src = ["strawberry", "tests"]
225225
[tool.ruff.lint]
226226
select = ["ALL"]
227227
ignore = [
228+
# × this should be fine to use :)
229+
"RUF002",
228230
# we use asserts in tests and to hint mypy
229231
"S101",
230232

strawberry/aiohttp/test/client.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
from __future__ import annotations
22

33
import warnings
4-
from typing import (
5-
TYPE_CHECKING,
6-
Any,
7-
)
4+
from typing import Any
85

96
from strawberry.test.client import BaseGraphQLTestClient, Response
107

11-
if TYPE_CHECKING:
12-
from collections.abc import Mapping
13-
148

159
class GraphQLTestClient(BaseGraphQLTestClient):
1610
async def query(
1711
self,
1812
query: str,
19-
variables: dict[str, Mapping] | None = None,
13+
variables: dict[str, Any] | None = None,
2014
headers: dict[str, object] | None = None,
2115
asserts_errors: bool | None = None,
2216
files: dict[str, object] | None = None,

0 commit comments

Comments
 (0)