If you look at the common chords of A major you’ll find six maj7 chords fit the modes commonly used:
Amaj7, Dmaj7 from A Ionian (the diatonic ones); Gmaj7 borrowed from A Mixolydian; Cmaj7, Fmaj7 borrowed from A Aeolian; and Bbmaj7 borrowed from A Phrygian. Here’s a loop of them with an A pedal tone on top:
As you might expect, you can’t just play any A major melody over any scale. Here are a couple strategies:
Avoid the Changes
Here you keep the melody diatonic (here using only A Ionian), but craft the melody (and/or the chords) so the melody is always in the current mode.
Here’s an example that uses all seven notes of A major:
Play to the changes
Here you intentionally target notes that are newly brought to the scale by a mode change. E.g. switching from A Mixolydian to A Aeolian, you’d want to land on C or F.
Here’s an example over the same chords, but playing to the changes to squeeze in more chromatic notes:
And an example from pop music, in the chorus of “Something About You” (E major) the melody moves from the 3 scale degree to the b3 over the borrowed bVI chord: