u/sunagainstgold dealt with the medieval issue several years ago, in a related question about why African people are called "black"
In addition to the sources she listed back then, there has been a lot of work done more recently, perhaps most importantly Geraldine Heng, The Invention of Race in the European Middle Ages (Cambridge University Press, 2018). I don't recall any AH answers dealing with Heng's book specifically but maybe someone else can talk about it here.