Skip to content

Query resolver result is different to server side log #1199

Answered by Weakky
Nikxt asked this question in General
Discussion options

You must be logged in to vote

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:

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 */ } } } })
	  }
    })
  }
})
  • Query.users make a query that includes the…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by jasonkuhrt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1199 on July 10, 2020 15:00.