graphene-django icon indicating copy to clipboard operation
graphene-django copied to clipboard

Issue with nested serializers: expected iterable but did not find one

Open coler-j opened this issue 3 years ago • 2 comments

Running into similar issue to these issues:

  • https://github.com/graphql-python/graphene-django/issues/371
  • https://github.com/graphql-python/graphene-django/issues/458

This was supposed to be resolved in https://github.com/graphql-python/graphene-django/pull/395

I am on version2.13.0

I have a nested serialized using many=True for the related serializer, everything saves fine, but on return I am getting:

File "/../graphql/execution/executor.py", line 531, in <lambda>
    lambda resolved: complete_value(
  File "/../graphql/execution/executor.py", line 566, in complete_value
    return complete_list_value(
  File "/../graphql/execution/executor.py", line 603, in complete_list_value
    assert isinstance(result, Iterable), (
AssertionError: User Error: expected iterable, but did not find one for field MyObjectMutationPayload.objects.

This seems to imply there is an issue with the return data.

coler-j avatar Jan 19 '21 02:01 coler-j

Could you provide an example that makes this problem appear?

tcleonard avatar Feb 04 '21 13:02 tcleonard

Here is an example that makes it to appear

class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.User
        fields = "__all__"

class AdminSerializer(serializers.ModelSerializer):
    admin = UserSerializer(many=True)

    class Meta:
        model = models.OrganizationAdmin
        fields = ('admin')

class AdminModelMutation(SerializerMutation):
    class Meta:
        serializer_class = AdminSerializer

ImportError: Could not import 'schema' for Graphene setting 'SCHEMA'. AttributeError: 'NoneType' object has no attribute '_meta'.

KingNonso avatar May 13 '21 06:05 KingNonso