mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-04-25 11:23:45 +03:00
Allow passing string references to DjangoListField
This commit is contained in:
parent
6a19ab5a4b
commit
38a0d4c4f2
|
@ -1,5 +1,6 @@
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
|
import six
|
||||||
from django.db.models.query import QuerySet
|
from django.db.models.query import QuerySet
|
||||||
from graphql_relay.connection.arrayconnection import connection_from_list_slice
|
from graphql_relay.connection.arrayconnection import connection_from_list_slice
|
||||||
from promise import Promise
|
from promise import Promise
|
||||||
|
@ -19,6 +20,7 @@ class DjangoListField(Field):
|
||||||
if isinstance(_type, NonNull):
|
if isinstance(_type, NonNull):
|
||||||
_type = _type.of_type
|
_type = _type.of_type
|
||||||
|
|
||||||
|
if not isinstance(_type, six.string_types):
|
||||||
assert issubclass(
|
assert issubclass(
|
||||||
_type, DjangoObjectType
|
_type, DjangoObjectType
|
||||||
), "DjangoListField only accepts DjangoObjectType types"
|
), "DjangoListField only accepts DjangoObjectType types"
|
||||||
|
|
|
@ -19,6 +19,10 @@ class TestDjangoListField:
|
||||||
with pytest.raises(AssertionError):
|
with pytest.raises(AssertionError):
|
||||||
list_field = DjangoListField(TestType)
|
list_field = DjangoListField(TestType)
|
||||||
|
|
||||||
|
def test_only_import_paths(self):
|
||||||
|
list_field = DjangoListField("graphene_django.tests.models.Reporter")
|
||||||
|
assert list_field._type.of_type.of_type is ReporterModel
|
||||||
|
|
||||||
def test_non_null_type(self):
|
def test_non_null_type(self):
|
||||||
class Reporter(DjangoObjectType):
|
class Reporter(DjangoObjectType):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user