-
Notifications
You must be signed in to change notification settings - Fork 227
No UUIDType support #336
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
Comments
It would be interesting to see if this works with the native Postgres.UUID instead of sqlalchemy_utils.UUID, since internal converters exist for that Type (see converters.py line 188). For now, it would be helpful if you could post a traceback of the error for further analysis. |
@erikwrede thanks! It works with the postgres UUID on a postgres db. I would love to get this working with sqlite3. I will open a separate issue for that, if needed, and change the name back on this since I referenced the other issues. from uuid import uuid4
from sqlalchemy.dialects.postgresql import UUID
class Item(Base):
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid4)
from graphene_sqlalchemy import SQLAlchemyObjectType
class ItemNode(SQLAlchemyObjectType):
class Meta:
model = Item |
Sorry for the late reply. I haven't found the time to do any testing earlier. Since you referenced #257, I expected that you already tried adding a custom type converter for Adding a custom type converter is as simple as adding these lines to your code before the model: from sqlalchemy_utils import UUIDType
from graphene_sqlalchemy.converter import convert_sqlalchemy_type
@convert_sqlalchemy_type.register(UUIDType)
def convert_column_to_string(type, column, registry=None):
return graphene.String This is essentially the solution detailed in #257. I've just tested this with your code above on Quick side note: To prevent this from happening in most of the cases, I want to add additional type converters to graphene-sqlalchemy 3.0. Tracking in #339. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topics referencing this issue. |
Almost identical to #257
Opening a new issue since I could not find a solution. Any help is much appreciated.
How can I support UUIDs?
The text was updated successfully, but these errors were encountered: