Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering on relations #83

Open
dimaip opened this issue Jun 17, 2021 · 2 comments
Open

Filtering on relations #83

dimaip opened this issue Jun 17, 2021 · 2 comments
Labels
type/feat Add a new capability or enhance an existing one

Comments

@dimaip
Copy link

dimaip commented Jun 17, 2021

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

@dimaip dimaip added the type/feat Add a new capability or enhance an existing one label Jun 17, 2021
@iddan
Copy link
Collaborator

iddan commented Jun 22, 2021

Maybe it should be added to the project roadmap next to relation ordering? https://github.com/prisma/nexus-prisma#midterm

@jasonkuhrt jasonkuhrt pinned this issue Jul 8, 2021
@jasonkuhrt jasonkuhrt unpinned this issue Aug 30, 2021
@verekia
Copy link

verekia commented Oct 7, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feat Add a new capability or enhance an existing one
Projects
None yet
Development

No branches or pull requests

3 participants