10000 Fix #196 - handle ChoiceType initialized with Enum by thejcannon · Pull Request #197 · graphql-python/graphene-sqlalchemy · GitHub
[go: up one dir, main page]

Skip to content

Fix #196 - handle ChoiceType initialized with Enum #197

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

Closed
wants to merge 1 commit into from

Conversation

thejcannon
Copy link

No description provided.

@coveralls
Copy link
coveralls commented Apr 1, 2019

Coverage Status

Coverage increased (+0.09%) to 91.989% when pulling ea62496 on thejcannon:fix_196 into 1033de5 on graphql-python:master.

return Enum(name, type.choices, description=get_column_doc(column))
enum_members = getattr(type.choices, "__members__", None)
if enum_members: # Check if an enum.Enum is used
items = [(item.name, item.value) for item in enum_members.values()]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also return Enum.from_enum(type.choices).
I don't know enough about what the expected name/description should be to know which way is more correct.

@thejcannon
Copy link
Author

Closing. I'm going to post a new PR that'll fix this and #199 by modeling the code after convert_enum_to_enum

@thejcannon thejcannon closed this Apr 1, 2019
@thejcannon thejcannon reopened this Apr 2, 2019
@thejcannon
Copy link
Author

I reopened as #199 isn't seemingly an issue with this library.

@thejcannon
Copy link
Author

Closing again in lieu of new PR to fix enums in general

@thejcannon thejcannon closed this Apr 2, 2019
@squarewave24
Copy link

hello,
i came across this issue on graphene-sqlalchemy v2.2.2

TypeError: cannot unpack non-iterable ReviewStatusEnum object

on

status = Column(ChoiceType(ReviewStatusEnum, impl=Unicode()), nullable=False)

is there a trick to make this work?

@jnak
Copy link
Collaborator
jnak commented May 28, 2020

I'm not familiar with the issue but if you need a quick workaround, you should be able to define your own graphene field, enum and resolver.

@squarewave24
Copy link

actually it was resolved in latest pre-release version 2.3.* so i am testing that out now.

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.

4 participants
0