This paper introduces a novel approach to improve security in dynamic network slices for 5G networks using Graph-based Generative Adversarial Networks (G-GAN). Given the rapidly evolving and adaptable nature of 5G network slices, traditional security mechanisms often fall short in providing real-time, efficient, and scalable defense mechanisms. To address this gap, this study proposes the use of G-GAN, which combines the strengths of Generative Adversarial Networks (GANs) and Graph Neural Networks (GNNs) for adaptive learning and anomaly detection in dynamic network environments. The proposed approach utilizes GAN to generate realistic network traffic patterns, both normal and adversarial, whereas GNNs analyze these patterns within the context of the network's graph-based topology. This combination facilitates the early detection of anomalies and potential security threats, adapting to the ever-changing configurations of network slices. The current study presents a comprehensive methodology for implementing G-GAN, including system architecture, data processing, and model training. The experimental analysis demonstrates the efficacy of G-GAN in accurately identifying security threats and adapting to new scenarios, revealing that G-GAN outperformed established models with an accuracy of 97.12%, precision of 96.20%, recall of 97.24%, and F1-Score of 96.72%. This study not only contributes to the field of network security in the context of 5G, but also opens avenues for future exploration in the application of hybrid AI models for real-time security across various domains.