بسم الله الرحمن الرحيم
It is forbidden only when the graves are in front of the namazi. If there is a mosque and the wall of the mosque is a barrier in between then it is lawful to offer salah in the mosque of graveyard without any karahat.
Allah knows Best!
Darul Uloom Deoband
This answer was collected from the official ifta website of Darul Uloom Deoband in India.