Skip to content

Exception: Don't know how to convert the SQLAlchemy field: UUIDType #257

Closed
@Msordet

Description

@Msordet

Hi,

My app crashes with the following mapping:

#error
Exception: Don't know how to convert the SQLAlchemy field item.uuid_column (<class 'sqlalchemy.sql.schema.Column'>)

# model
from sqlalchemy_utils import UUIDType

class Item(Base):
    uuid_column = Column(UUIDType(binary=False), nullable=False, unique=True)

# schema
from graphene_sqlalchemy import SQLAlchemyObjectType

class ItemNode(SQLAlchemyObjectType):
    class Meta:
        model = Item

I tried to put this in my schema file to no avail:

from sqlalchemy_utils import UUIDType
from graphene_sqlalchemy.converter import get_column_doc, is_column_nullable, convert_sqlalchemy_type

@convert_sqlalchemy_type.register(UUIDType)
def convert_column_to_string(type, column, registry=None):
    return graphene.String(description=get_column_doc(column), required=not (is_column_nullable(column)))

I checked the following issues/PR but I don't get it: :/

Can someone point me in the right direction with this?

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