-
Bug descriptionWe are using a custom resolver to make a prisma query with a filter on a nested list. In this case, we query a Product with all related versions (filter: if version is not internal). This works like expected. But in graphql playground we get the product with all versions (filter on related list ignored) So our correct object is overwritten. It looks like there is just another hidden query right after our called query, which bypasses our filter. How to reproduceThese are our two models:
This is the query in our schema.ts:
The result is not correct anymore, because our server-side filter is ignored. Expected behaviorThe Result in Playground (4) and the server-side log (3) should be the same. Environment & setupWindows 10 prisma/client: 2.0.0-beta.3 nexus/schema": 0.13.1 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Beta Was this translation helpful? Give feedback.
-
Hello any update on this issue ? |
Beta Was this translation helpful? Give feedback.
-
Hey folks, this is presently not a bug and rather a misunderstanding of how schema.objectType({
name: 'User',
definition(t) {
t.model.id()
t.model.products() <-- This field make its own query regardless of what's queried on the `Query.users` type
}
})
schema.queryType({
definition(t) {
t.crud.users({
resolve(root, args, ctx) {
return ctx.db.users.findMany({ include: { products: { where: { /* some constraints */ } } } })
}
})
}
})
The constraint should rather be put on the child resolver and not the parent query. eg: schema.objectType({
name: 'User',
definition(t) {
t.model.id()
t.model.products({
resolve(root, args, ctx) {
return ctx.db.user.findOne({ where: { id: root.id } }).products({ where: { /* some constraints */ } })
}
})
}
}) We could add some logic to not query the Hopefully that solves your issue 🙌 |
Beta Was this translation helpful? Give feedback.
Hey folks, this is presently not a bug and rather a misunderstanding of how
nexus-plugin-prisma
works.Just because you're querying a relation on a parent resolver will not prevent a child resolvers from querying its own data. What happens is the following:
Query.users
make a query that includes the…