Achieving accurate air quality predictions depends on a variety of factors, including meteorological conditions, the spatial distribution of pollution sources, and the geographic environment of the target area. This complexity poses challenges in capturing the intricate spatiotemporal dependencies inherent in air quality data. To address this issue, this work proposes a spatiotemporal graph network called GA$^{2}$Transformer, as a novel Transformer-based encoder–decoder architecture, to capture fine-grained spatiotemporal dependencies of air quality data. The proposed GA$^{2}$Transformer integrates a multilevel discrete wavelet decomposition module for extracting trend and periodicity clues at multiple levels from air quality data, and a graph-assisted attention module for modeling graph-structured spatiotemporal dependencies of air quality data. Extensive experiments on the real-world collected Beijing dataset show the validity of the proposed GA$^{2}$Transformer in air quality prediction tasks, outperforming other used methods.