Aggregations for multiple connected components in one query

I’m doing a recursive query that starts with passing multiple values to eq(), e.g.:

{
  var(func: eq("id","1","2","3")) { 
    uids as uid 
    phone_number
    ~phone_number
    email
    ~email
  }
}

which leaves me with a result that looks something like this:

Is it possible (using a single query) to aggregate things for each connected component? Like how many emails each component contains, etc.

can you explain further what exactly the result would look like?

So for something like:

{
  var(func: eq("id","1","2")) { 
    uids as uid 
    phone_number
    ~phone_number
    email
    ~email
  }
  q(func: uid(uids)) { # uid() could be replaced by some function that I don't know about.
    ids as id
    count(id)
    count(email)
  }
}

It’d be nice to get a result like:

[
  {
    "ids": [
      { "id": 1 },
      { "id": 4 },
      { "id": 5 }
    ],
    "count(id)": 3,
    "count(email)": 2
  },
  {
    "ids": [
      { "id": 2 },
      { "id": 6 },
      { "id": 7 }
    ],
    "count(id)": 3,
    "count(email)": 3
  }
]

I guess it’s sort of like groupBy(), but without having to specify a single edge to group on. We’re trying to avoid adding nodes just to group components like this.

bump