Is there any support for nested queries? Say I wan...
# orm-help
s
Is there any support for nested queries? Say I wanted to do something like getting all posts from my own friends:
Copy code
posts {
  id
  author {
    id
    friends (
      where: {
        id: myID
      }
    ) {
      id
    }
  }
}
The alternative is to retrieve my
friends
, iterate through their IDs with a query like
getPostsByAuthor
l
I've used nested arguments. Are you getting errors?
s
No, I was just seeing if that was doable.
I'm assuming you didn't get errors 😄
l
I always get errors. 🙂
😂 3
It can take a little bit of stitching to get it set up between your application and Prisma, but it'll work
I have a similar query where I get the total cost of a product, e.g.
Copy code
deal {
    ...
    amount
    salesTaxRate(state: "CA") { rate }
}
s
Cool. Thank you!
💯 1
I hope you don't mind if I follow up on this, but this similar query is returning a 400 error. Playground isn't catching any syntax errors.
Copy code
query getTopLevelPostsForUser($id: ID!) {
  getTopLevelPostsForUser{
    id
    author(where:{
      id:$id
    }) {
      id
    }
  }
}
l
Sorry, just saw this! What does the error say? Since you're using the Prisma generated syntax, make sure you have the author type properly imported.