2727from strawberry .types .base import WithStrawberryObjectDefinition
2828from strawberry .types .cast import get_strawberry_type_cast
2929from strawberry .types .field import StrawberryField
30+ from strawberry .types .maybe import _annotation_is_maybe # noqa: PLC2701
3031from strawberry .types .private import is_private
3132from strawberry .utils .deprecations import DeprecatedDescriptor
3233from typing_extensions import Self , dataclass_transform , get_annotations
@@ -165,18 +166,22 @@ def _process_type(
165166 # FIXME: For input types it is important to set the default value to UNSET
166167 # Is there a better way of doing this?
167168 if is_input :
169+ # For Maybe types, the default should be None (matching strawberry's behavior)
170+ # For other types, the default should be UNSET
171+ is_maybe = _annotation_is_maybe (annotation )
172+ default_value = None if is_maybe else UNSET
173+
168174 # First check if the field is defined in the class. If it is,
169- # then we just need to set its default value to UNSET in case
170- # it is MISSING
175+ # then we just need to set its default value in case it is MISSING
171176 if field_name in cls .__dict__ :
172177 field = cls .__dict__ [field_name ]
173178 if (
174179 isinstance (field , dataclasses .Field )
175180 and field .default is dataclasses .MISSING
176181 ):
177- field .default = UNSET
182+ field .default = default_value
178183 if isinstance (field , StrawberryField ):
179- field .default_value = UNSET
184+ field .default_value = default_value
180185
181186 continue
182187
@@ -185,12 +190,12 @@ def _process_type(
185190 if base_field is not None and isinstance (base_field , StrawberryField ):
186191 new_field = copy .copy (base_field )
187192 else :
188- new_field = _field (default = UNSET )
193+ new_field = _field (default = default_value )
189194
190195 cls_annotations [field_name ] = field_annotation .raw_annotation
191- new_field .default = UNSET
196+ new_field .default = default_value
192197 if isinstance (base_field , StrawberryField ):
193- new_field .default_value = UNSET
198+ new_field .default_value = default_value
194199
195200 setattr (cls , field_name , new_field )
196201
0 commit comments