Skip to content

Fixes #371 - Support ListSerializer fields in SerializerMutation #395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 15, 2018

Conversation

mbarrientos
Copy link
Contributor

This allows SerializerMutation to handle serializer fields with many=True.

Fixes #371

e.g. having these serializers

class CategorySerializer(ModelSerializer):
    name = serializers.CharField()

    class Meta:
        model = Category
        fields = '__all__'


class ProductSerializer(ModelSerializer):
    description = serializers.CharField()
    category = CategorySerializer(many=True)

    class Meta:
        model = Product
        fields = '__all__'

... and this mutation

class CreateProduct(SerializerMutation):
    class Meta:
        serializer_class = ProductSerializer

enables nested objects in in the queries:

mutation {
	createProduct(input:{
    description: "Product description",
    category: [
      {name: "Category 1"}
    ]
  }) {
    id
  }
}

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 94.237% when pulling eacdb50 on mbarrientos:drf-list-serializers into dbd3957 on graphql-python:master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 94.237% when pulling eacdb50 on mbarrientos:drf-list-serializers into dbd3957 on graphql-python:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 94.237% when pulling eacdb50 on mbarrientos:drf-list-serializers into dbd3957 on graphql-python:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 94.237% when pulling eacdb50 on mbarrientos:drf-list-serializers into dbd3957 on graphql-python:master.

@coveralls
Copy link

coveralls commented Feb 13, 2018

Coverage Status

Coverage increased (+0.06%) to 94.641% when pulling 3793ce1 on mbarrientos:drf-list-serializers into dbd3957 on graphql-python:master.

@mbarrientos mbarrientos changed the title Support ListSerializer fields in SerializerMutation Fixes #371 - Support ListSerializer fields in SerializerMutation Feb 26, 2018
@syrusakbary
Copy link
Member

Gracias por el PR Miguel!

Merging :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants