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

Nested Query Filter #178

Open
WuDo opened this issue Jan 10, 2025 · 1 comment
Open

Nested Query Filter #178

WuDo opened this issue Jan 10, 2025 · 1 comment

Comments

@WuDo
Copy link

WuDo commented Jan 10, 2025

Is there any chance of support nested query filter? So I can filter nested objects e.g.

query list {
    listParentObjects(where:{enabled:{equal: true}}) {
         childElement(where:{counter:{gte: 2}) {
               id
         }
    }
}

In this use case, I want all enabled ParentObjects and for them only their childElements with counter greater then 2.

Now with

query list {
    listParentObjects(where:{enabled:{equal: true}}) {
         childElement {
               id
         }
    }
}

I get all childElements for enabled ParentObjects.

I know I can do:

query list {
    listParentObjects(where:{enabled:{equal: true}, {childElement:{some:{counter:{gte: 2}}}) {
         childElement {
               id
         }
    }
}

But that will give me enabled ParentObjects with at least one childElement with such counter, but all these ParentObjects will still have listed all the childElements.

Some other prisma generators support this.

@WuDo
Copy link
Author

WuDo commented Jan 10, 2025

Prisma Client can do this:

const result = await prisma. parentObjects.list({
    where: {
       enabled: true
   },
  select: {
    childElements: {
      where: {
        counter:{
           gte: 2
        }
      },
     select: {
        id: true
     }
    },
  },
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant