Jonathan
07/16/2020, 10:11 AM# Scenario 1: Do a single Prisma call on Posts-level (Level A)
{
posts { # <-- Level A: Do a single prisma.many call, and actually include all users, profilePictures, with all of their
users { # <-- Level B❓On the user-resolver, do we then have to do a superfluous another call (even if level A already got all of their info?)
name
title
birthDate
derivedNrOfFriends
profilePictures { # <-- Level C ❓On the profilePictures resolver, do we do a call even if the posts already included everything necessary?
...etc
}
friends {
}
}
}
}
# Scenario 2: Do multiple Prisma call on each resolver (Level A, Level B, Level C)
{
posts { # <-- Level A: Do a prisma.many call, only include post fields
users { # <-- Level B❓Do a prisma.many call, only include user fields, use optionally parent.id to scope on posts
name
title
birthDate
derivedNrOfFriends
profilePictures { # <-- Level C. Do a prisma.many on profilePictures resolver level, use optionally parent.id to scope on users
...etc
}
friends {
}
}
}
}Jonathan
07/16/2020, 10:13 AMinfo property or set context in some way to inform resolvers on a lower level that their information is already gathered. However, when calling users independently (without posts as parent), they would need to do their own prisma callsJonathan
07/16/2020, 10:14 AMRyan
07/16/2020, 10:17 AMconst prisma = new Prisma.PrismaClient({
log: ['query'],
})
This will log all database queries made.
Right now, some performance optimizations are still to be complete so you would notice improvement over time for these as well 🙂Jonathan
07/16/2020, 10:27 AMRyan
07/16/2020, 10:34 AMinclude for relational data as Prisma will handle the optimizations internally and you do not need to worry about firing Prisma separately on each resolver.Jonathan
07/16/2020, 10:40 AMJonathan
07/16/2020, 10:40 AM