Does `prisma.user(…)` do any caching? I'm starting...
# orm-help
r
Does
prisma.user(…)
do any caching? I'm starting to add relation resolvers in my
User
type, but I'm repeating
prisma.user(…).<relation>
throughout my
/Types/User.js
resolver. Just wary that if there's no caching, it could be running the same query against the user table many times…
h
We batch everything using dataloader
so your final thing will result in single hit to the database
means user(...).<relation> will be converted in such a SQL statement in prisma server that it will grab all things at once
r
perfect 👍
Is it right that I'm having to manually define each relation in my types/User.js file? I thought that if I didn't define the type property, then Prisma would pick up the property. Because until I manually added the User.accountSubscription resolver, running a query for that field in the playground would return null (or an error saying it can't be null).
h
It is fine to use that pattern to resolve them 🙂
r
but, if I don't explicitly include them, the values don't resolve at all. Is that right?
h
Yes, that ensures safety and will make sure you don't forget to resolve a field.
https://github.com/javascript-af/javascript-af/blob/master/packages/backend/src/resolvers/User/User.ts I also do the same with my projects. If you use TS, graphqlgen will automate this
r
…this project has definitely got me more interested in TS…!