Your argument applies to any particle. You could just as well ask about an electron flying through space interacting with the gravitational fields of other objects. However we know that electrons can be diffracted just like photons. Incidentally there is a new paper on electron diffraction that is interesting reading if not especially surprising.
We don't have a way of describing a quantised gravitational interaction because we don't have a quantum theory of gravity. However in the electron case you could let it interact through the electromagnetic field - after all this is another inverse square law field. If you use an electromagnetic detector to determine which slit the electron went through the diffraction pattern disappears, because localising the electron has made it's momentum uncertain.
So assuming you could find a sensitive enough gravitational detector, using it to determine which slit the photon passed through would localise the photon and prevent the diffraction pattern forming. In practice the experiment is unfeasible anyway since a photon with enough energy to interact gravitationally would have far too small a wavelength for the diffraction to be observed. Indeed, although I haven't done the maths I'm pretty certain your solar mass photon would form a black hole.