Open art1415926535 opened 6 years ago
Unfortunately there's no way to filter parent query by subset's fields at the moment. At the same time as for me it's still quite undefined behavior. Here we have several options we might want to achieve (maybe even more):
However since now subsets are resolved as separate queries, there's an implementation possibility:
query {
authors {
edges {
node {
id
name
book_set (filters: {name: "bar1"}) {
edges {
node {
id
name
}
}
}
}
}
}
}
Thus we have separated filter for subsets. I've already implemented this so I'll push it soon.
It's still without filtering parent query though. I'm thinking about some kind of subset characteristics lookup like author (book_set__count__gt: 0)
but yet, can't figure out how to implement it.
Subset filtering case is ready in b237d4985459c686c71814905b5ee2153d0d42f9, released to 2.2.0
BTW, I nearly accidentally fixed sync queries necessity at subset fetching :grinning:. So now it's safe to use db.set_allow_sync(False)
along with _set
fields.
I think Django's style will be better
authors with at least one book with certain name, but selecting all books as a subset
This option will cover most different uses with a separate filter for subsets.
What need to do for allow query like this
I get the following error