diff --git a/graphene_sqlalchemy/converter.py b/graphene_sqlalchemy/converter.py index 60e14ddd..2fe8945f 100644 --- a/graphene_sqlalchemy/converter.py +++ b/graphene_sqlalchemy/converter.py @@ -235,7 +235,7 @@ def convert_column_to_float(type, column, registry=None): @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()) + return lambda: enum_for_sa_enum(type, registry or get_global_registry(), fallback_name=column.key) # TODO Make ChoiceType conversion consistent with other enums diff --git a/graphene_sqlalchemy/enums.py b/graphene_sqlalchemy/enums.py index f100be19..3a07c84e 100644 --- a/graphene_sqlalchemy/enums.py +++ b/graphene_sqlalchemy/enums.py @@ -42,7 +42,7 @@ def _convert_sa_to_graphene_enum(sa_enum, fallback_name=None): return Enum(name, members) -def enum_for_sa_enum(sa_enum, registry): +def enum_for_sa_enum(sa_enum, registry, fallback_name=None): """Return the Graphene Enum type for the specified SQLAlchemy Enum type.""" if not isinstance(sa_enum, SQLAlchemyEnumType): raise TypeError( @@ -50,7 +50,7 @@ def enum_for_sa_enum(sa_enum, registry): ) enum = registry.get_graphene_enum_for_sa_enum(sa_enum) if not enum: - enum = _convert_sa_to_graphene_enum(sa_enum) + enum = _convert_sa_to_graphene_enum(sa_enum, fallback_name=fallback_name) registry.register_enum(sa_enum, enum) return enum