Filtering on relations
Perceived Problem
This plugin provides you with automatically generated resolvers for relation fields. But it would be nice if it provided you with some filtering options automatically generated for you, ideally exposing the whole querying api of Prisma (or at least some basic stuff).
Ideas / Proposed Solution(s)
E.g. check how TypeGraphQL does it: https://typegraphql.com/docs/prisma.html
Maybe it should be added to the project roadmap next to relation ordering? https://github.com/prisma/nexus-prisma#midterm
Is there currently any way to filter a relation that's automatically included in the Prisma request? It seems like my include > where clauses are being overwritten by the Nexus plugin and ignored.
Let's say I have a User and Post models and a resolver that does:
const result = await prisma.user.findMany({ where: { userId }, include: { posts: { where: { something: 'impossible' }}}})
console.log(result) // [{ id, ... posts: [] }]
return result
And a query that does:
{
posts {
title
}
}
But the response sent to the client is:
{
posts: [plenty of posts]
}
How to filter them correctly?
Is there any workaround? If I change:
t.field(User.posts)
to:
t.list.nonNull.field('posts', { type: 'Post' })
Filtering works correctly.