dgraph
dgraph copied to clipboard
Add other filters to expand()
Experience Report
reference: https://discuss.dgraph.io/t/how-to-find-relationship-between-two-nodes/7495/3?u=micheldiz
What you wanted to do
Use expand func to reduce hard typing. This increases the users experience.
{
M as var(func: type(Person)) @filter(eq(name, 'Martin Sheen')
O as var(func: type(Person)) @filter(eq(name, 'Oliver Stone')
q(func: uid(O) @recurse(depth: 50, loop: true) {
expand(User) @filter(uid(M))
}
}
What you actually did
{
M as var(func: type(Person)) @filter(eq(name, 'Martin Sheen')
O as var(func: type(Person)) @filter(eq(name, 'Oliver Stone')
q(func: uid(O) @recurse(depth: 50, loop: true) {
friend @filter(uid(M))
~friend @filter(uid(M))
follows @filter(uid(M))
~follows @filter(uid(M))
# maybe even more edges to add (...)
}
}
Why that wasn't great, with examples
The only problem is that you need to hard type all possible edges to accomplish that. Using "Expand(Type)" with a filter it would catch all possible edges from the Type Definition and apply the filter as a "template".
Github issues have been deprecated. This issue has been moved to discuss. You can follow the conversation there and also subscribe to updates by changing your notification preferences.

Postman repro case https://cloudy-astronaut-679688.postman.co/workspace/e8602b95-3843-46e0-8f3b-2d994602fa7a/collection/24547389-2ebb8f27-7be7-4493-a152-dca9b4782b5b?action=share&creator=24547389
using predicate "in" with @reverse. you can declare the predicate "~in" in a type. expand(all) will work : it will follow all the relationships declared in the node type, so it will follow ~in if present. in our case the ~in relationship goes to a node of type "N5803". If we expand(all) @filter(type(N5803)) , the query does not follow the ~in relationship. See the postman test with other options working.
The link isn't working for me.
You don't have access To access this page, switch to an account with permission. You are signed in as michel
But I don't get your point. Are you saying that expand function has filters? last time I checked the code it wasn't.
https://dgraph.io/docs/query-language/expand-predicates/#filtering-during-expand expand supports type filters only, but they do not work on reverse predicates.
my bad not reading this issue correctly. We must open a separate issue... I'll do it.