11from functools import partial
22
3+ import six
34from django .db .models .query import QuerySet
45from graphql_relay .connection .arrayconnection import connection_from_list_slice
56from promise import Promise
@@ -19,19 +20,23 @@ def __init__(self, _type, *args, **kwargs):
1920 if isinstance (_type , NonNull ):
2021 _type = _type .of_type
2122
23+ # Django would never return a Set of None vvvvvvv
24+ super (DjangoListField , self ).__init__ (List (NonNull (_type )), * args , ** kwargs )
25+
2226 assert issubclass (
23- _type , DjangoObjectType
27+ self . _underlying_type , DjangoObjectType
2428 ), "DjangoListField only accepts DjangoObjectType types"
2529
26- # Django would never return a Set of None vvvvvvv
27- super (DjangoListField , self ).__init__ (List (NonNull (_type )), * args , ** kwargs )
30+ @property
31+ def _underlying_type (self ):
32+ _type = self ._type
33+ while hasattr (_type , "of_type" ):
34+ _type = _type .of_type
35+ return _type
2836
2937 @property
3038 def model (self ):
31- _type = self .type .of_type
32- if isinstance (_type , NonNull ):
33- _type = _type .of_type
34- return _type ._meta .model
39+ return self ._underlying_type ._meta .model
3540
3641 @staticmethod
3742 def list_resolver (django_object_type , resolver , root , info , ** args ):
0 commit comments