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

Wrong error message for nested serializer in mutation

Open abtuleshov opened this issue 5 years ago • 3 comments

I have serializer mutation

class EmployeeSaveMutation(SerializerMutation):
    class Meta:
        serializer_class = EmployeeSerializer

class EmployeeSerializer(serializers.ModelSerializer):
    user = UserSerializer()

    class Meta:
        model = Employee
        fields = '__all__'

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

        def validate(self, attrs):
            raise serilizers.ValidationError('raise UserSerializer validate')

The response is:

erorrs = [
    { field: "user", messages: ["non_field_errors"] }
]

I need response something like:

{ field: "user.non_field_errors", messages: ["raise UserSerializer validate"] }

abtuleshov avatar Jul 18 '19 16:07 abtuleshov

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 17 '19 19:09 stale[bot]

I am exactly facing the same issue, is there any solution to overcome the above problem

JyothiVutukuri avatar Apr 28 '23 20:04 JyothiVutukuri

@ulgens Can I create a PR which can solve the nested error issue in serializer mutation

JyothiVutukuri avatar May 12 '23 07:05 JyothiVutukuri