We study the spin transport in the quantum Heisenberg spin chain subject to boundary magnetic fields and driven out of equilibrium by Lindblad dissipators. An exact solution is given in terms of matrix product states, which allows us to calculate exactly the spin current for any chain size. It is found that the system undergoes a discontinuous spin-valve-like quantum phase transition from ballistic to sub-diffusive spin current, depending on the value of the boundary fields. Thus, the chain behaves as an extremely sensitive magnonic logic gate operating with the boundary fields as the base element.