Skip to content

How to perform partial update using mutation? #935

@mciastek

Description

@mciastek

I'm trying to perform partial update using graphene. I'm following docs for serializers, but I can't run the mutation, because of required fields. Here's an example.

Serializer

class StudySerializer(serializers.ModelSerializer):
  class Meta:
    model = Study
    fields = '__all__'
    # required for accepting "id" in mutation's arguments
    # see https://github.com/graphql-python/graphene-django/issues/906#issuecomment-602078174
    extra_kwargs = {'id': {'read_only': False, 'required': False}}

Mutation

class UpdateStudy(SerializerMutation):
  class Meta:
    serializer_class = StudySerializer
    model_operations = ['update']

GraphQL is complaining about missing fields in mutation, but they should be optional

Screenshot 2020-04-16 at 15 07 52

Is there any workaround for this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions