paljs / prisma-tools

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

Simple one-to-many apollo SDL first code generation not working #252

Closed ZenSoftware closed 10 months ago

ZenSoftware commented 2 years ago

Hello @AhmedElywa! 🎎

Pal.js apollo SDL first code generation does not seem to be working with a very simple one-to-many schema. I have created a bare minimum reproduction of this Pal.js bug for you by cloning your prisma-tools/packages/create/examples/apollo-sdl-first example and modifying the schema.prisma file.

My system:

schema.prisma

 model User { 
   id        Int      @id @default(autoincrement()) 
   username  String   @unique 
   password  String 

   products Product[] 
 } 

 model Product { 
   id      Int  @id @default(autoincrement()) 
   owner   User @relation(fields: [ownerId], references: [id]) 
   ownerId Int 
 } 

Notice how the definition for ProductUpdateManyMutationInput is not being generated. src/resolversTypes.ts#L482-L485

/*
export interface ProductUpdateManyMutationInput {
   ... missing ...
}
*/

export interface UpdateManyProductArgs { 
   data: ProductUpdateManyMutationInput 
   where?: ProductWhereInput 
 }

Though UserUpdateManyMutationInput is being properly generated.

resolversTypes.ts#L454-L457

export interface UpdateManyUserArgs {
  data: UserUpdateManyMutationInput
  where?: UserWhereInput
}

src/resolversTypes.ts#L605-L608

 export interface UserUpdateManyMutationInput { 
   username?: StringFieldUpdateOperationsInput 
   password?: StringFieldUpdateOperationsInput 
 } 

Would you happen to know what is happening? Thanks 🎐

f8k8 commented 11 months ago

It seems like this is still an issue. I've put together a minimal reproduction here: https://github.com/f8k8/paljs-bug. Clone it and do npm install then npm run generate. In the generated resolversTypes.ts, the HouseUpdateManyMutationInput is missing.

f8k8 commented 11 months ago

I've figured out why this is happening. If the model (House in the case of the repo I linked) doesn't have any other fields, just an ID and relations, then the XXXUpdateManyMutationInput interface isn't generated. Presumably because it would have no fields.

AhmedElywa commented 10 months ago

this should fix now