Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

ever considered db views instead of doing a bunch of joins at fetch time?


Yes, but not every query should be a view (materialized or not) because the ORM doesnt support things like lateral join, cross join, etc.


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;
    }


Well if that is possible, that's great, but when I've asked similar questions before the answer is always to use some external library like joinmonster or whatever.


This is easily possible with the low-level graphql NPM package which is the base of many frameworks. Most give you an option to get through the abstraction and do it.


How refreshing to see something else than foo and bar




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: