I'm thinking that the gospel of John might be a response to some heresies, and triggered more specifically by Cerinthus.
There's a strong tradition that supports that view, but it is subject to question and commentary.
For those who don't know,
here's some notes on Cerinthus:
Born in Egypt, a Jew. Educated in the Judaeo-Philonic school of Alexandria. Cerinthus did not claim mystical powers, but rather spoke of angelic revelations.
What makes him (in)famous is the report in Irenaeus, received from Polycarp, that when he and St John were in the public baths, Cerintus entered and John is supposed to have said: "Let us flee, lest the bath fall in while Cerinthus, the enemy of the truth, is there." (The value of this tradition is not great – the meeting with St. John in the bath is also told of "Ebion", as well as of Cerinthus.)
His view seems to be that the God of the Hebrew Scriptures is not the Absolute and Transcendent God, the "unknown God", but a lesser quasi-angelic power which made heaven and earth, etc, and this he shares with Gnosticism. This second-order divinity was not necessarily opposed to the Unknown God, but rather was ignorant of Him.
He did not agree with the Gnostics that this creator-god – the "God of the Jews" – was inferior and evil. He preferred to identify him with the Angel who delivered the Law. Scholars have pointed out that these are legitimate deductions from the teaching of Philo. Cerinthus is a long way from the bolder and more hostile schools of later Gnosticism.
So we could see Cerintus as holding a particular view of the 'Two Powers in Heaven' idea, but the secondary power is not associated with the first in the same way that Philo argued. For Cerinthus the separation into two distinct entities is more pronounced.
His Christology is somewhat Ebionite, with his own colourful additions. Jesus was a man of Joseph and Mary, upon whom the Holy Spirit descends at his baptism – and teaches him about the Unknown God – but the Holy Spirit who departs at some point immediately prior to the crucifixion. According to some accounts, Jesus was subsequently raised from the dead. According to others, he is not yet risen, nor shall he rise, until the general resurrection. This general resurrection of Cerinthus was of an earthly kingdom in which the elect are to enjoy pleasures, feasts, marriages, and sacrifices. Its capital is Jerusalem and its duration 1000 years: thereafter shall ensue the restoration of all things. Cerinthus derived this notion from Jewish sources. His notions of eschatology are radically Jewish.
This and other accounts (reliability of sources aside) make it difficult to assign to Cerinthus any certain place in the history of heresy. He can only be regarded generally as a link connecting Judaism and Gnosticism.
+++
Whether John wrote his Gospel against Cerinthus is difficult to say. Irenaeus says as much:
"John, the disciple of the Lord, preaches this faith, and seeks, by the proclamation of the Gospel, to remove that error which by Cerinthus had been disseminated among men, and a long time previously by those termed Nicolaitans, who are an offset of that knowledge falsely so called..."
(Irenaeus,
Against Heresies, III, 11, 1)
Or whether the 1st and 2nd Epistles were so written, but not the Gospel, is a matter of scholarly debate.
It's notable that the Prologue asserts the Logos as eternal and divine, but does not thereby assert the Virgin Birth, which Cerinthus denies, and it is possible to harmonise the Prologue and Cerinthus to some degree, so if an option is allowed, I would say the Gospel was not necessarily against Cerinthus per se, and if Boyarin argues, is a midrash on Genesis 1.
A number of scholars argue a very early strata for the initial John, contemporary with Mark – and that Mark and John each had a version of the other's gospel, while the Prologue might be later, and even of another hand, in which case both Mark and John start with the baptism, without any reference to Jesus' birth, which, again, could be harmonised with Cerinthus.
Hmmm ...