Reputation: 4306
I have the following query :
{
allPeople {
people {
name
filmConnection {
films {
title
}
}
}
}
}
I would like to select all people that have a film connection with the title a new hope. How do i select this specific thing from the API. I could also just get it like this and handle it in the code. But surely there is a better way.
What i'd expect :
{
allPeople {
people {
name
filmConnection {
films {
title : "a new hope"
}
}
}
}
}
That didnt work..
Try out here in this playground :
Upvotes: 0
Views: 978
Reputation: 8428
parameter CAN BE passed to deeper child (f.e. can be used to filter films)
{
allPeople {
people {
name {
filmConnection {
films(title_eq:"a new hope") {
title
}
}
}
}
}
}
... if API supports this kind of filtering for films
... but it won't filter people - you'll have all people AND filtered films (for all people) because filters won't work on parents.
You CAN have custom API that will be this kind of filtering aware, f.e.
{
allPeople {
people(connectedFilmTitle_eq:"a new hope") {
name {
filmConnection {
films {
title
}
}
}
}
}
}
customized (not automatically gnerated) peolpe
resolver can make appriopriate query [on joined tables] and return structure you're asking for.
In that case probably you don't need deeper structures - ...filmConnection { films { title
- you know this data earlier (filter parameters).
... but probably you have a many2many relation and cen reverse this query:
{
allFilms {
films(title_eq:"a new hope") {
title {
peoleConnection {
people {
name
}
}
}
}
}
}
Upvotes: 1