paljs / prisma-tools

Prisma tools to help you generate CRUD system for GraphQL servers
https://paljs.com
MIT License
684 stars 54 forks source link

Possible to display/edit explicit many-to-many relations in Admin? #117

Closed willwillis closed 3 years ago

willwillis commented 4 years ago

I have a few explicit many-to-many relationships in my application, so that I can eventually store details about the relationship. Currently this doesn't seem supported in "Admin" is that correct?

# simplified schema.prisma

model Dashboard {
    id        Int                    @id @default(autoincrement())
    name      String                 @unique
    sections  SectionsOnDashboards[]
}

model SectionsOnDashboards {
    dashboard   Dashboard @relation(fields: [dashboardId], references: [id])
    dashboardId Int
    section     Section   @relation(fields: [sectionId], references: [id])
    sectionId   Int
    order       Int?
    alias       String?
    @@id([sectionId, dashboardId])
}

model Section {
    id        Int      @id @default(autoincrement())
    name      String   @unique
    published Boolean  @default(false)
    dashboards SectionsOnDashboards[]
    jobs       JobsOnSections[]
}

Image 1) Dashboard => Sections => Section exists

prisma-admin-playground

Image 2) 0 rows displayed in Admin prisma-admin-1

Could it be that the singular/plural form of Section/s can't be used on the same model?

Thanks.

AhmedElywa commented 4 years ago

Sorry @willwillis, until now any model did not have @id in one field will be excluded from admin generated schema

The component working with dynamic models and fields so it's needed @id in one field to use in the update and delete functions

AhmedElywa commented 4 years ago

will support many-to-many but this table will just have read and create you can't update or delete

AhmedElywa commented 3 years ago

with the new release v2.0.1, you can now list many-to-many relation table