query CountingQuery{
stateLocations as var(func: eq(Location.state, "California"))
moreFilteredLocations as var(func: eq(Location.otherPredicate, "Some Other Filter")) @filter(uid(stateLocations)) {
total as count(uid)
}
FilteredLocations(func: uid(moreFilteredLocations), first:10, offset:0) {
total: val(total)
uid
Location.name
Location.state
Location.otherPredicate
}
}
Expecting to see total show up in the response. But I just got the list of entries that contains all the other data and not the total. I know if I did count(uid) in the final root query it would just return 10 since that’s what I set the pagination to. Is there something I’m doing wrong with the query variables?
"FilteredLocations": [
// I was expecting total to be here
{
"uid": "0xd431",
"Location.name": "Test Location 1",
"Location.state": "California",
...
},
{
"uid": "0xd4ed",
"Location.name": "Test Location 2",
"Location.state": "California",
...
},
...
]
Well, in DQL, you can not control what position the value will come from. But I suspect that it should be always at the top or always at the bottom. Not sure, I don’t remember from the top of my mind. About the “total” there’s no “total concept” in DQL functions. This means the count uid will always obey the given parameters in the query filters and query root params. You should use the first block as the Total value you want. Instead of waiting for it in the FilteredLocations query body.
but then it becomes an int, and i wouldnt be able to use that as a list of filtered uids to pass down further no? Or does it still get stored as a list of uids that i can use to filter later on?
So I will always need the Total as the name of the query of the last query before the root query right? I ask because I’m trying to generate the overall query and adding the intermediate filter queries in between as I go before passing the final list of filtered locations into the root query.
I just want to confirm that if I were to do it this way, I would need to keep track of which was the last filtered query used and change that query name from var to Total. I will play with it more on my end as well but I just want to confirm my understanding is correct.