Database

[{"_id":{"$oid":"5f8c406fc8c88110e0d927f2"},"name":"A"},{"_id":{"$oid":"5f8c406fc8c88110e0d927f3"},"parentFolderId":"5f8c406fc8c88110e0d927f2","name":"B"}]

Query

db.collection.aggregate([{$graphLookup:{from:"collection",startWith:{$toObjectId:"$parentFolderId"},connectFromField:"parentFolderId",connectToField:"_id",as:"parentFolder",maxDepth:0,}}])

Result