-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add select and include to findOne and findMany #7204
base: main
Are you sure you want to change the base?
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/keystonejs/keystone-next-docs/Dw9hkkQjRzoVGwFbYr5P2SPfsr2q |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
Problems now only are:
produces a TS error because of missing types. But if I add
|
26e4ead
to
f2ca4d1
Compare
This would be a great feature for some more heavy processing in some custom mutations for example. |
This comment was marked as outdated.
This comment was marked as outdated.
I think we can add this functionality with the caveat that no Alternatively, we can change the type of Alternatively, maybe this is an opt-in behaviour, with something like |
Is there any plan to support this or even only |
@mariomnts plans yes, but how we integrate this type of functionality with hooks is a problem that needs a resolution. |
That makes sense. In my particular use case I don't use hooks at all in any part of the app so something that comes to my mind that if hooks are not defined a possible optimization is just getting the requested fields. |
@mariomnts indeed, this is what I suggested previously
|
@dcousens sorry I missed that comment, that sounds great then. @MurzNN do you plan to continue working on this PR? |
Now
findOne
andfindMany
functions in DB API misses ability to select specific fields only, and include relationship fields too.It is my try to add this missing functionality.
Prisma allows query specific fields, here is the documentation https://www.prisma.io/docs/concepts/components/prisma-client/select-fields#select-specific-fields
So seems we simply can pass those variables from Keystone API to Prisma API.
Here is usage example of this feature directly in Prisma, based on
examples/blog
:And here is desired behavior in Keystone DB API:
Resolves #7198