Fixed django_connection defaults

This commit is contained in:
Syrus Akbary 2016-02-12 19:05:34 -08:00
parent 56e1b2b638
commit e6f229ffb9
3 changed files with 6 additions and 7 deletions

View File

@ -117,7 +117,7 @@ def test_should_query_connection():
class Query(graphene.ObjectType):
all_reporters = DjangoConnectionField(ReporterType)
def resolve_all_reporters_connection(self, *args, **kwargs):
def resolve_all_reporters(self, *args, **kwargs):
return Reporter.objects.all()
query = '''
@ -172,7 +172,7 @@ def test_should_query_connectionfilter():
class Query(graphene.ObjectType):
all_reporters = DjangoFilterConnectionField(ReporterType)
def resolve_all_reporters_connection_filter(self, *args, **kwargs):
def resolve_all_reporters(self, *args, **kwargs):
return Reporter.objects.all()
query = '''

View File

@ -11,6 +11,7 @@ class DjangoConnectionField(ConnectionField):
def __init__(self, *args, **kwargs):
self.on = kwargs.pop('on', False)
kwargs['default'] = kwargs.pop('default', self.get_manager)
return super(DjangoConnectionField, self).__init__(*args, **kwargs)
@property
@ -27,8 +28,6 @@ class DjangoConnectionField(ConnectionField):
return resolved_qs
def from_list(self, connection_type, resolved, args, info):
if resolved is None:
resolved = self.get_manager()
resolved_qs = maybe_queryset(resolved)
qs = self.get_queryset(resolved_qs, args, info)
return super(DjangoConnectionField, self).from_list(connection_type, qs, args, info)

View File

@ -42,18 +42,18 @@ class ObjectTypeMeta(FieldsClassTypeMeta):
class ObjectType(six.with_metaclass(ObjectTypeMeta, FieldsClassType)):
_root = None
class Meta:
abstract = True
def __getattr__(self, name):
print self._root
if name == '_root':
return
return getattr(self._root, name)
def __init__(self, *args, **kwargs):
self._root = kwargs.pop('_root', None)
signals.pre_init.send(self.__class__, args=args, kwargs=kwargs)
self._root = kwargs.pop('_root', None)
args_len = len(args)
fields = self._meta.fields
if args_len > len(fields):