-
Notifications
You must be signed in to change notification settings - Fork 769
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
Convert MultipleChoiceField to List of type String #611
Conversation
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.
Is this a breaking change?
@phalt yes, it does change the way MultipleChoiceFilter is resolved in graphql (from simple string to list of strings), however resolving to string is a bug. It is possible that by fixing this bug, some existing queries in the wild will change from simply not working as intended to returning a proper error (because those queries would now be in violation of the schema) e.g. Let's say you have a filter defined like so:
And you wanted to use this filter in a query. Since the MultipleChoiceField is resolved to string type, schema expects something like the following:
However this will not work, because the MultipleChoiceField expects a list or tuple:
If we make MultipleChoiceField resolve to list of strings then our original query can change to:
or if we want to choose multiple options:
This will now work with the underlying MultipleChoiceField |
I guess we should either document the change as part of release notes, or implement a deprecation warning so we don't break projects that are using the current behaviour without realizing it is wrong? |
I think I would prefer the documentation option. Any ideas how to proceed with that? |
@kimbriancanavan looking at previous releases we have updated the documentation or written "migration paths" - code examples of before / after to help people update. |
What is our versioning strategy with backwards incompatible changes? |
@zbyte64 semver.org I guess. We've done major upgrades in the past with breaking changes, and we've written migration documents to handle it. |
I came across this bug just now! |
Since there's a breaking change here, let's hold off until we're ready for v3. I think it'd be best to do this once graphene hits v3 which should be by the end of the month. |
In other places we are converting choices into enums, but here we are not. I also wonder if |
@phalt Stacked with that bug now. Will it be finally merged or appeared with a new graphene version? |
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. |
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. |
Thanks for the contribution @kimbriancanavan ! |
Is there a workaround for this in the meantime, or do we have to wait for v3 to be released? |
The django_filters.MultipleChoiceFilter is currently being converted to a String (due to MultipleChoiceFilter eventually inheriting from django.forms.fields.ChoiceField).
This PR changes that behavior so that it instead gets converted into a List of type String.