prisma / prisma1

💾 Database Tools incl. ORM, Migrations and Admin UI (Postgres, MySQL & MongoDB) [deprecated]
https://v1.prisma.io/docs/
Apache License 2.0
16.54k stars 863 forks source link

Mutations with disconnect=true on an relation that is not connected to anything fails with an error #5165

Closed avatsaev closed 2 years ago

avatsaev commented 3 years ago

Bug description

Error when disconnecting something that is not connected to anything with disconnect: true on Prisma V1

How to reproduce

Mutate an object with an unexisting relation by using disconnect: true

Example:

Data structure:

Object Book is related to object Author

Data:

Book with id:1 is NOT connected to an Author

book.author

// => null

Repro

Try to disconnect the author from the book id:1


mutation RemoveAuthor {
    updateBook(
        where: {id: 1},
        data: {
            author: {disconnect: true}
        }
    ) {
        id
    }
}

Error:

 Error: The relation BookAuthor has no node for the model Authir with the value 'x' for the field 'id' connected to a node for the model Book on your mutation path.

Expected behavior

Disconnecting something that is not connected should not fail with error, but should be silently ignored, at most log a warning.

Error message is not clear enough.

Prisma information

type Book {
   ...
   author: Author
   ...
}

type Author {
    ...
    books: [Book!]!
    ...

}

Environment & setup

Prisma Version

V1
stale[bot] commented 2 years ago

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