strawberry
strawberry copied to clipboard
Allow empty sub-classes with pydantic-types
Allow the empty inheritance of classes with the pydantic-type decorator as discussed in #1533
Description
Currently, when trying to inherit from a class which was wrapped by strawberry.experimental.pydantic.type
or -.input
without any additional class variables with the strawberry.auto
-annotation, a strawberry.experimental.pydantic.exceptions.MissingFieldsListError
arises.
This PR allows the follwing code which would otherwise result in the abovementioned exception:
import strawberry
from strawberry import auto
from pydantic import BaseModel
class NoteModel(BaseModel):
confidential: str # do not expose via graphql
headline: str
text: str
@strawberry.experimental.pydantic.input(NoteModel)
class NoteInput:
headline: auto
text: auto
@strawberry.experimental.pydantic.type(NoteModel)
class Note(NoteInput):
pass
Completely empty types are still not allowed and would yield an error.
Types of Changes
- [ ] Core
- [x] Bugfix
- [ ] New feature
- [x] Enhancement/optimization
- [ ] Documentation
Issues Fixed or Closed by This PR
- Resolves #1533
Checklist
- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [x] I have read the CONTRIBUTING document.
- [x] I have added tests to cover my changes.
- [x] I have tested the changes and verified that they work and don't break anything (as well as I can manage).
Thanks for adding the RELEASE.md
file!
Here's a preview of the changelog:
Allow empty sub-classes with pydantic-types according to #1533.
Here's the preview release card for twitter:
Here's the tweet text:
🆕 Release (next) is out! Thanks to Moritz Bock for the PR 👏
Get it here 👉 https://github.com/strawberry-graphql/strawberry/releases/tag/(next)
Codecov Report
Merging #1620 (5d9111d) into main (f519299) will increase coverage by
0.00%
. The diff coverage is100.00%
.
:exclamation: Current head 5d9111d differs from pull request most recent head 80640f6. Consider uploading reports for the commit 80640f6 to get more accurate results
@@ Coverage Diff @@
## main #1620 +/- ##
=======================================
Coverage 98.14% 98.14%
=======================================
Files 129 129
Lines 4471 4472 +1
Branches 759 760 +1
=======================================
+ Hits 4388 4389 +1
Misses 43 43
Partials 40 40