Latest Results
Use parametrized generic models directly
Parametrizations of decorated generic models, like `Page[User]`, can now be
used directly, like generic Strawberry types: `-> Page[User]` is a GraphQL
type named after its arguments by the schema's name converter, `UserPage`.
Pydantic creates a subclass for each parametrization, which would inherit
the definition of the generic model. Instead, the generic model's definition
gives each parametrization one of its own the first time it's read, built
like the definition of a decorated subclass, so core's resolvers, unions and
interfaces see it without changes. Inputs and interfaces work too. A
subclass can still be decorated to give a parametrization a name of its
own, and decorating a parametrization itself raises an error.
Generic models that reference their own parametrizations, like a `Tree[T]`
with `children: list[Tree[T]]`, raise an error for now: Pydantic types
those fields with a placeholder that isn't public.
Shortcake-Parent: 2026-10-12-pydantic-type-mapping
Co-authored-by: Patrick Arminio <patrick.arminio@gmail.com>2026-10-17-pydantic-generic-models Raise an error for Pydantic serializers on output types
GraphQL resolves the fields of Pydantic types from the model's attributes,
not from `model_dump()`, so Pydantic's serializers were silently ignored,
including serializers that hide or redact values. Types and interfaces
whose GraphQL fields have serializers (`@field_serializer`,
`PlainSerializer` or `WrapSerializer`, also inside the type, like
`list[Annotated[str, PlainSerializer(...)]]`) or `Field(exclude_if=...)`,
or that have a `@model_serializer`, now raise an `IgnoredSerializerError`
when they're decorated.
Fields that aren't part of the GraphQL type, like `strawberry.Private`
ones, and inputs, which aren't serialized, can still have serializers.
`ignore_serializers=True` on `@strawberry.pydantic.type` and `.interface`
allows them, for models whose serializers are only meant for other uses,
like a REST API. Parametrizations of generic models use the option of
their generic model.
Failing closed also leaves room to apply serializers to GraphQL later,
without silently changing what existing schemas return.
Shortcake-Parent: 2026-10-17-pydantic-generic-models
Co-authored-by: Patrick Arminio <patrick.arminio@gmail.com>2026-10-17-pydantic-serializers Document and test the validators of Pydantic inputs
The docs cover field, model and functional validators, strict mode, model
config, and `TypeAdapter` and `RootModel` used in resolvers, which work
through the validation Pydantic already does for inputs.
The tests check what Strawberry adds to that validation: resolvers get the
values validators change, validator errors are located at the field or model
they validate, `before` validators receive the data keyed by Python names,
and GraphQL inputs work with `extra="forbid"` and with strict mode, which
only applies to values GraphQL doesn't check, like JSON scalars.
Shortcake-Parent: 2026-10-12-pydantic-input-defaults
Co-authored-by: Patrick Arminio <patrick.arminio@gmail.com>2026-10-12-pydantic-validation Latest Branches
0%
2026-10-17-pydantic-generic-models 0%
2026-10-17-pydantic-serializers 0%
2026-10-12-pydantic-input-defaults © 2026 CodSpeed Technology