A test of C P invariance in Higgs boson production via vector-boson fusion has been performed in the H → γ γ channel using 139 fb - 1 of proton-proton collision data at s = 13 TeV collected by the ATLAS detector at the LHC. The optimal observable method is used to probe the C P structure of interactions between the Higgs boson and electroweak gauge bosons, as described by an effective field theory. No sign of C P violation is observed in the data. Constraints are set on the parameters describing the strength of the C P -odd component in the coupling between the Higgs boson and the electroweak gauge bosons in two effective field theory bases: d ˜ in the HISZ basis and c H W ˜ in the Warsaw basis. The results presented are the most stringent constraints on C P violation in the coupling between Higgs and weak bosons. The 95% C.L. constraint on d ˜ is derived for the first time and the 95% C.L. constraint on c H W ˜ has been improved by a factor of 5 compared to the previous measurement.