File tree 3 files changed +26
-0
lines changed
3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 1
1
import datetime
2
2
import sys
3
3
import typing
4
+ import uuid
4
5
import warnings
5
6
from decimal import Decimal
6
7
from functools import singledispatch
@@ -398,6 +399,11 @@ def convert_sqlalchemy_hybrid_property_type_time(arg):
398
399
return graphene .Time
399
400
400
401
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
+
401
407
def is_union (arg ) -> bool :
402
408
if sys .version_info >= (3 , 10 ):
403
409
from types import UnionType
Original file line number Diff line number Diff line change 2
2
3
3
import datetime
4
4
import enum
5
+ import uuid
5
6
from decimal import Decimal
6
7
from typing import List , Optional , Tuple
7
8
@@ -267,6 +268,21 @@ def hybrid_prop_self_referential_list(self) -> List["ShoppingCart"]:
267
268
def hybrid_prop_optional_self_referential (self ) -> Optional ["ShoppingCart" ]:
268
269
return None
269
270
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
+
270
286
271
287
class KeyedModel (Base ):
272
288
__tablename__ = "test330"
Original file line number Diff line number Diff line change @@ -673,6 +673,10 @@ class Meta:
673
673
"hybrid_prop_self_referential_list" : graphene .List (ShoppingCartType ),
674
674
# Optionals
675
675
"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 ),
676
680
}
677
681
678
682
assert sorted (list (ShoppingCartType ._meta .fields .keys ())) == sorted (
You can’t perform that action at this time.
0 commit comments