Skip to content

convert DRF ChoiceField to Enum #537

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

Merged
merged 7 commits into from
Sep 22, 2019
Merged

Conversation

zbyte64
Copy link
Collaborator

@zbyte64 zbyte64 commented Oct 18, 2018

This is to resolve #517 so that we use choices defined from DRF.

This also impacts FilePathField as it is technically a ChoiceField.

@coveralls
Copy link

coveralls commented Oct 18, 2018

Coverage Status

Coverage increased (+0.06%) to 92.779% when pulling 0050f8f on zbyte64:drf-choices into b0cba39 on graphql-python:master.

@zbyte64
Copy link
Collaborator Author

zbyte64 commented Oct 18, 2018

Tests do pass, but can't directly trigger a rebuild. For some reason the CI broke (seems rarely intermittent):

$ curl -sSf -o python-3.5.tar.bz2 ${archive_url}
curl: (56) SSL read: error:00000000:lib(0):func(0):reason(0), errno 104
Unable to download 3.5 archive. The archive may not exist. Please consider a different version.

@cowlicks
Copy link

cowlicks commented Feb 5, 2019

I hit this issue today. Is there a workaround you would recommend that will allow me to have a schema where enums are used for Django choice fields when using the serializer mutation?

@cowlicks
Copy link

cowlicks commented Feb 5, 2019

Ideally, there would be a way to override the defaults for the inputs and outputs.

@PeterDekkers
Copy link

@zbyte64 any chance this PR can be resurrected?

I'm using the workaround from #517. It would be great to have a built-in solution.

@zbyte64
Copy link
Collaborator Author

zbyte64 commented May 31, 2019

@cowlicks you can always redefine the field where you define your own DjangoObjectType

@zbyte64
Copy link
Collaborator Author

zbyte64 commented May 31, 2019

PR now converts multiple choices fields to list of enums.

Now the remaining question is whether it makes sense for FilePathField to be an enum. Choices may not be static as new directories could be added.

@stale
Copy link

stale bot commented Jul 30, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 30, 2019
@jkimbo
Copy link
Member

jkimbo commented Aug 4, 2019

@zbyte64 is this still a PR that you would like to see merged?

@stale stale bot removed the wontfix label Aug 4, 2019
@zbyte64
Copy link
Collaborator Author

zbyte64 commented Aug 5, 2019

This is still an issue and I still believe this is a valid way to address the issue. So yes, we should merge it...

@spockNinja spockNinja removed their request for review August 12, 2019 18:03
@jkimbo
Copy link
Member

jkimbo commented Sep 22, 2019

Merging this PR because it's been waiting around for ages.

@jkimbo jkimbo merged commit a64ba65 into graphql-python:master Sep 22, 2019
@overide
Copy link

overide commented Sep 30, 2020

@zbyte64 Can you direct me to the example where I see this change in action? I tried it but didn't work, maybe I didn't understand it correctly. I'm using v2.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reuse enum type of choices in serializer mutation
6 participants