Support GraphQL variables in subqueries
GraphQL variables are used to pass values to queries and currently are only supported at the root level. Supporting GraphQL variables at sub-queries may be required for some queries where users wants to supply values that they already have in hand.
For example user can retrieve an edge between two nodes if he has UIDs, like
query q($source: string, $target: string) {
edge(func: uid($source)) {
visited @filter(uid($target)) {
uid
}
}
}
Currently Dgraph supports GraphQL variables at root query edge and not at sub-query visited.
Though as a work-around, user can introduce a DGraph variable to query edge between two known nodes, like
query q($source: string, $target: string) {
var (func: uid($target)) {
target as uid
}
edge(func: uid($source)) {
visited @filter(uid(target)) {
uid
}
}
}
This should be fixed with 4d6a6077343570518cbe247fa1fbf9320731b09b.
hi, i found a problem with query like this:
query withvar($a:string, $b:bool) {
query(func:uid($a)) {
candidate_school @facets(eq(on_edu,$b)) @groupby(name) {
count(uid)
}
} }
it doesn't have any result return, but when i use query like this:
` { query(func:uid(0x998a17)) {
candidate_school @facets(eq(on_edu,false)) @groupby(name) {
count(uid)
}
} }`
it has result.
it seems that queryWithVars has a problem when query vars in facets. @pawanrawal @sboorlagadda
refer : https://discuss.dgraph.io/t/query-and-querywithvars/2796/9
Can you file a new issue? I prefer not to re-open closed issues.