I just ran into an issue in our staging environment that produced an interesting question.
If a subgraph resolves out a reference to an Entity using what it believes to be a viable key, and another subgraph attempts to resolve that reference and fails, misleading errors are produced. In this instance, we were returning an array of Entity references, with one or more failing to be resolved. Any of these bad references causes the entire array to fail to resolve.
So instead of
[ validEntity, validEntity, badReferenceError, validEntity ]
I’m just getting
This feels… bad. At this point the errors that we’re getting are
Cannot return null for non-nullable field X, which isn’t the actual error, the error is that the reference is bad.
Is there a way to handle this? The second subgraph doesn’t really get an option to tell gateway/router that the reference is bad and to
null out the Entity, right? Seems like that’s what we’d want to do. Either null out the entity or remove it from the return array. We can’t do that AFAIK, so instead we run head first into nullability issues on all of the fields selected.
I would currently expect that even if we don’t have a way to handle these issues and remove or null out the reference, we should at least have the resolvable references returned to the client, right? Is it possible that I have a bad configuration somehow that is preventing this? Should I throw instead of returning
undefined in the reference resolver?