Skip to content

Commit 5d63578

Browse files
committed
Map pg's uuid to graphene's uuid
1 parent c9af40c commit 5d63578

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
@@ -4,7 +4,7 @@
44
from sqlalchemy.orm import interfaces
55

66
from graphene import (ID, Boolean, Dynamic, Enum, Field, Float, Int, List,
7-
String)
7+
String, UUID)
88
from graphene.types.json import JSONString
99

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

graphene_sqlalchemy/tests/test_converter.py

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

265265

266266
def test_should_postgresql_uuid_convert():
267-
assert_column_conversion(postgresql.UUID(), graphene.String)
267+
assert_column_conversion(postgresql.UUID(), graphene.UUID)
268268

269269

270270
def test_should_postgresql_enum_convert():

0 commit comments

Comments
 (0)