Flatten only a particular node?

Hi @vibl
If you are sure that there is only one author id, then this might work for you:

{
  q as var(func: eq(title, "My title"))   {
    title as title
    author (first:1)    {
      aid as authorId      
    }
    authorIdMax as max(val(aid))
  }
  
  q1(func: uid(q))  {
    title: val(title)
    
    authorId : val(authorIdMax)
  
    publisher {
        publisherId
    }
  }
}

Response

{
  "data": {
    "q1": [
      {
        "title": "My title",
        "authorId": 42,
        "publisher": {
          "publisherId": 28
        }
      }
    ]
  }
}
1 Like