So whether or not you use an ORM is up to you, that’s not quite the bottleneck. Most companies are going to use an ORM for convenience, since you really don’t lose much in efficiency. I believe in the real world, the ORM would use a join as well, that was just rough SQL to save space and get the idea across. I want to stress though, that it’s realy not an ORM or handwritten issue, the issue with GraphQL is that you HAVE to split those queries up.
In GraphQL, even handwritten, your query simply wouldn’t have access to that array of author IDs. The GQL query:
{ authors {
books {
title
}
}
}
at the authors level is where the big “get all authors” query goes, and if you tried to shove that into the books resolver, now you’re over fetching, since your making the same query twice. Plus, it would break you GQL, since you only want the books from that author to appear in that author’s books field. And if you wrote a query at the books level that not only fetches all the authors, and all their books, AND filters using the parent_author object’s id, well now we’re reaching levels of inefficiency that shouldn’t even be possible.
Does that make sense?