News for hackers. Stuff that matters.
Re:GraphQL kinda sucks by NonNefarious on Saturday August 06, 2022 @10:56AM (#32368663)
I thought it was supposed to do this, but then discovered that it has no way to express joins.

Has this been addressed? I don't see how you can decouple the back-end data from front-end queries without that.

Re:GraphQL kinda sucks by vikR0001 on Saturday August 06, 2022 @11:20AM (#32368871)
You can do something like this. This query can be created and run on the client:

``` const SAMPLE_JOIN_QUERY = gql` query ($main_data_id: String!) { mainData( main_data_id: $main_data_id) { id main_data_field_1 main_data_field_2 main_data_field_3 related_data{ related_data_field_1 related_data_field_2 related_data_field_3 } } } `; ```

Re:GraphQL kinda sucks by mdaniel on Saturday August 06, 2022 @12:26PM (#32369451)
https://news.ycombinator.com/formatdoc may interest you

    const SAMPLE_JOIN_QUERY = gql`
    query ($main_data_id: String!) {
      mainData( main_data_id: $main_data_id) { 
        id main_data_field_1 main_data_field_2 main_data_field_3 
        related_data {
          related_data_field_1 related_data_field_2 related_data_field_3
        }
      } 
    }`;
Re:GraphQL kinda sucks by NonNefarious on Saturday August 06, 2022 @02:24PM (#32370399)
Thanks!
Re:GraphQL kinda sucks by platz on Saturday August 06, 2022 @11:27AM (#32368943)
in other words, it's up to the folks writing the resolvers to manifest and implement that join as a nested field.
Re:GraphQL kinda sucks by mst on Saturday August 06, 2022 @04:11PM (#32371167)
Which means a lot of the time they end up just caching as hard as they can and hoping that's good enough.

(which is often, honestly, an entirely rational decision in terms of prioritising limited resources, but still makes me sad)

Re:GraphQL kinda sucks by zoover2020 on Saturday August 06, 2022 @12:03PM (#32369231)
Dataloader does this IIRC
Re:GraphQL kinda sucks by initplus on Saturday August 06, 2022 @07:16PM (#32372468)
Right, but on the backend someone had to think ahead of time that somebody would want to JOIN between those two types, and remember to put the field in place, and implement the JOIN.