Hi guys. I have a problem with a mutation with a c...
# orm-help
r
Hi guys. I have a problem with a mutation with a connection and need some help. This is my schema.prisma:
Copy code
model Menu {
  id        Int          @default(autoincrement()) @id
  name      String
  company   Company      @relation(fields: [companyId], references: [id])
  companyId Int
  isActive  Boolean
  items     ItemOnMenu[]
}

model ItemOnMenu {
  id          Int           @default(autoincrement()) @id
  item        Item          @relation(fields: [itemId], references: [id])
  itemId      Int
  ItemOnOrder ItemOnOrder[]
  course      String
  Menu        Menu          @relation(fields: [menuId], references: [id])
  menuId      Int
}
In graphql.ts i have:
Copy code
schema.objectType({
  name: 'Menu',
  definition(t) {
    t.model.id();
    t.model.name();
    t.model.items();
    t.model.company();
    t.model.companyId();
    t.model.isActive();
  },
});

schema.objectType({
  name: 'ItemOnMenu',
  definition(t) {
    t.model.id();
    t.model.item();
    t.model.itemId();
    t.model.ItemOnOrder();
    <http://t.model.Menu|t.model.Menu>();
    t.model.menuId();
    t.model.course();
    t.model.price();
  },
});
When i run the following mutation, it will give me an error. The id is in my database, i verified that. This is the mutation:
Copy code
mutation createNewItemOnMenu(
  $item: "test"
  $course: "testCourse"
  $price: 2.75
) {
  createOneItemOnMenu(
    data: {
      item: { create: { name: $item } }
      course: $course
      price: $price
      Menu: { connect:{id: 60} }
    }
  ) {
    id
    item {
      name
    }
  }
}
This is the error which gives me a really big headache.
Copy code
"message": "\n\u001b[31mInvalid \u001b[1m`prisma.itemOnMenu.create()`\u001b[22m invocation:\u001b[39m\n\n Null constraint violation on the fields: (`id`)",
Anyone there who can help me? I am running:
Copy code
"@prisma/cli": "^2.0.0-beta.4",
"@prisma/client": "^2.0.0-beta.4",
"nexus-plugin-prisma": "^0.8.0-next.9",