'How to filter data with nested object in GraphQL
query {
comp(func: eq(dgraph.type,"ServiceTemplate")) {
topologytemplate{
nodetemplates {
name
namespace @filter (eq(url,"a_url")){
url
}
}
}
}
}
Using the above query I am want to filter data that nodetemplate objects have matching URL that we are passing in query and we get a list of all nodetemplates but I am getting result as follows:
{
"data": {
"comp": [
{
"topologytemplate": {
"nodetemplates": [
{
"name": "a",
"namespace": {
"url": "a_url"
}
},
{
"name": "b"
},
{
"name": "c"
},
{
"name": "d"
},
{
"name": "e"
},
{
"name": "f",
"namespace": {
"url": "b_url"
}
},
{
"name": "g"
}
]
}
}
]
},
}
But I want only those nodetemplates that have URLs that we are going to filter using graphQL. Any idea how to filter it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
