Why can't you just build a special GraphQL query with the SQL query you want? I mean having something like
query {
myCustomQuery(...params...) {
id
whatever
}
}
backed by
async function resolver(ctx) {
const rows = await db.query(sql`SELECT yadda as id, badda as whatever FROM dabba JOIN dada ON ...`);
return rows;
}