diff --git a/graphene_sqlalchemy/converter.py b/graphene_sqlalchemy/converter.py index 4ff55eed..dee49305 100644 --- a/graphene_sqlalchemy/converter.py +++ b/graphene_sqlalchemy/converter.py @@ -6,7 +6,7 @@ from sqlalchemy.orm import interfaces from graphene import (ID, Boolean, Dynamic, Enum, Field, Float, Int, List, - String) + NonNull, String) from graphene.types.json import JSONString from .enums import enum_for_sa_enum @@ -46,7 +46,8 @@ def dynamic_type(): # TODO Add a way to override connection_field_factory return connection_field_factory(relationship_prop, registry, **field_kwargs) return Field( - List(_type), + List(NonNull(_type)), + required=True, **field_kwargs ) diff --git a/graphene_sqlalchemy/tests/test_converter.py b/graphene_sqlalchemy/tests/test_converter.py index e8051a18..148b8c30 100644 --- a/graphene_sqlalchemy/tests/test_converter.py +++ b/graphene_sqlalchemy/tests/test_converter.py @@ -209,8 +209,12 @@ class Meta: assert isinstance(dynamic_field, graphene.Dynamic) graphene_type = dynamic_field.get_type() assert isinstance(graphene_type, graphene.Field) - assert isinstance(graphene_type.type, graphene.List) - assert graphene_type.type.of_type == A + assert isinstance(graphene_type.type, graphene.NonNull) + list_type = graphene_type.type.of_type + assert isinstance(list_type, graphene.List) + list_element_type = list_type.of_type + assert isinstance(list_element_type, graphene.NonNull) + assert list_element_type.of_type == A def test_should_manytomany_convert_connectionorlist_connection(): diff --git a/graphene_sqlalchemy/tests/test_types.py b/graphene_sqlalchemy/tests/test_types.py index fda8e659..789b5e8f 100644 --- a/graphene_sqlalchemy/tests/test_types.py +++ b/graphene_sqlalchemy/tests/test_types.py @@ -219,8 +219,12 @@ class Meta: pets_field = ReporterType._meta.fields['pets'] assert isinstance(pets_field, Dynamic) - assert isinstance(pets_field.type().type, List) - assert pets_field.type().type.of_type == PetType + assert isinstance(pets_field.type().type, NonNull) + list_type = pets_field.type().type.of_type + assert isinstance(list_type, List) + list_element_type = list_type.of_type + assert isinstance(list_element_type, NonNull) + assert list_element_type.of_type == PetType assert pets_field.type().description == 'Overridden'