Per Bob Woodward’s book, Graham aligned himself with Trump in an effort to try to shape Trump’s views on foreign policy and the military (eg getting him to take a harder line against Assad and doubling down in Afghanistan), and this started over a year before McCain died.