mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-27 03:53:56 +03:00
Fixed django_connection defaults
This commit is contained in:
parent
56e1b2b638
commit
e6f229ffb9
|
@ -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 = '''
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue
Block a user