Closed MichalLytek closed 4 years ago
This will be most likely addressed through this issue: https://github.com/prisma/prisma2/issues/1606#issuecomment-601753275
Also related: https://github.com/prisma/prisma2/issues/829 and https://github.com/prisma/prisma-client-js/issues/188
This is implemented now and available on alpha
.
Problem
I have a simple Prisma schema from docs:
When I do simple
await prisma.movie.findMany()
call, I receive onlytitle
property in the objects, even if the underlying query is fetching the id columns:This behavior makes the object impossible to uniquely identify, which might be needed in plenty of use cases, like relations resolving in GraphQL resolvers, where we need all id columns to perform a
findOne
query:Solution
It should always return all id columns and reflect that in typings - either by new properties:
Or by populating the properties aka auto-select:
Alternatives
I'm afraid there is no alternatives available because of lack of uniquness of the response data.
For generated resolvers we can always include the director keys but this results in additional query:
And still breaks custom queries/resolvers 😞
Additional context