omar-dulaimi / prisma-trpc-generator

Prisma 2+ generator to emit fully implemented tRPC routers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support Include and Select

omar-dulaimi opened this issue · comments

Discussed in #11

This requires work to be done here in this library and also in Prisma Zod Generator.

Here's a similar package for graphql based on prisma, which you can use as an inspiration: https://github.com/MichalLytek/typegraphql-prisma

Any update on this?

Any update on this?

Not much time these days unfortunately. Though PRs are welcomed if anybody decided to work on it.

One of the engineers on my team is going to take a crack at this. Assuming success, a PR will be forthcoming!

Select is live with the latest release 0.5.0. Special thanks to @BitPhoenix

🙏

I am able to generate the schemas by specifying to the generator to make include and select queries, and I can issue the query, e.g.:

const jobsQuery = trpc.project.job.findManyJob.useQuery({
  take: 40,
  include: { employer: true },
});

I can see that the proper database queries are made to retrieve the correct data from the DB, but how do I access the included data? I can only access the ID, despite my relationships being defined (i.e. they work in prisma studio):

{jobsQuery.data?.map((job) => {
  <p>{job.employerId}</p>;
})}

Also, previously job had type Job of the model generated from the Prisma schema. Now it is just SerializeObject<UndefinedToOptional<Job>>. What am I doing wrong?

@omar-dulaimi I'm dealing with the same issue that @vikt0r0 mentioned above - when using include, the type produced by the query doesn't include the linked relations. I'd like to take a stab at a PR, but I'm not really sure where to start. If you could point me in the right direction, hopefully I can figure something out.

Thanks for this package by the way!

Hey @vikt0r0 @zrachlin
Please open a new issue with reproducible steps so I can take a look at it. I would appreciate it if you shared a sample schema and prisma version, etc.

Sure. I also have a project I can send you if you want me to.