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

Cryptic error message on `unique_together` error when using DjangoPatchMutation

Open chdefrene opened this issue 1 year ago • 0 comments

I have a model with a unique_together constraint:

# users/models.py

class Person(models.Model):
    class Meta:
        unique_together = ("first_name", "last_name")

However, when I add a DjangoPatchMutation for this model, and then try to patch an object that triggers the uniqueness constraint, the following error is returned:

graphql.error.located_error.GraphQLLocatedError: current transaction is aborted, commands ignored until end of transaction block

This makes it hard to handle error messages in my app.

For comparison, this is the error that is returned when the same constraint is triggered by DjangoCreateMutation:

duplicate key value violates unique constraint "users_person_first_name_last_name_uniq"
     DETAIL:  Key (first_name, last_name)=(John, Crichton) already exists."

chdefrene avatar Jan 17 '23 15:01 chdefrene