Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated ID type error in *Where*Input #232

Open
bigfree opened this issue Feb 7, 2025 · 0 comments
Open

Generated ID type error in *Where*Input #232

bigfree opened this issue Feb 7, 2025 · 0 comments

Comments

@bigfree
Copy link

bigfree commented Feb 7, 2025

prisma version: 6+
prisma-nestjs-graphql version: 21.1.1

Hi, I have a problem with the generated types.

This is my prisma schema:

model PKMN_Ability {
  /// @HideField({ match: 'PKMN_Ability*@(Create|Update)*Input' })
  /// @FieldType('Cuid')
  id           String  @id @default(cuid())
  originalId   Int     @unique
  name         String  @db.VarChar(50)
  isMainSeries Boolean

  generation   PKMN_Generation @relation(fields: [generationId], references: [id], onDelete: Cascade, name: "AbilityGeneration")
  /// @FieldType('Cuid')
  generationId String

  changelogs  PKMN_AbilityChangelog[]
  flavorTexts PKMN_AbilityFlavorText[]
  names       PKMN_AbilityName[]

  /// @FieldType('DateTime')
  createdAt DateTime @default(now())
  /// @FieldType('DateTime')
  updatedAt DateTime @updatedAt

  @@index(fields: [id], type: Hash)
  @@index(fields: [name], type: Hash)
}

when I try to call select over prisma it returns a type error message:

Type PKMN_AbilityWhereUniqueInput is not assignable to type
{     id: string | number;     originalId: string | number; } & {     id?: string;     originalId?: number;     AND?: PKMN_AbilityWhereInput | PKMN_AbilityWhereInput[];     ... 10 more ...;     names?: PKMN_AbilityNameListRelationFilter; }
Type PKMN_AbilityWhereUniqueInput is not assignable to type
{     id: string | number;     originalId: string | number; }
Property id is optional in type PKMN_AbilityWhereUniqueInput but required in type
{     id: string | number;     originalId: string | number; }

here are my prisma calls:

public async findAll(
    findManyPkmnAbilityArgs: FindManyPkmnAbilityArgs,
    select: Prisma.PKMN_AbilitySelect,
): Promise<PKMN_Ability[]> {
    return this.prismaService.pKMN_Ability.findMany({
        ...findManyPkmnAbilityArgs,
        select,
    });
}

public async findOne(
    findUniquePkmnAbilityArgs: FindUniquePkmnAbilityArgs,
    select: Prisma.PKMN_AbilitySelect,
): Promise<PKMN_Ability | null> {
    return this.prismaService.pKMN_Ability.findUniqueOrThrow({
        ...findUniquePkmnAbilityArgs,
        select,
    });
}

Can anyone help me? or is it a generation bug?
I suspect the problem is in the ID type. It can be of type string or number. Or am I doing something wrong?

I see it's a similar problem as in !229

Thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant