Normalize directive ignores edge alias

{
  films(func: allofterms(name@en, "Indiana Jones")) @normalize {
    name: name@en
    genre: genre {
      name: name@en
    }
  }
}

Above query returns:

"data": {
    "films": [
      {
        "name": [
          "The Adventures of Young Indiana Jones: Passion for Life",
          "History"
        ]
      },
      ...
    ]
}

So basically it merges name and genre.name. It probably acts correctly if genre wouldn’t have an alias, but since it does, it would be great if normalize would keep genre edge so that result would be:

"data": {
    "films": [
      {
        "name": "The Adventures of Young Indiana Jones: Passion for Life",
        "genre": [{
          "name": "History"
        }]
      },
      ...
    ]
}

This feature would be useful when you have query variables defined in same block, but don’t want to return it. So you can simply alias just the ones that you want to return, without flattening results.

If this feature doesn’t belong with @normalize directive, it would be great if there would be separate directive for this functionality.

It does acts correctly. The objective of normalize is to “flat” whatever you setup with aliases.

I don’t get the relation with normalize. This would be a feature related to variables. I have thought about it some time ago, about having a type of variable that is hidden by default on the query body. Is that what you are talking about?

Maybe there isn’t one, idk… I was looking for a solution to specify which fields I needed returned and which I didn’t. Normalize + aliases seemed to do that except on one depth, and I though if I aliased edge, it would treat it like you have normalize on that edge, instead of whole query.

Yeah that sounds great.

Humm, that’s another way of doing it

{
  T as var(func: allofterms(name@en, "Indiana Jones")) {
    n1 as  name@en
    genre {
      n2 as name@en
    }
  }
 films(func: uid(T)) {
    name: val(n1)
    genre {
      name: val(n2)
    }
  }
}