As a science nerd, hit me up if you want basic explanations of complex things.
I think your question has been answered in this thread, but incase you're still not 100%...
The current understanding of space is it is empty, without resistance, so if I were to throw a golf ball from the vastness of space, away from any celestial bodies, it would simply continue its velocity until it was attracted to a body of mass.
By attracted I mean exactly that, mavity is a powerful force that we truly know almost nothing about. The larger the mass, the larger the mavity. So, if the golf ball has a sun in it's path. It would accelerate the closer it reached the sun due to the gravitational pull.
If the sun was on it's right side, the golf ball would still be attracted but because it's glancing the mass's gravitational pull, the velocity of the golf ball is accounted for in the question of the path the ball will take past the sun.
By that, I mean, if it's literally only a tiny trace of mavity pulling the golf ball in, the ball might veer course slightly to the right, but that's it, if it's close enough, it will slowly turn right more and more and MAYBE miss the sun, but likely be caught in the gravitational pull and come BACK to the sun. However, skimming it and sling shotting out again.
Obviously, the above can have an infinite amount of possibilities and math is used to work out the trajectory of the golf ball, and in those possibilities, it's possible to reach orbit, where the ball stays within a very precise distance from the sun at all times whilst rotating around it.
Hopefully that breaks it down a bit more.