prisma-tools icon indicating copy to clipboard operation
prisma-tools copied to clipboard

sdlInput generation looks incorrect

Open pakatagoh opened this issue 3 years ago • 4 comments

@AhmedElywa

I have the following schema

model LeaveOfAbsence {
  createdAt     DateTime @default(now())
  updatedAt     DateTime @updatedAt
  id            String   @id @default(cuid())
  startDateTime DateTime
  endDateTime   DateTime
  reason        String?
  cleaner       Cleaner  @relation(fields: [cleanerId], references: [id])
  cleanerId     String
}

model Cleaner {
  createdAt         DateTime         @default(now())
  updatedAt         DateTime         @updatedAt
  id                String           @id @default(cuid())
  leaveOfAbsence    LeaveOfAbsence[]
  agency            Agency           @relation(fields: [agencyId], references: [id])
  agencyId          String
}

model Agency {
  createdAt           DateTime      @default(now())
  updatedAt           DateTime      @updatedAt
  id                  String        @id @default(cuid())
  name                String        @unique
  cleaners            Cleaner[]
}

With prisma, I'm able to create a LeaveOfAbsence with nested creations of Cleaner and Agency

image

However, the sdlInput types generated do not take into account nested creations. Below is the sdl generated with the help of generateGraphQlSDLFile from @paljs/plugins

createOneLeaveOfAbsence(data: LeaveOfAbsenceCreateInput!): LeaveOfAbsence!

input LeaveOfAbsenceCreateInput {
  createdAt: DateTime
  updatedAt: DateTime
  id: String
  startDateTime: DateTime!
  endDateTime: DateTime!
  reason: String
  cleaner: CleanerCreateNestedOneWithoutLeaveOfAbsenceInput!
}

input CleanerCreateNestedOneWithoutLeaveOfAbsenceInput {
  create: CleanerUncheckedCreateWithoutLeaveOfAbsenceInput
  connectOrCreate: CleanerCreateOrConnectWithoutLeaveOfAbsenceInput
  connect: CleanerWhereUniqueInput
}

input CleanerUncheckedCreateWithoutLeaveOfAbsenceInput {
  createdAt: DateTime
  updatedAt: DateTime
  id: String
  # other types here 
  agencyId: String!
  # more types here 
}

As a result, apollo hooks generated by codegen do not follow the same types as prisma

image

I am not able to perform nested/transactional creations. Was pretty sure this wasn't an issue in the past. Maybe it's an issue with prisma's latest updates that are causing this issue

Hope the explanation is clear enough and hope to get some feedback asap!

My setup: "@paljs/plugins": "2.13.0", "@paljs/cli": "2.13.1", "@prisma/client": "2.20.1", "prisma": "^2.20.1",

pakatagoh avatar Mar 31 '21 12:03 pakatagoh

Maybe it's an update from Prisma DMMF in the last version. I will check that and back to you

AhmedElywa avatar Mar 31 '21 12:03 AhmedElywa

@AhmedElywa any updates on this?

pakatagoh avatar Apr 14 '21 08:04 pakatagoh

Not yet was working on a big change in Prisma admin and ClI to support multiple Prisma schema in the sand project

AhmedElywa avatar Apr 14 '21 10:04 AhmedElywa

okay noted! but just wondering if you have any indication on when you think you might finish working on this fix?

pakatagoh avatar Apr 14 '21 10:04 pakatagoh