diff --git a/graphene_django/fields.py b/graphene_django/fields.py index 47b44f6..388dbf0 100644 --- a/graphene_django/fields.py +++ b/graphene_django/fields.py @@ -1,5 +1,6 @@ from functools import partial +import six from django.db.models.query import QuerySet from graphql_relay.connection.arrayconnection import connection_from_list_slice from promise import Promise @@ -19,9 +20,10 @@ class DjangoListField(Field): if isinstance(_type, NonNull): _type = _type.of_type - assert issubclass( - _type, DjangoObjectType - ), "DjangoListField only accepts DjangoObjectType types" + if not isinstance(_type, six.string_types): + assert issubclass( + _type, DjangoObjectType + ), "DjangoListField only accepts DjangoObjectType types" # Django would never return a Set of None vvvvvvv super(DjangoListField, self).__init__(List(NonNull(_type)), *args, **kwargs) diff --git a/graphene_django/tests/test_fields.py b/graphene_django/tests/test_fields.py index f6abf00..55ccebd 100644 --- a/graphene_django/tests/test_fields.py +++ b/graphene_django/tests/test_fields.py @@ -19,6 +19,10 @@ class TestDjangoListField: with pytest.raises(AssertionError): 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): class Reporter(DjangoObjectType): class Meta: