Skip to content

Commit 5281e37

Browse files
committed
Release 🍓 0.289.6
1 parent 11e7115 commit 5281e37

File tree

3 files changed

+72
-67
lines changed

3 files changed

+72
-67
lines changed

CHANGELOG.md

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

4+
0.289.6 - 2026-01-26
5+
--------------------
6+
7+
This release adds support for field extensions in experimental pydantic types.
8+
9+
Previously, when using `@strawberry.experimental.pydantic.type()` decorator, field extensions defined with `strawberry.field(extensions=[...])` were not being propagated to the generated Strawberry fields. This meant extensions like authentication, caching, or result transformation couldn't be used with pydantic-based types.
10+
11+
This fix ensures that extensions are properly preserved when converting pydantic fields to Strawberry fields, enabling the full power of field extensions across the pydantic integration.
12+
13+
Examples:
14+
15+
**Permission-based field masking:**
16+
17+
```python
18+
from pydantic import BaseModel
19+
from typing import Optional
20+
import strawberry
21+
from strawberry.experimental.pydantic import type as pyd_type
22+
from strawberry.extensions.field_extension import FieldExtension
23+
24+
25+
class PermissionExtension(FieldExtension):
26+
def resolve(self, next_, source, info, **kwargs):
27+
# Check permission, return None if denied
28+
if not check_field_access(info.context.user, info.field_name, source.id):
29+
return None
30+
return next_(source, info, **kwargs)
31+
32+
33+
class UserModel(BaseModel):
34+
id: int
35+
fname: str
36+
email: str
37+
phone: str
38+
39+
40+
perm_ext = PermissionExtension()
41+
42+
43+
@pyd_type(model=UserModel)
44+
class UserGQL:
45+
# Public fields - just use auto
46+
id: strawberry.auto
47+
fname: strawberry.auto
48+
49+
# Protected fields - attach extension
50+
email: Optional[str] = strawberry.field(extensions=[perm_ext])
51+
phone: Optional[str] = strawberry.field(extensions=[perm_ext])
52+
```
53+
54+
**Basic transformation extension:**
55+
56+
```python
57+
class UpperCaseExtension(FieldExtension):
58+
def resolve(self, next_, source, info, **kwargs):
59+
result = next_(source, info, **kwargs)
60+
return str(result).upper()
61+
62+
63+
class ProductModel(BaseModel):
64+
name: str
65+
66+
67+
@pyd_type(model=ProductModel)
68+
class Product:
69+
name: str = strawberry.field(extensions=[UpperCaseExtension()])
70+
```
71+
72+
Contributed by [Srikanth](https://github.com/XChikuX) via [PR #4171](https://github.com/strawberry-graphql/strawberry/pull/4171/)
73+
74+
475
0.289.5 - 2026-01-25
576
--------------------
677

RELEASE.md

Lines changed: 0 additions & 66 deletions
This file was deleted.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "strawberry-graphql"
3-
version = "0.289.5"
3+
version = "0.289.6"
44
description = "A library for creating GraphQL APIs"
55
authors = [{ name = "Patrick Arminio", email = "[email protected]" }]
66
license = { text = "MIT" }

0 commit comments

Comments
 (0)