Weapon swapping should be the highest priority input and execute even if other commands (such as attacking) are queued. This is most apparent on builds that swap weapons often, such as Assail Psyker and Weapons Specialist Veteran.
For example, if I’m playing a Psyker and tossing Assail shards then try to swap to my melee weapon, the weapon swap may be ignored if I were pressing the attack button at the same time. This can also lead to overloading peril if additional Assail shards are thrown when the player was intending have their melee or ranged weapon selected.
There is a mod that attempts to address this issue, but it should really just be in the base game. When a weapon swap input is sent, the swap should happen as soon as possible, ignoring other attack inputs until after the swap.