In 5th Edition D&D there are various monsters with immunity or resistance to magic. For example, the Rakshasa is immune to spells of 6th level or lower. Many of these monsters are not also immune/resistant to magical weapons however.
If the monster is attacked with Spiritual Weapon would the immunity/resistance to magic still be in effect?
On the one hand it is a spell which attacks with a "melee spell attack" (phb 278), on the other hand the spell explicitly says it creates a weapon (although "spectral").
Is it merely a spell in the shape of a weapon (and therefore immunities will work on it) or does it conjure a temporary magical weapon (and therefore magic immunities will not work on it)?