-
-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: skip empty choice value #687
fix: skip empty choice value #687
Conversation
Seems they are not supported by GraphQL
Reviewer's Guide by SourceryThis pull request fixes a bug where empty choice values in Django models were causing crashes when generating enums. The fix skips empty choice values during enum generation, aligning the behavior with Sequence diagram for enum generation with empty choice handlingsequenceDiagram
participant Django as Django Model Field
participant Resolver as Field Type Resolver
participant GraphQL as GraphQL Schema
Django->>Resolver: Get choices from model field
activate Resolver
loop For each choice
alt Choice value is empty
Resolver-->>Resolver: Skip empty choice
else Choice value is not empty
Resolver->>Resolver: Convert choice to GraphQL enum
Note right of Resolver: Clean name using regex
end
end
Resolver->>GraphQL: Return enum type
deactivate Resolver
Class diagram showing Choice model changesclassDiagram
class Choice {
<<TextChoices>>
+A: str
+B: str
+__empty__: str
+get_choices()
}
note for Choice "Empty choices are now skipped
during GraphQL enum generation"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @fabien-michel - I've reviewed your changes - here's some feedback:
Overall Comments:
- You've marked that this change requires documentation updates, but no documentation changes were made. Please update the documentation to reflect that empty choices are skipped in GraphQL enum generation.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #687 +/- ##
=======================================
Coverage 89.00% 89.01%
=======================================
Files 42 42
Lines 3821 3823 +2
=======================================
+ Hits 3401 3403 +2
Misses 420 420 ☔ View full report in Codecov by Sentry. |
Hmm, seems the problem is more than that. I'm not sure what to do here. |
Ty! :) |
Seems they are not supported by GraphQL
Having an empty choice make generate enum from choice feature crash, trying to use None as a string.
Description
The fix, for now, is to skip empty value, so the behavior is the same as
TextChoiceField
.It make the schema building pass, but sadly, data with an empty value will still fail with
Enum 'MyAutoGeneratedEnum' cannot represent value: ''
and I'm note sure what to do with that.Types of Changes
Checklist
Summary by Sourcery
Bug Fixes: