Medication recommendation (MR) is a promising task that benefits both patients and medical practitioners. However, the individual differences in patients and drug–drug interactions (DDIs) in medication combinations are two key factors that severely limit the personalization and safety of the present MR models. To alleviate the challenges mentioned above, this paper proposes a novel MR model named Trans-GAHNet, which innovatively leverages transformer-based representation learning and constructs multiple graphs for drug information augmentation. More specifically, the transformer network architecture is deployed to fully encode the sequential EHR data for effective patient representations, which addresses the cold start issue and enhances the interpretability of representation learning. Next, multiple graphs are employed to capture the co-occurrence and exclusiveness in drug pairs and to mitigate potential DDIs in drug combinations, thereby enhancing the personalization and safety of the predicted medication combinations. Finally, extensive experiments on real-world datasets are conducted to evaluate the proposed model, and the experimental results demonstrate that Trans-GAHNet outperforms the state-of-the-art baseline models on multiple metrics, with Jaccard, F1 and PRAUC scores of 0.5238, 0.6786 and 0.7795, respectively.