Exception: Don't know how to convert the SQLAlchemy field: UUIDType
See original GitHub issueHi,
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: 😕
- https://github.com/graphql-python/graphene-sqlalchemy/issues/53
- https://github.com/graphql-python/graphene-sqlalchemy/issues/233
- https://github.com/graphql-python/graphene-sqlalchemy/pull/203
Can someone point me in the right direction with this?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
How can I use UUIDs in SQLAlchemy? - Stack Overflow
The sqlalchemy postgres dialect supports UUID columns. This is easy (and the question is specifically postgres) -- I don't understand why ...
Read more >PostgreSQL - SQLAlchemy 1.4 Documentation
When SQLAlchemy issues a single INSERT statement, to fulfill the contract of having the “last insert identifier” available, a RETURNING clause is added...
Read more >Error Messages - SQLAlchemy 1.4 Documentation
Object cannot be converted to 'persistent' state, as this identity map is no longer valid. AsyncIO Exceptions. AwaitRequired; MissingGreenlet; No Inspection ...
Read more >What's New in SQLAlchemy 1.1?
JSON Columns will not insert JSON NULL if no value is supplied and no default is ... Same-named @validates decorators will now raise...
Read more >Default behavior for sqlalchemy_utils.UUIDType
id = Column(UUIDType(binary=False), primary_key=True, default=uuid.uuid4) ... don't know what the 'binary' flag on the sqlalchemy_utils version does):
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I found a solution by putting the
convert_column_to_string
right after the model declaration instead of in the schema file. I don’t really get why so if someone could explain, that’d be nice. 😃This still doesn’t work for me with the error:
Exception: NonNull could not have a mounted String() as inner type. Try with NonNull(String).
Trying with
NonNull(String)
give another errorAssertionError: Can only create NonNull of a Nullable GraphQLType