Skip to content

sqlalchemy-utils enum to graphene type double conversion #297

Closed
@lungati

Description

@lungati

I notice sqlalchemy_utils enum type is being converted to graphene enum type.

This section of code is triggered multiple times:
def from_enum( cls, enum, description=None, deprecation_reason=None ): # noqa: N805 description = description or enum.__doc__ meta_dict = { "enum": enum, "description": description, "deprecation_reason": deprecation_reason, } meta_class = type("Meta", (object,), meta_dict) return type(meta_class.enum.__name__, (Enum,), {"Meta": meta_class})
-2 Here.. Not sure if this is triggered automatically:
@convert_sqlalchemy_type.register(types.Enum) def convert_enum_to_enum(type, column, registry=None): return lambda: enum_for_sa_enum(type, registry or get_global_registry())

N.B: My models include this section: business_domain = Column(Enum(BusinessDomain), nullable=False)

-3 And here... I trigger the same code here because I need to list the values of the enum. Commenting out this section resolves the issue but I need this list of values!
graphene.List(graphene.Enum.from_enum(BusinessDomain))

Noticed the LRU cache fix mentioned here (#211) won't help if you have different enums.

Can someone help me figure out the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions