Hasura not respecting postgres serial PK #8709
Answered
by
MattRoelle
MattRoelle
asked this question in
Question
-
Hi there! I am using Postgres and trying out Hasura. I have a contact table in my db that looks like this (generated using Prisma): -- CreateTable
CREATE TABLE "contact" (
"id" SERIAL NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"first_name" VARCHAR(100) NOT NULL,
"last_name" VARCHAR(100) NOT NULL,
CONSTRAINT "contact_pkey" PRIMARY KEY ("id")
); I am trying to run the following mutation, created using the hasura console explorer. mutation MyMutation {
insert_contact(objects: {first_name: "Matt", last_name: "Roelle"}) {
returning {
id
}
}
} In response I get {
"errors": [
{
"extensions": {
"path": "$.selectionSet.insert_contact.args.objects",
"code": "constraint-violation"
},
"message": "Uniqueness violation. duplicate key value violates unique constraint \"contact_pkey\""
}
]
} How do I instruct Hasura to let PG handle the id field? Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
MattRoelle
Jul 21, 2022
Replies: 1 comment
-
The following mutation worked, I was using the batch insert mutation I believe. mutation MyMutation {
insert_contact_one(object: {first_name: "Matt", last_name: "Roelle"}) {
id
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
MattRoelle
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following mutation worked, I was using the batch insert mutation I believe.