During the scene, Gilly asked Sam the meaning of the word ‘annulment’ which he explained that it’s the ending of a marriage. Gilly then read from a book that an annulment was issued to Prince Rhaegar by the Septon and he was then married to somebody else in secret, in Dorne.
Though this doesn’t reveal all but it is safe to assume that after Rhaegar annulled his marriage to Elia Martell, he married Lyanna Stark which means that Jon Snow was not born out of wedlock (HBO has already confirmed Rhaegar as Jon Snow’s father).
And the guy just petted a massive dragon, like it’s no big deal! So Jon Snow is not only a Targaryen but as a male, rightful heir to the Iron Throne, which also trump’s Daenerys’ claim. To conclude, what Jon & Daenerys have believed all their lives is incorrect- The former is not a bastard and the latter is not the rightful heir to the Iron Throne.