Using geometry referenced from a Rhino file in a GH definition in the headless mode

Hi All,
I am trying to automate some of my Rhino/GH pipelines using Rhino.Inside. In my use case I have a big Rhino file and a GH definition which uses some referenced geometry as input. I was wondering whether it is possible to replicate this in the headless mode. I managed to open a 3dm file using Rhino.RhinoDoc.OpenHeadless() and successfully process a GH definition . However, when I try to use both of them together the referenced geo is not picked up.

Does anyone have any advice? I was thinking of iterating through the GH inputs, finding GUIDs of referenced objects and then iterating through the RhinoDoc to find the geometries and copying them to the definition but this sounds so excessive…

Any help would be much appreciated.