Suspending resolution of field until sibling and all its children are resolved

I’m running into an interesting situation where I would like to suspend the resolution of a field until all the children of the sibling are resolved. This can get very nested.

metadata {
 detailText  # 0
 results {
    detailText # 1
    children {
      detailText # 2

The value of detailText (0) depends on whether any of detailText within the sibling results has a value. I’ve tried using dataloader but that didn’t work when the data was deeply nested for example if detailText (2) had value.

Any advice here on how to approach this would be much appreciated. Thanks!

Hey @nupurjain09 that’s definitely an interesting situation!

I would consider changing how you approach the problem, because nothing requires that the end user even query those fields. children {detailText} has to get its data from somewhere, so you need to fetch that same data at the metadata { detailText } level too. Ideally you can fetch it with keys such that when the child fields hit dataloader it can used the cached values already.

In short, fields should always be responsible for querying their own data, whatever that should be. They can’t depend on the presence or absence of other fields. You can set up that fetching to try to batch and cache stuff, but relying on a specific execution order is not reliable.