Stargate SG-1: Apocalypse is a three novel series published by Fandemonium.
This series begins between "A Hundred Days" and "Shades of Grey", and depicts a chain of events that begin with SG-1 being sent almost a century into the future due to a strange anomaly in the Stargate. As a result, without O'Neill to expose the NID operation, Earth is abandoned by the Tollan, the Tok'ra and the Asgard just before a new attack by a Goa'uld fleet led by Apophis, forcing a small group to flee Earth to the Alpha site established by Colonel Maybourne's NID black ops group. During the intervening time, the Wraith came to the Milky Way galaxy and took control of a sizeable portion of the galaxy, while Rya'c became the First Prime to the Goa'uld Hecate (who took Doctor Janet Fraiser as a host), the last true resistance to Wraith control in the galaxy.
After SG-1 arrive in this future and discover that the Wraith came to the Milky Way galaxy in Atlantis, O'Neill and Carter are able to use the a time-travelling gate-ship to go back and prevent themselves being sent to the future, but this only creates an alternate timeline rather than rewriting their own history. Before returning to the future, Carter realises that Hecate's Jaffa were responsible for forcing SG-1 through the Stargate at that time; confronting Hecate upon returning to the future, it is revealed that Hecate originally killed SG-1 to get them out of the way, but later went back in time and used advanced technology to trap their wormhole in ecliptical orbit of a black hole so that she would have access to O'Neill's ability to control Ancient technology later so that she could control Atlantis. SG-1 are able to defeat Hecate and help the Wraith return to their galaxy, allowing this future Earth a chance to rebuild.