There are a number of prayers that you can say when visiting a cemetery, praying for the repose of the souls of your loved ones.
When visiting a grave, it is most appropriate to say a short prayer at the cemetery, asking God to grant eternal rest to your loved ones.
The most common prayer at a cemetery is the “Eternal Rest” prayer.
℣. Eternal rest, grant unto him/her, O LORD,
℟. And let perpetual light shine upon him/her.
℣. May he/she rest in peace.
You can also pray the prayer of St. Gertrude for the souls in purgatory.
Eternal Father, I offer You the most Precious Blood of Your Divine Son, Jesus, in union with the Masses said throughout the world today, for all the Holy Souls in Purgatory, for all sinners everywhere, for sinners in the universal Church, those in my own home and within my family. Amen.
A simple Hail Mary or even a Rosary could be prayed at a cemetery as well.
There is no “right” prayer to pray at a cemetery. The key is to pray for the repose of souls, and to ask God to have mercy on them.