This release improves schema-codegen for input types in two ways:
-
Nullable input fields now use
strawberry.Maybe[T | None], allowing them to
be omitted when constructing the input type. -
GraphQL default values on input fields are now generated as Python defaults.
Supported value types: integers, floats, strings, booleans, null, enums, and
lists. When a field also has a description (or other metadata), the default is
passed viastrawberry.field(description=..., default=...).
Before:
@strawberry.input
class CreateUserInput:
name: str
role: int | None # required – TypeError with {}
# default value "42" from schema was lostAfter:
@strawberry.input
class CreateUserInput:
name: str
role: strawberry.Maybe[int | None] = 42Releases contributed by @patrick91 via #4178