The very annoying answer "Don't do that then!"
is nevertheless possibly the simplest advice.
On your suggestion: I doubt that this is the best way
for Stata to go.
The command a user types that creates a graph could be
a call to a .do file or a user-written program.
That's likely no problem to you, assuming that you can
find or re-create such a .do file or user-written
program, but it is a bad principle for a Stata
graph (file) to contain information that Stata
can't guarantee to make sense of. For example,
the other file could easily have been lost,
discarded or modified.
In fact, Stata graph files do contain far more
information that can be used. Exploiting the way that
graphs use sersets offers one path here. Vince
Wiggins' talk at the London users' meeting,
recently made available, offers some explanation
and examples.