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 } } } `; ```
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!
in other words, it's up to the folks writing the resolvers to manifest and implement that join as a nested field.
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
Has this been addressed? I don't see how you can decouple the back-end data from front-end queries without that.