Sorting with nested key and also filter

I don’t remember what I have answered him. But it was like (with several modifications as uid_in accepts variables now)

{
  #Get the answers based on the user traversing via reverse edges
  me(func: eq(firstName, "Michel")) @filter(eq(lastName, "Diz")) {
    #User Level
    <~owner> {
    #Answer Level
    <~answers> { 
    #Question Level
         title
         description
         createdTs
       }
     }
  }
}
{
  #Get the answers based on the user
  ME as var(func: eq(firstName, "Michel")) @filter(eq(lastName, "Diz")) 
    
  #Traversing via reverse edges and returning only my answers
  me(func: uid(ME)) @cascade {
    #User Level
    <~owner> {
    #Answer Level
    <~answers> { 
    #Question Level
         title
         description
         createdTs
         answers @filter(uid_in(owner, uid(ME) )) (orderasc: createdTs) { 
          #Answer Level
          description
          createdTs
        }
       }
     }
  }
}

Note that this query isn’t tested anywhere. I just read the schema and imagined how it would be.

1 Like