-
As shown in the code below, when builder.prismaObject('Article', {
fields: (t) => ({
databaseId: t.exposeInt('databaseId'),
creator: t.relation('creator', {
nullable: true,
}),
}),
})
builder.queryField('articles', (t) =>
t.prismaField({
type: ['Article'],
resolve: (query) => {
return prisma.article.findMany({
...query,
})
},
})
) Next, As shown below, when In such a case, doesn't builder.prismaNode('Article', {
id: { field: 'databaseId' },
fields: (t) => ({
databaseId: t.exposeInt('databaseId'),
creator: t.relation('creator', {
nullable: true,
}),
}),
})
builder.queryField('articles', (t) =>
t.prismaConnection({
type: 'Article',
cursor: 'databaseId',
resolve: (query, parent, args) => {
return prisma.article.findMany({
...query,
})
},
})
) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
I would expect that this would create one Prisma query, and which would result in 2 SQL queries. Do you have any more details to share on what's going on here? Wasn't able to reproduce the issue, and there are several tests covering similar patterns showing optimized queries |
Beta Was this translation helpful? Give feedback.
-
@hayes README.md describes the query to reproduce. |
Beta Was this translation helpful? Give feedback.
can you upgrade prisma and pothos/plugin-prisma to the latest versions and see if your issue is resolved? I pushed a fix for optimizing nodes last week, and prisma has released my fix for optimizing findUniqueOrThrow calls, so I think this should work as expected now