Skip to content

Commit b83ba0d

Browse files
committed
Map pg's uuid to graphene's uuid
1 parent d00d9a0 commit b83ba0d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

graphene_sqlalchemy/converter.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from sqlalchemy.dialects import postgresql
44
from sqlalchemy.orm import interfaces
55

6-
from graphene import ID, Boolean, Dynamic, Enum, Field, Float, Int, List, String
6+
from graphene import ID, Boolean, Dynamic, Enum, Field, Float, Int, List, String, UUID
77
from graphene.types.json import JSONString
88

99
from .fields import createConnectionField
@@ -195,3 +195,10 @@ def convert_json_type_to_string(type, column, registry=None):
195195
return JSONString(
196196
description=get_column_doc(column), required=not (is_column_nullable(column))
197197
)
198+
199+
200+
@convert_sqlalchemy_type.register(postgresql.UUID)
201+
def convert_column_to_uuid(type, column, registry=None):
202+
return UUID(
203+
description=get_column_doc(column), required=not (is_column_nullable(column))
204+
)

graphene_sqlalchemy/tests/test_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ class Meta:
266266

267267

268268
def test_should_postgresql_uuid_convert():
269-
assert_column_conversion(postgresql.UUID(), graphene.String)
269+
assert_column_conversion(postgresql.UUID(), graphene.UUID)
270270

271271

272272
def test_should_postgresql_enum_convert():

0 commit comments

Comments
 (0)