File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 11import datetime
22import sys
33import typing
4+ import uuid
45import warnings
56from decimal import Decimal
67from functools import singledispatch
@@ -398,6 +399,11 @@ def convert_sqlalchemy_hybrid_property_type_time(arg):
398399 return graphene .Time
399400
400401
402+ @convert_sqlalchemy_hybrid_property_type .register (value_equals (uuid .UUID ))
403+ def convert_sqlalchemy_hybrid_property_type_uuid (arg ):
404+ return graphene .UUID
405+
406+
401407def is_union (arg ) -> bool :
402408 if sys .version_info >= (3 , 10 ):
403409 from types import UnionType
Original file line number Diff line number Diff line change 22
33import datetime
44import enum
5+ import uuid
56from decimal import Decimal
67from typing import List , Optional , Tuple
78
@@ -267,6 +268,21 @@ def hybrid_prop_self_referential_list(self) -> List["ShoppingCart"]:
267268 def hybrid_prop_optional_self_referential (self ) -> Optional ["ShoppingCart" ]:
268269 return None
269270
271+ # UUIDS
272+ @hybrid_property
273+ def hybrid_prop_uuid (self ) -> uuid .UUID :
274+ return uuid .uuid4 ()
275+
276+ @hybrid_property
277+ def hybrid_prop_uuid_list (self ) -> List [uuid .UUID ]:
278+ return [
279+ uuid .uuid4 (),
280+ ]
281+
282+ @hybrid_property
283+ def hybrid_prop_optional_uuid (self ) -> Optional [uuid .UUID ]:
284+ return None
285+
270286
271287class KeyedModel (Base ):
272288 __tablename__ = "test330"
Original file line number Diff line number Diff line change @@ -673,6 +673,10 @@ class Meta:
673673 "hybrid_prop_self_referential_list" : graphene .List (ShoppingCartType ),
674674 # Optionals
675675 "hybrid_prop_optional_self_referential" : ShoppingCartType ,
676+ # UUIDs
677+ "hybrid_prop_uuid" : graphene .UUID ,
678+ "hybrid_prop_optional_uuid" : graphene .UUID ,
679+ "hybrid_prop_uuid_list" : graphene .List (graphene .UUID ),
676680 }
677681
678682 assert sorted (list (ShoppingCartType ._meta .fields .keys ())) == sorted (
You can’t perform that action at this time.
0 commit comments