Skip to content

Cryptic error message on unique_together error when using DjangoPatchMutation #104

Open
@chdefrene

Description

@chdefrene

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."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions