The constitution allows for the federal government to defend our borders from threats and invasions, but if a state wants to allow illegals in, isn't that a states rights issue? If that were to go to court, who wins? The state, or the federal government?
Here is a very quick stab at it. Very quick. It is a whole lot more complicated than this.
Immigration is an enumerated power, congress has the exclusive power to regulate or not regulate it. Supremecy clause.
But, the question is whether states must use their executive resources to enforce federal law.
In case of California not enforcing fed law on immigration, they likely win.