The code remains the same, just that you won’t have to hard code the uid which you currently supply in the query. UID can be stored as a variable and that variable could be passed to uid_in function. I am not on my desk right now, will update with code snippets after a while. You can take a look at the wip PR: https://github.com/dgraph-io/dgraph/pull/5320
{
User1 as var(func: eq(name, "User1")){
followers as ~follows
myfollows as follows
}
var(func: uid(User1)){
fTrue as follows @filter(uid(followers))
}
F1 as friendsOfUser1(func: uid(fTrue)){
name
}
allFriends(func: uid(F1, User1)) {
name
}
maAndFollowingsOfAnother(func: uid(F1)) {
name
follows @filter(uid(myfollows)) { name }
}
}
PS. It is always good when requesting queries examples with a certain logic, that you give us a sample along with your Schema. Something “dummy”. That way we can explore the structure of your graph model and think about strategies quickly.
Of course, we can create the sample ourselves. But it is not always the same thing that the user needs and it is not as fast. With Samples, we can respond even faster.