Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Include and Select #13

Closed
omar-dulaimi opened this issue Jul 15, 2022 Discussed in #11 · 10 comments
Closed

Support Include and Select #13

omar-dulaimi opened this issue Jul 15, 2022 Discussed in #11 · 10 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@omar-dulaimi
Copy link
Owner

omar-dulaimi commented Jul 15, 2022

Discussed in #11

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

@omar-dulaimi omar-dulaimi added the enhancement New feature or request label Jul 15, 2022
@omar-dulaimi omar-dulaimi added this to To do in Issues Progress Tracking via automation Jul 15, 2022
@omar-dulaimi omar-dulaimi added the help wanted Extra attention is needed label Aug 17, 2022
@konuch
Copy link

konuch commented Aug 27, 2022

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

@Kliton
Copy link

Kliton commented Oct 14, 2022

Any update on this?

@omar-dulaimi
Copy link
Owner Author

Any update on this?

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

@kristinlindquist
Copy link
Contributor

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

@omar-dulaimi
Copy link
Owner Author

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

@vikt0r0
Copy link

vikt0r0 commented Jan 14, 2023

🙏

@vikt0r0
Copy link

vikt0r0 commented Jan 20, 2023

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?

@zrachlin
Copy link

zrachlin commented Feb 1, 2023

@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!

@omar-dulaimi
Copy link
Owner Author

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.

@vikt0r0
Copy link

vikt0r0 commented Feb 4, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
No open projects
Development

No branches or pull requests

6 participants