How are warlocks viable at higher levels?

Im just getting started and am interested in the warlock class. From reading a bunch on this class it seams like the easiest way to play one is as an Eldritch Blast spammer. I understand the damage output can be quite high.

However, at mid to high levels don’t enemies start having resistance to spells below a certain level, making EB unviable? With so few spells seems like at this point the Warlock won’t be useful in combat any more under those scenarios. I understand that not all encounters will play out like that, but it’s a pretty big deficiency.