Galaxies play a key role in our endeavor to understand how structure formation proceeds in the Universe. For any precision study of cosmology or galaxy formation, there is a strong demand for huge sets of realistic mock galaxy catalogs, spanning cosmologically significant volumes. For such a daunting task, methods that can produce a direct mapping between dark matter halos from dark matter-only simulations and galaxies are strongly preferred, as producing mocks from full-fledged hydrodynamical simulations or semi-analytical models is too expensive. Here, we present a graph-neural-network-based model that is able to accurately predict key properties of galaxies such as stellar mass, g − r color, star formation rate, gas mass, stellar metallicity, and gas metallicity, purely from dark matter properties extracted from halos along the full assembly history of the galaxies. Tests based on the TNG300 simulation of the IllustrisTNG project show that our model can recover the baryonic properties of galaxies to high accuracy, over a wide redshift range (z = 0–5), for all galaxies with stellar masses more massive than 109
M
⊙ and their progenitors, with strong improvements over the state-of-the-art methods. We further show that our method makes substantial strides toward providing an understanding of the implications of the IllustrisTNG galaxy formation model.