Physics-informed neural network (PINN) exists some challenges, such as independent and uncorrelated drawbacks leading to convergence impediments, limited interpretability and lack of generalization. In this paper, a novel energy-informed graph transformer model is proposed to overcome the drawbacks of PINN. In the proposed model, the graph neural network-based-attention mechanism is proposed to dynamically calculate weight coefficients between objects of graph-structured data, and then to aggregate weighted combinations of the neighbor objects features to update features of the target objects. The loss function is constructed with homoscedastic uncertainty by introducing trainable scalar parameters, which can be optimized to achieve the best performance of the network as it changes dynamically the topology of the loss function involved in the optimization process. Numerical results show that the proposed method can effectively increase the efficiency, robustness and accuracy of the network approximation of forward and inverse problems of solid mechanics. Furthermore, the proposed model demonstrates excellent generalization capabilities when applied to new problem using transfer learning strategy.