The problem with gravitational fields is that the force is not constant so we cannot use W = F x d
From Newton's law of gravitation the weight of an object varies with 1/r2
so, to move an object away from the Earth the force needed would also vary with 1/r2

The area under the graph between two values of r, however, does tell us how much work would be needed.
For example to move a mass from A to B the work needed is equal to this area

