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

Deeply nested objects aren't typed when clientExtensions is enabled #17349

Closed
TaylorFacen opened this issue Jan 16, 2023 · 9 comments · Fixed by #17347 or #17356
Closed

Deeply nested objects aren't typed when clientExtensions is enabled #17349

TaylorFacen opened this issue Jan 16, 2023 · 9 comments · Fixed by #17347 or #17356
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: client types Types in Prisma Client topic: clientExtensions
Milestone

Comments

@TaylorFacen
Copy link

Bug description

Originally, I ran into the RangeError: Maximum call stack size exceeded error when trying to build my application. Using prisma version 4.9.0-integration-feat-client-ext-generic-type-api.13 as mentioned in #16600 resolved that issue. However, I am now running into an issue where deeply nested objects aren't included in my object types.

How to reproduce

Using the schema and code listed below, run pnpm run build. The following error is logged to the console

Type error: Property 'item' does not exist on type '{ id: string;  name: string; plaidItemId: string; }'.

Expected behavior

No response

Prisma information

model PlaidInstitution {
  id                          String      @id
  name                        String
  logoUrl                     String?     @map("logo_url")
  items                       PlaidItem[]
  @@map("plaid_institutions")
}

model PlaidItem {
  id                          String      @id
  institutionId               String      @map("institution_id")
disabledAt                  DateTime?   @map("disabled_at")
  institution     PlaidInstitution        @relation(fields: [institutionId], references: [id], onDelete: Restrict)

  accounts                    PlaidAccount[]

  @@map("plaid_items")
  @@index([institutionId])
}

model PlaidAccount {
  id                          String      @id
  plaidItemId                 String      @map("plaid_item_id")
  name                        String
  destinations                Destination[] 
  item                        PlaidItem   @relation(fields: [plaidItemId], references: [id], onDelete: Cascade)
  @@map("plaid_accounts")
  @@index([plaidItemId])
}

model Destination {
  id                          String      @id @default(uuid())
  integration                 String
  name                        String
  accounts                    PlaidAccount[]
  
  @@map("destinations")
}
const destination = await db.destination.findFirst({ 
    include: { 
      accounts: { where: { item: { disabledAt: null } }, include: { item: { include: { institution: true }} }},
    }
  });

Environment & setup

  • OS: macOS
  • Database: PlanetScale
  • Node.js version: v16.17.0

Prisma Version

10.1.0
@Multiply
Copy link

As mentioned here, I'm having the same issue.

@TaylorFacen
Copy link
Author

By the way, I just downgraded my application back to v4.8.1 and removed clientExtensions and my app is able to build without an issue.

@millsp millsp self-assigned this Jan 17, 2023
@millsp millsp added this to the 4.9.0 milestone Jan 17, 2023
@millsp millsp added bug/2-confirmed Bug has been reproduced and confirmed. topic: client types Types in Prisma Client tech/typescript Issue for tech TypeScript. team/client Issue for team Client. topic: clientExtensions labels Jan 17, 2023
@millsp
Copy link
Member

millsp commented Jan 17, 2023

This has been fixed on dev, you can try it out by installing 4.9.0-dev.70, or wait until the 4.9.0 release tomorrow. Thanks for reporting this issue.

@millsp millsp closed this as completed Jan 17, 2023
@janpio janpio changed the title Deepy nested objects aren't typed when clientExtensions is enabled Deeply nested objects aren't typed when clientExtensions is enabled Jan 17, 2023
@TaylorFacen
Copy link
Author

This has been fixed on dev, you can try it out by installing 4.9.0-dev.70, or wait until the 4.9.0 release tomorrow. Thanks for reporting this issue.

Hi, I just tried to install, but I'm running into the same error

@TaylorFacen
Copy link
Author

I tried 4.9.0-dev.72 and that didn’t work either.

@millsp millsp reopened this Jan 17, 2023
@millsp
Copy link
Member

millsp commented Jan 17, 2023

Sorry my bad; I fixed issues with includes, but didn't realize this one is slightly different from the others. When the where property is in use, includes isn't taken in to account on the type level.

@ABitShift
Copy link

ABitShift commented Jan 19, 2023

I am facing the exact same issue, the same version installed flow were tested

  • RangeError: Maximum call stack size exceeded - on 4.8.1 with prisma extension preview enabled
  • deeply select / includes type error (everything gets flatten at level 2 of nesting) - on 4.9.0 with prisma extension preview enabled

@jove4015
Copy link

jove4015 commented Feb 6, 2023

@millsp - This bug is marked resolved, however, client extensions still are not usable (see #17767). Is there any progress on making this feature functionally available?

@millsp
Copy link
Member

millsp commented Feb 6, 2023

Hey @jove4015, the fix will be release tomorrow. If you want, you can install @prisma/client@dev to try it out. General availability for this feature will come once we have received enough feedback and fixed the bugs as well as missing features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: client types Types in Prisma Client topic: clientExtensions
Projects
None yet
5 participants