How to get sub graph with custom query

@gerrit.meier Any thoughts on this...?

I also tried this, both Database-side reduction (which was very slow) and Client-side reduction (was not working and can't really recall the reason, it's been some days now) and I don't know what else to try.

Any help would be appreciated