Abstract Objective. Obstructive sleep apnea (OSA) is a prevalent sleep disorder. Accurate sleep staging is one of the prerequisites in the study of sleep-related disorders and the evaluation of sleep quality. We introduce a novel GraphSleepFormer (GSF) network designed to effectively capture global dependencies and node characteristics in graph-structured data. Approach. The network incorporates centrality coding and spatial coding into its architecture. It employs adaptive learning of adjacency matrices for spatial encoding between channels located on the head, thereby encoding graph structure information to enhance the model's representation and understanding of spatial relationships. Centrality encoding integrates the degree matrix into node features, assigning varying degrees of attention to different channels. Ablation experiments demonstrate the effectiveness of these encoding methods. The Shapley Additive Explanations (SHAP) method was employed to evaluate the contribution of each channel in sleep staging, highlighting the necessity of using multimodal data. Main results. We trained our model on overnight polysomnography data collected from 28 OSA patients in a clinical setting and achieved an overall Accuracy of 80.10%. GSF achieved performance comparable to state-of-the-art methods on two subsets of the ISRUC database. Significance. The GSF Accurately identifies sleep periods, providing a critical basis for diagnosing and treating OSA, thereby contributing to advancements in sleep medicine.