The Prophet ﷺ came to the graveyard, stood there for a long time, then raised his hands three times.
جاء النبي ﷺ بقيع فقام فأطال القيام ثم رفع يديه ثلاث مرات.
Muslim narrated it in the Book of Funerals (974:103) from Harun bin Saeed Ayli, who said, Abdullah bin Wahb told us, Ibn Jurayj informed us, from Abdullah bin Kathir bin Muttalib, that he heard Muhammad bin Qays say, I heard Ayesha say, then he mentioned the hadith in full, and it is recorded in the chapter on supplications for the people of the graves.Facing the qibla is not a condition for greeting the people of the graves and supplicating for them. Rather, one greets them and supplicates for them while facing them wherever that may be, because the Prophet ﷺ did not command us to do that. It has been established that he used to visit Baqi frequently, and it has not been transmitted to us that he faced the qibla when greeting its people and supplicating for them, just as facing the qibla is not a condition for greeting the Prophet ﷺ and his two companions and supplicating for them, by the agreement of the scholars.This is the view favored by Shaykh al-Islam Ibn Baz, may Allah have mercy on him, in his Fatawa.