First a caveat: An object with mass can’t move at the speed of light, but it could move at speeds arbitrarily close to that.
The most successful model of gravity isGeneral Relativity, which treats gravity as a curvature of 4-dimensional space time. Gravity’s influence travels at the speed of light. There’s a classic thought experiment that sort of answers your question: what would happen if the sun was teleported away? The answer is the earth would continue to orbit around the spot the sun was for 8 minutes, and we would continue to see sunlight for that same amount of time since that’s how long it takes light to travel that distance. Then after 8 minutes the sun would disappear and the first “lack of gravity” would reach us, and things would be bad for earth :(
The fact that gravity travels at the speed of light actually leads to an interesting phenomenon: Gravitational waves If a massive object rapidly accelerates (or decelerates), for example a star sized mass moving quickly and then coming to an abrupt stop, it will emit a ripple in space time called a gravitational wave that will travel outward at the speed of light.
It was big news about a decade ago when gravitational waves were first detected by LIGO, a series of large interferometers that look for expansion/contraction in spacetime. Their first detection was the collision of 2 black holes; as the black holes spiral around each other and eventually merge, they emit oscillating waves with increasing frequency. They made a cool video showing how the frequency increases by converting it to sound.
Since then LIGO and VIRGO (similar European collaboration) have detected multiple gravitational waves from the collision of black holes and neutron stars. So not only are gravitational waves a neat validation of general relativity, they’re actually being used to do astronomy.