This is an extension of #239, creating another issue per @janpio.
In order to address the N+1 field resolution issue in nexus-prisma via query batching in prisma2, we've upgraded to prisma2 preview23 and nexus-prisma 0.11.1, but did not see much improvement in performance.
The example query we're testing with is this:
await prisma.lessonTaking.findMany({
where: whereArg,
select: {
id: true,
lessonContent: {
select: {
id: true,
},
},
courseTaking: {
select: {
id: true,
},
},
assignmentTakings: {
select: {
id: true,
},
},
},
})
Executing this query directly with prisma runs 5 queries in 53.26ms. Running this query using a nexus resolver, e.g.:
t.field('lessonTakings', {
type: 'LessonTaking',
list: true,
nullable: true,
args: {
where: 'LessonTakingWhereInput',
},
resolve: async (_, args, { prisma }) => {
return prisma.lessonTaking.findMany({
...args,
})
},
})
Takes 2.01 sec, and runs 845 queries (mostly single select) based on the prisma logs. We're not sure if the query batching isn't catching our queries for some reason.
The where statement used for this testing:
{
student: { id: { equals: <id> } },
assignedDate: { lt: <date> },
assignmentTakings: { some: { submittedAt: { equals: null }, isSkipped: { not: true } } },
}
The example log is attached.
Hey @Linktheoriginal 馃憢,
I've just made some tests and could not reproduce your issue on a simple datamodel.
Could you provide some minimal reproduction code for your issue? That would be super helpful 馃檹
@Weakky I've added you to a repo with some reproduction code.
Hey @Linktheoriginal, thanks a lot for setting up some reproduction.
Here's the underlying problem: https://github.com/prisma/prisma-client-js/issues/562
Hello, any update on this? the issue @Weakky mentioned is closed but the query is still taking a long time to resolve. Many thanks for your awesome work.
@ALITHEALI in our project with @Linktheoriginal we go to another solution to generate our CRUD system and use tool to convert info: GraphQLResolveInfo to be available Prisma select object
with this way you have all control of your crud system and have best performance
here is our tools https://github.com/AhmedElywa/prisma-tools
Most helpful comment
@ALITHEALI in our project with @Linktheoriginal we go to another solution to generate our CRUD system and use tool to convert
info: GraphQLResolveInfoto be availablePrisma select objectwith this way you have all control of your crud system and have best performance
here is our tools https://github.com/AhmedElywa/prisma-tools