Initializing a facet on a all edges of a certain type

I attempted to do this in batches using a single query like:

query {
	q(func: has(On), offset:0, first:500) @cascade {
		sourceID as uid
                <On> {
			targetID as uid

And a mutation:

uid(sourceID) <On> uid(targetID) (new_field="foo") .

Assuming this would just add a new facet to existing edges. But in addition to this it appears to be adding edges between all the sourceID’s and targetID’s returned (losing the association between each sourceID and their specific connected targetID’s). Anyone see a way to accomplish this with a single query\mutation?

Note I did implemented an alternative in which I run the query by itself and then iterate over the results and send in a mutation for each edge, but that’s a multi pass solution with a lot of data being returned by the query. I am wondering how to accomplish this in a single pass if possible.

The facets are created per entities. So, the same edge point to several entities will have their own facet. If you rewrite the edge between both entities (parent and child) you gonna overwrite it. There’s no “append” for now in Facets feature.

Feels like you are using Bulk Upsert, so it is predicted that it will write (new_field = "foo") in all entities that he finds in your query. In this case, if you already have any facet, it gonna overwrite all first:500.

But it’s unclear what is the use case of this topic.

The scenario is just to add\initialize a facet to a group of existing edges in batches of 500. The above query is supposed to find a source node and then all nodes connected to it along a On edge. Then the mutation is supposed add the facet to that group of edges. But instead of just updating the facets for existing On edges the mutation is creating additional edges. Note that if the batch size is 1, meaning only one source node\uid is returned this does not happen. So it only happens when multiple source nodes(uid) are returned. It’s as if it creates an edge between all the sources and targets instead of just updating those that exist.

So I am wondering if there is a way to just update the facets in this fashion. Again, I solved the problem by doing the query up front and then iterating over the results and creating individual mutations for each existing edge and that works, but is a two pass solution which I would like to avoid if possible.

Note I read about facets and my understanding is that the above will remove any previous facets instead of appending on the new one. That is not the main issue though. I want it to update existing edges, not add new ones.

I can see new edges added by running this query before and after.

  var(func: has(On)) {
   	on_count as	count(On)    
  edge_counts() {