-
Notifications
You must be signed in to change notification settings - Fork 822
Correctly resolve Enum #879
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
This is a breaking change. @syrusakbary whats your policy on such changes? |
@avivey let's discuss how we can make this backward-compatible. |
What is needed for this to enter master? What is breaking about the change? |
@allardhoeve the breaking change is that when . you have Enum arguments you'll now get the enum and not its value.
What you're getting in graphene now wuld be We'll work to figure out how to make this backward compatible (have a flag somewhere indicating new\old enum support) |
@ekampf now supports old form by default. |
@dschaller @avivey we could bundle this over the graphene3 release? |
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. |
ping |
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. |
I don't see an "open" button... maybe create a new branch from this commit
and create new pr?
…On Sat, Feb 15, 2020 at 12:06 AM Eran Kampf ***@***.***> wrote:
There's no way to reopen PRs? or is it a permission Im missing?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#879?email_source=notifications&email_token=AALVTAVSTHUQ55PLWG2HHELRC4IXLA5CNFSM4GK4ZS62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEL2SO5Y#issuecomment-586491767>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALVTAWUASZ3IEOZRBZMJSLRC4IXLANCNFSM4GK4ZS6Q>
.
|
See #877, #756, #444.
This changes introduces "new style enums" which are more natural to work with, having the value provided to the resolver is an enum value.
This only works with Python-Enum based enums (
graphene.Enum.from_enum()
) and is disabled by default (passlegacy_enum_resolver=False
to enable).There's still a bug with specifying default values to enum arguments, but that bug is in
graphql-core
, and there's no reasonable workaround ingraphene
for it. We'll needgraphql-core-next
to better handle enums.In part, this change reverts #446 for new-style enums. #446 added a custom
__eq__
to the underlying python-enum backing graphene-enums. Some magic in the Python stack expects that if you provide__eq__
you should also provide__hash__
(Which makes sense), rendering the resulting enum instances un-hashable.Since having
EnumInstance == EnumInstance.Value
doesn't make sense in a typed world (such as GraphQL), I prefer to remove this and resolve the underlying problem instead (provide resolvers with proper values).