Skip to content

Fix for enum type duplication in graphene schema #165

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

hoffrocket
Copy link

The converter code was created a new type for each Enum column that it
encountered. The problem is where the same Enum type is used for
multiple columns. In that case graphene will notice two schema types
with the same underlying name and throw an Assertion error like:

AssertionError: Found different types with the same name in the schema: pet_kind, pet_kind.

This fix creates a new registry dict for storing a type.name to Enum
mapping that allows for reuse.

The converter code was created a new type for each Enum column that it
encountered. The problem is where the same Enum type is used for
multiple columns. In that case graphene will notice two schema types
with the same underlying name and throw an Assertion error like:

AssertionError: Found different types with the same name in the schema: pet_kind, pet_kind.

This fix creates a new registry dict for storing a type.name to Enum
mapping that allows for reuse.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 92.12% when pulling 890b6d5 on hoffrocket:dupenums into 33d5b74 on graphql-python:master.

@hoffrocket
Copy link
Author

I notice that there are some other outstanding PRs that address this issue in addition to some other problems with enums. Any reason those other changes haven't been merged? Would love to find something to address this. Currently have a workaround in place that registers a this solution using @convert_sqlalchemy_type.register(sqlalchemy.types.Enum)

@Nabellaleen
Copy link
Collaborator

Hi @hoffrocket !

graphene-sqlalchemy maintainer team is now alive ! Could you rebase and resolve conflicts ? :)

@Nabellaleen Nabellaleen modified the milestone: 2.1.1 Mar 18, 2019
thejcannon pushed a commit to thejcannon/graphene-sqlalchemy that referenced this pull request Apr 12, 2019
thejcannon pushed a commit to thejcannon/graphene-sqlalchemy that referenced this pull request Apr 12, 2019
thejcannon pushed a commit to thejcannon/graphene-sqlalchemy that referenced this pull request Apr 12, 2019
@hoffrocket hoffrocket closed this Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants