That's one of the problems that GraphQL is intended to solve, specifically you don't want to write your API queries directly in SQL but you also want the flexibility to chain queries together and specify the exact types of data you require.
For an internal hackathon we basically tried to do this but ran out of time. We built our own query driven API layer that is basically a shim over datomics query and pull apis.