Hello! `prisma-client-js` generates the following ...
# prisma-client
p
Hello!
prisma-client-js
generates the following invalid TypeScript types when using
t.crud.updateOne*
for me. Notice the dots inside the type names. Has anybody else ever experienced this?
Copy code
export type Game_server_port.gameServerId_binding_protocol_uniqueCompoundUniqueInput = {
  gameServerId: number
  binding: number
  protocol: GameServerPortProtocol
}

export type Game_server_port.gameServerId_identifier_uniqueCompoundUniqueInput = {
  gameServerId: number
  identifier: string
}

export type Game_server_port.gameServerId_number_protocol_uniqueCompoundUniqueInput = {
  gameServerId: number
  number: number
  protocol: GameServerPortProtocol
}

export type Game_server_setting.gameServerId_gameSettingId_uniqueCompoundUniqueInput = {
  gameServerId: number
  gameSettingId: number
}

export type Game_server_setting_preset.gameServerId_name_uniqueCompoundUniqueInput = {
  gameServerId: number
  name: string
}
j
t.crud
is not part of Prisma CLient - are you also using Nexus Plugin Prisma?
p
Yes, I am. I thought it got generated by prisma client because the types are in
generated/prisma-client/index.d.ts
(the path I defined in schema.prisma under generator.output) instead of
generated/nexus-prisma.ts
(the path I configured for nexus-plugin-prisma in outputs.typegen)
j
Can you quickly create a new project with
prisma init
, put your schema in that project and run
prisma generate
to confirm?
p
Yes, give me a ssecond.
I can confirm, that the types are generated after I ran
prisma init
in a fresh directory, copied only my
prisma.schema
and then ran
prisma generate
.
Here's a minimal shema to reproduce the issue:
Copy code
model GameServer {
  id                  Int                       @id @default(autoincrement())
  ports               GameServerPort[]
  @@map("game_server")
}

model GameServerPort {
  id           Int                    @id @default(autoincrement())
  /// varchar(32)
  identifier   String
  protocol     GameServerPortProtocol
  /// unsigned smallint, container port
  number       Int
  /// unsigned smallint, host port
  binding      Int
  gameServerId Int
  /// ON UPDATE CASCADE, ON DELETE CASCADE
  gameServer   GameServer             @relation(fields: [gameServerId], references: [id])

  @@unique([gameServerId, binding, protocol], name: "game_server_port.gameServerId_binding_protocol_unique")
  @@unique([gameServerId, identifier], name: "game_server_port.gameServerId_identifier_unique")
  @@unique([gameServerId, number, protocol], name: "game_server_port.gameServerId_number_protocol_unique")
  @@map("game_server_port")
}

enum GameServerPortProtocol {
  TCP
  UDP

  @@map("game_server_port_protocol")
}
Might be because of the index names. Those are the prisma default index names, generated by
prisma migrate
.
j
That sounds like something worth an issue with this reproduction 👍
p
Is prisma/prisma the correct repository for this?
j
Yep, that works.
p
I also noticed another issue with the generated TypeScript code. I opened an issue explaining both here: https://github.com/prisma/prisma/issues/3964
👍 1