strawberry
strawberry copied to clipboard
Use dataclasses.MISSING for default value for default and default_factory
This PR changes the default for default and default_factory to dataclasses.MISSING to allow using UNSET as default when doing something like this:
@strawberry.input
class FilterInput:
in_: Optional[str] = strawberry.field(name="in", default=strawberry.UNSET)
I don't like the double checks we added for UNSERT and dataclasses.MISSING, maybe we can add a util function, or see if we can remove some of them.
I wanted to update the mypy plugin too, but it seem to trigger an unrelated error, so I'll avoid doing that for now :)
Codecov Report
Merging #2128 (49a92af) into main (1bb0328) will increase coverage by
0.01%. The diff coverage is100.00%.
Additional details and impacted files
@@ Coverage Diff @@
## main #2128 +/- ##
==========================================
+ Coverage 98.19% 98.21% +0.01%
==========================================
Files 162 162
Lines 6494 6496 +2
Branches 1447 1449 +2
==========================================
+ Hits 6377 6380 +3
+ Misses 58 57 -1
Partials 59 59
Thanks for adding the RELEASE.md file!

Here's a preview of the changelog:
This release fixes an issue that prevented using strawberry.field with
UNSET as the default value.
Here's the preview release card for twitter:

Here's the tweet text:
🆕 Release (next) is out! Thanks to @patrick91 for the PR 👏
Get it here 👉 https://github.com/strawberry-graphql/strawberry/releases/tag/(next)