Quantum information in electromagnetism and gravity