It sounds like you want to upsert an edge here. You can use the @upsert directive in your schema to do upserts. https://docs.dgraph.io/query-language/#upsert-directive
Commit does not “batch up” all the transaction operations (queries, mutations) in one go (if it did, you wouldn’t get query or mutation responses without calling Commit). Commit tells Dgraph to try and persist all the changes in the commit or abort if there’s a conflict.