I have a working query which looks like this:
query orgs($limit: Int = 10) {
orgs: research_db_fundingorganization(limit: $limit) {
gridreference {
id: data(path: "id")
name: data(path: "name")
country: data(path: "addresses[0].country")
city: data(path: "addresses[0].city")
types: data(path: "types")
}
}
}
but I only want to return objects if say orgs.gridreference.country
is equal to Austria
.
I can't work out how to filter on a value that might exist deeper on a path.
Filtering orgs.gridreference.id
and orgs.gridreference.name
are simple and can be done like this:
query orgs($limit: Int = 10, $query: jsonb = {id: "grid.458347.9"}) {
orgs: research_db_fundingorganization(limit: $limit, where: {gridreference: {data: {_contains: $query}}}) {
gridreference {
id: data(path: "id")
name: data(path: "name")
country: data(path: "addresses[0].country")
city: data(path: "addresses[0].city")
types: data(path: "types")
}
}
}
FYI, the above produces the result:
{
"data": {
"orgs": [
{
"gridreference": {
"id": "grid.458347.9",
"name": "Austrian Development Agency",
"country": "Austria",
"city": "Vienna",
"types": [
"Government"
]
}
}
]
}
}
Why is it not possible to do something like this:
query orgs($limit: Int = 10, $grid_country: String = "Austria") {
orgs: research_db_fundingorganization(limit: $limit, where: {gridreference: {country: {_eq: $grid_country}}}) {
gridreference {
id: data(path: "id")
name: data(path: "name")
country: data(path: "addresses[0].country")
city: data(path: "addresses[0].city")
types: data(path: "types")
}
}
}