strawberry
strawberry copied to clipboard
Bugfix: fix strawberry.enum_value handling
Description
Currently strawberry.enum_value causes errors. Here I add a test for the issue, a bugfix and some documentation about the way it works.
note: you cannot differ keys with the same value in a resolver. This is a limitation by python enum itself (uses singletons for values).
note: I recreate the Enum if an EnumValueDefinition instance is detected, otherwise it breaks the logic
Types of Changes
- [ ] Core
- [x] Bugfix
- [ ] New feature
- [ ] Enhancement/optimization
- [ ] Documentation
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:
Fix enum issues with strawberry.enum_value. BREAKING: When strawberry.enum_value is used the wrapped Enum is re-created.
Here's the preview release card for twitter:

Here's the tweet text:
🆕 Release (next) is out! Thanks to Alexander for the PR 👏
Get it here 👉 https://github.com/strawberry-graphql/strawberry/releases/tag/(next)
fixes #2174 proper.
Codecov Report
Merging #2179 (3d807c7) into main (23e2bd4) will decrease coverage by
0.02%. The diff coverage is100.00%.
Additional details and impacted files
@@ Coverage Diff @@
## main #2179 +/- ##
==========================================
- Coverage 98.22% 98.19% -0.03%
==========================================
Files 162 162
Lines 6466 6499 +33
Branches 1223 1237 +14
==========================================
+ Hits 6351 6382 +31
Misses 58 58
- Partials 57 59 +2