How to filter parent nodes on child nodes attributes

Hi,

i have some kind of the following schema to version some data:

firstName: string @index(fulltext) .
nodes: [uid] @reverse .
txAt: dateTime .
delete: bool @index(bool).
firstNames: [uid] @reverse .

type Tx {
	txAt: dateTime
	nodes: [uid]
	delete: bool
}

type User {
	firstNames: [uid]
}

type FirstName {
	firstName: string
}

the following query has the expected result:

query{
  users(func: type(User)){
    uid
    firstNames {
      firstName
      tx: ~nodes {
        delete
        txAt
    }
  }
}

example result:

"users": [
      {
        "uid": "0x76db",
        "firstNames": [
          {
            "firstName": "Marcus",
            "tx": [
              {
                "delete": false,
                "txAt": "2020-01-10T10:04:05.129457683Z"
              },
              {
                "delete": true,
                "txAt": "2020-01-11T08:04:05.131234323Z"
              }
            ]
          },
          {
            "firstName": "Markus",
            "tx": [
              {
                "delete": false,
                "txAt": "2020-01-10T11:04:05.123456789Z"
              }
            ]
          }
        ]
      }
    ]
  1. Question:
    Since one could not use something like @filter(eq(firstNames.tx.delete, false) on the “parent”- Node because you could not drill into the array and subelements
    how can you filter out the deleted data?
    I´m new to draph Queries and tried some stuff with @cascade and var, but i´m stuck.
    Wanted result is just the firstname “Markus”. Example:
"users": [
      {
        "uid": "0x76db",
        "firstNames": [
          {
            "firstName": "Markus",
            "tx": [
              {
                "delete": false,
                "txAt": "2020-01-10T11:04:05.123456789Z"
              }
            ]
          }
        ]
      }
    ]
  1. Could you optimize this further to the following output (only fetch the first Element of the array “firstNames” and alias it/convert it to an object instead of an array Element?
"users": [
      {
        "uid": "0x76db",
        "firstName": "Markus"
      }
    ]

I think cascade is the right path. Share this query so I can take a look. And maybe a simple sample of your structure in JSON. From the head to the tail. Maybe you can just “relate the type schema” so I can have an idea of relations hierarchy.