-
Notifications
You must be signed in to change notification settings - Fork 766
Support formatting of enum choices #209
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
Conversation
1 similar comment
3 similar comments
this would be nice to have, and it fixes #67 |
bdc7189
to
f93251b
Compare
Like it! A test case for this scenario would be helpful for assuring that we don't break support in the future :) |
I've joined a new company and am not working on GraphQL nor on python anymore. Should I close the PR? |
While I think this would be nice to have, I'm worried about the dependence on django-enumfields. Comments like this lead me to worry hzdg/django-enumfields#96 |
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.
I think this PR, and the potentially related but possibly tangential #67, are indicative of a wider problem here. Issues I can see:
- Is there too much "magic" going on with enum conversion? Maybe not.
- Should choice fields really be represented as Enums?
- Should this be opt-in?
- Should the enum serialisation be clearer?
- Should the documentation around how to customise Django model/form field conversion be clearer?
I feel like this particular change is a patch fix that isn't really understandable why it fixes things. Tests, comments, documentation and a more generalised solution are one option, and this can become a feature we support in some way.
Alternatively, improving the behaviour we have, making it more understandable, more customisable, and easier to modify, could also be a better approach.
I'd like to tidy up some of the PRs, so if we still want to work on this let me know or I will close this in 1 week. |
I think the topic is still relevant though I'm not sure about the current PR. I faced the problem that the default (and not changable) behavoir is returning really weird things from ChoiceFields. For example "A_1" instead of the 1 is would expect. I monkey-patched the behavior so I could work with it but a configurable solution would be awesome. |
@GitRon good point, as this is discussed heavily in other issues I will close this as this PR alone doesn't cover all the issues. |
When using django_enumfields
field.choices
is a list of the enum 'constants' and their labels / names.convert_choice_name
renders the 'values' with str. This ok for normal choice values, but the string representation of pythonEnum
s follows the TypeName.VALUE format. This results in TYPENAME_VALUE formatted values for GraphQL queries, instead of VALUE (which I think it should be). This PR fixes that.