All perfect praise be to Allah, The Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallahu ‘alayhi wa sallam, is His slave and Messenger.
We believe that there is no harm in eating the fruits of the trees that grow on graves, although some scholars held that it is disliked. The permissibility of benefiting of the fruits of these trees is supported by the authentic narrations in Saheeh Al-Bukhaari and Saheeh Muslim, who show that the site of the Prophet's Mosque (in Madeenah) was originally a graveyard of the polytheist with palm trees and ruins therein. The palm trees were cut and made the Qiblah of the mosque, the ruins were leveled, the graves were dug up, and the foundations of the Mosque were laid. So these were graves of polytheists that were dug up, and the soil was kept. If this soil had been considered ritually impure, it would have been moved out of the mosque. This proves that the soil is pure, and if the soil is pure, then whatever grows in it or springs from it is accordingly pure.
Allah knows best.