paljs / prisma-tools

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

createManyAndReturn types not what Pal.js is expecting #335

Closed ZenSoftware closed 1 day ago

ZenSoftware commented 3 weeks ago

Hi @AhmedElywa ! 🎐

I just wanted to let you know how my upgrade experience has been going for the new createManyAndReturn feature Prisma released. I've been running into some small issues.

The actual type being generated by Prisma is some kind of super convoluted type for the new createManyAndReturn feature: paljs-debugging-2

You seem to be expecting the return type for the above to be exported as a declared TypeScript type named CreateManyUserAndReturnOutputType. This type is not being generated for me utilizing @prisma ^5.14.0 paljs-debugging-1

Is this type that you are expecting being generated for you?

Thanks a million for your continual maintenance of Pal.js bud. I would not have been able to create my starter kit without your work. πŸ₯‚

AhmedElywa commented 3 weeks ago

With this new API from Prisma, we add a lot of work on the last version to support it. Prisma changed the dmmf schema a lot to meet this new API so if you have any issues with this API update paljs to the last version and try it.

ZenSoftware commented 3 weeks ago

Yes, I am utilizing @paljs/cli v7.0.0.

The issue is the type CreateManyUserAndReturnOutputType does not exist within the TypeScript type definition file for my Prisma client. The output for your generation for 'SDL first' is expecting this type within your resolversTypes.ts file that is being generated. 乁(ツ)∫

// This type that you are expecting is missing within my Prisma client's index.d.ts file
Client.Prisma.CreateManyUserAndReturnOutputType

// Modifying my Prisma client's index.d.ts file fixes the problem and I can compile by manually adding this under the Prisma namespace
export type CreateManyUserAndReturnOutputType = Prisma.PrismaPromise<$Result.GetResult<Prisma.$UserPayload<ExtArgs>, T, 'createManyAndReturn'>>;

The last line in the code above is the return type for the createManyAndReturn function. I found it and simply by copy and pasted it as the type for the type CreateManyUserAndReturnOutputType to export.

f8k8 commented 1 day ago

I'm seeing the same error. It looks like maybe the generator should create something like this instead: id?: Resolver<ReturnType<Client.Prisma.UserDelegate["createManyAndReturn"]>, {}, string>;