News for hackers. Stuff that matters.
Re:RedwoodJS 1.0 by replygirl on Monday April 04, 2022 @02:33PM (#30910380)
ever considered db views instead of doing a bunch of joins at fetch time?
Re:RedwoodJS 1.0 by Exuma on Monday April 04, 2022 @04:11PM (#30911432)
Yes, but not every query should be a view (materialized or not) because the ORM doesnt support things like lateral join, cross join, etc.
Re:RedwoodJS 1.0 by emteycz on Monday April 04, 2022 @09:21PM (#30914173)
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;
    }
Re:RedwoodJS 1.0 by Exuma on Monday April 04, 2022 @09:45PM (#30914354)
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.
Re:RedwoodJS 1.0 by emteycz on Tuesday April 05, 2022 @07:50AM (#30917798)
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.
Re:RedwoodJS 1.0 by szundi on Tuesday April 05, 2022 @04:31AM (#30916580)
How refreshing to see something else than foo and bar