So this is a tip that catches people out a lot, and is to do with TigerGraph transactions.
It’s like this, if you write out a vertex or an edge inline with your code in a GSQL function, you cannot read it again. Similarly, if you delete something, it won’t disappear.
This is actually quite clever in that it enables efficient distributed processing (all updates don’t need to fly around the cluster on each synchronisation step), but it can be a surprise for those of us who come from a SQL background.
Accumulators are your friend for this kind of thing, though they can’t help you with inserts. My best suggestion here is to make global lists of tuples your friend, and perform all updates at the very end of the function. This can also make debugging much much easier (print those lists!), so is not such a bad thing.