1
1
from functools import partial
2
2
3
+ import six
3
4
from django .db .models .query import QuerySet
4
5
from graphql_relay .connection .arrayconnection import connection_from_list_slice
5
6
from promise import Promise
@@ -19,19 +20,23 @@ def __init__(self, _type, *args, **kwargs):
19
20
if isinstance (_type , NonNull ):
20
21
_type = _type .of_type
21
22
23
+ # Django would never return a Set of None vvvvvvv
24
+ super (DjangoListField , self ).__init__ (List (NonNull (_type )), * args , ** kwargs )
25
+
22
26
assert issubclass (
23
- _type , DjangoObjectType
27
+ self . _underlying_type , DjangoObjectType
24
28
), "DjangoListField only accepts DjangoObjectType types"
25
29
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
28
36
29
37
@property
30
38
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
35
40
36
41
@staticmethod
37
42
def list_resolver (django_object_type , resolver , root , info , ** args ):
0 commit comments