redwoodjs / redwood

The App Framework for Startups
https://redwoodjs.com
MIT License
17.28k stars 991 forks source link

[Bug?]: Redwood not compatible with compound prisma ID fields #8552

Open russell-dot-js opened 1 year ago

russell-dot-js commented 1 year ago

What's not working?

Redwood requires each model to have a single field annotated with @id in your prisma schema. Without a single @id field, redwood cannot scaffold, generate sdl or services, and cells produce corrupt queries

This is caused by the redwood CLI looking for the model, and then once it finds the model, looking for a single field marked with @id, and that result being null if it does not exist.

How do we reproduce the bug?

// schema.prisma

model Order {
  tenantId  String
  id        String   @unique @default(uuid())
  @@id([tenantId, id])
}

cli: yarn rw g sdl order

Results in error: │ WARNING: Cannot generate CRUD SDL without an @id database column. │

cli: yarn rw g cell order

results in the following cell query:

export const QUERY = gql`
  query FindOrderQuery($id: !) {
    order: order(id: $id) {
      id
    }
  }
`

(see the type of $id)

What's your environment? (If it applies)

No response

Are you interested in working on this?

russell-dot-js commented 1 year ago

See #8556 and #8557 for the important fixes (not prioritizing scaffolding)