DjangoFormMutation does not generate enum from forms.ChoiceField
See original GitHub issue- What is the current behavior?
GEEKS_CHOICES =(("1", "One"), ("2", "Two"))
class UpdateUserStateInTradeForm(forms.Form):
state = forms.ChoiceField(choices=GEEKS_CHOICES)
# mutation
class UpdateUserStateInTradeMutation(DjangoFormMutation):
class Meta:
form_class = UpdateUserStateInTradeForm
# generated schema
state: String!
- What is the expected behavior?
state is enumeration
-
Please tell us about your environment:
- Version: 2.13.0, Django 3.0.1
- Platform: Linux
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
DjangoFormMutation does not generate enum from forms.ChoiceField
DjangoFormMutation does not generate enum from forms.ChoiceField. ... What is the current behavior? ... ChoiceField(choices=GEEKS_CHOICES) # mutation class ...
Read more >How to use enums as a choice field in django model
If a tuple is not provided, or the last item is not a (lazy) string, the label is automatically generated from the member...
Read more >Graphene Documentation - Read the Docs
Graphene-Django comes with mutation classes that will convert the fields on Django forms into inputs on a mutation. DjangoFormMutation from ...
Read more >graphene-django Changelog - PyUp.io
Do not access the internals of `SimpleLazyObject` by pcraciunoiu in ... Make v3 django choice field enum naming default (in v3) by DoctorJohn...
Read more >How to use the graphene.Enum function in graphene - Snyk
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
About this issue, can you guys let us know what’s the proper way to have Enums for a ChoiceField (or CharField with choices) for a DjangoFormMutation? It seems the bug is still there.
@artofhuman that’s a good point. In that case, check the following branch comparison:
https://github.com/graphql-python/graphene-django/compare/main...iorlandini:feature/form-choices-to-enum-conversion
I think it does the job! Just do not forget to use a Django
ModelForm
instead of aForm
because it needs a reference to the model: