Repository: graphql-python/graphene-django

Issue:
SerializerMutation nested serializer with many=True expects a String
I have a DRF Serializer with a field using a custom nested serializer, something like this:
```python
class SecondSerializer(serializers.ModelSerializer):
    class Meta:
        model = SecondModel
        fields = '__all__'

class FirstSerializer(serializers.ModelSerializer):
    class Meta:
        model = FirstModel
        fields = ('field_a', 'field_b')
    field_b = SecondSerializer(many=True)
```
I'm trying to create a mutation on the FirstSerializer like this:
```python
class FirstMutation(SerializerMutation):
    class Meta:
        serializer_class = FirstSerializer
```
but when I run it the field_b input on the FirstMutation is expecting a string and not a json representation of a SecondModel.

I did a little bit of debugging and when field_b is checked in https://github.com/graphql-python/graphene-django/blob/master/graphene_django/rest_framework/serializer_converter.py#L42 it isn't recognized as a subclass of ModelSerializer because it is a ListSerializer, I guess because of the many=True parameter. I don't know if this is the problem or If I'm doing something wrong because I don't know enough about the internals of graphene-django and I'm not really sure if I'm using it correctly because I couldn't find any documentation or example using a nested DRF serializer.


Discussion:

Resolving patch:
diff --git a/graphene_django/rest_framework/serializer_converter.py b/graphene_django/rest_framework/serializer_converter.py
--- a/graphene_django/rest_framework/serializer_converter.py
+++ b/graphene_django/rest_framework/serializer_converter.py
@@ -46,6 +46,15 @@ def convert_serializer_field(field, is_input=True):
             global_registry = get_global_registry()
             field_model = field.Meta.model
             args = [global_registry.get_type_for_model(field_model)]
+    elif isinstance(field, serializers.ListSerializer):
+        field = field.child
+        if is_input:
+            kwargs['of_type'] = convert_serializer_to_input_type(field.__class__)
+        else:
+            del kwargs['of_type']
+            global_registry = get_global_registry()
+            field_model = field.Meta.model
+            args = [global_registry.get_type_for_model(field_model)]
 
     return graphql_type(*args, **kwargs)
 
@@ -75,6 +84,12 @@ def convert_serializer_to_field(field):
     return graphene.Field
 
 
+@get_graphene_type_from_serializer_field.register(serializers.ListSerializer)
+def convert_list_serializer_to_field(field):
+    child_type = get_graphene_type_from_serializer_field(field.child)
+    return (graphene.List, child_type)
+
+
 @get_graphene_type_from_serializer_field.register(serializers.IntegerField)
 def convert_serializer_field_to_int(field):
     return graphene.Int


Test patch:
diff --git a/graphene_django/rest_framework/tests/test_field_converter.py b/graphene_django/rest_framework/tests/test_field_converter.py
--- a/graphene_django/rest_framework/tests/test_field_converter.py
+++ b/graphene_django/rest_framework/tests/test_field_converter.py
@@ -1,8 +1,10 @@
 import copy
-from rest_framework import serializers
-from py.test import raises
 
 import graphene
+from django.db import models
+from graphene import InputObjectType
+from py.test import raises
+from rest_framework import serializers
 
 from ..serializer_converter import convert_serializer_field
 from ..types import DictType
@@ -74,7 +76,6 @@ def test_should_uuid_convert_string():
 
 
 def test_should_model_convert_field():
-
     class MyModelSerializer(serializers.ModelSerializer):
         class Meta:
             model = None
@@ -128,6 +129,30 @@ class StringListField(serializers.ListField):
     assert field_b.of_type == graphene.String
 
 
+def test_should_list_serializer_convert_to_list():
+    class FooModel(models.Model):
+        pass
+
+    class ChildSerializer(serializers.ModelSerializer):
+        class Meta:
+            model = FooModel
+            fields = '__all__'
+
+    class ParentSerializer(serializers.ModelSerializer):
+        child = ChildSerializer(many=True)
+
+        class Meta:
+            model = FooModel
+            fields = '__all__'
+
+    converted_type = convert_serializer_field(ParentSerializer().get_fields()['child'], is_input=True)
+    assert isinstance(converted_type, graphene.List)
+
+    converted_type = convert_serializer_field(ParentSerializer().get_fields()['child'], is_input=False)
+    assert isinstance(converted_type, graphene.List)
+    assert converted_type.of_type is None
+
+
 def test_should_dict_convert_dict():
     assert_conversion(serializers.DictField, DictType)
 
@@ -157,6 +182,6 @@ def test_should_json_convert_jsonstring():
 
 
 def test_should_multiplechoicefield_convert_to_list_of_string():
-    field = assert_conversion(serializers.MultipleChoiceField, graphene.List, choices=[1,2,3])
+    field = assert_conversion(serializers.MultipleChoiceField, graphene.List, choices=[1, 2, 3])
 
     assert field.of_type == graphene.String