How to correctly return errors and partial data in list query #1161
Unanswered
tsteenkamp
asked this question in
Q&A
Replies: 1 comment 6 replies
-
You need to throw the error, not return the error. const list = ids.map(id => products.find(product => product.id === id));
if (list.some(item => item === undefined)) {
throw new Error("...");
} |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
so I have a root query that receives a list of IDs of entities and should return details about those or an error if it cannot find the corresponding entity. For example:
If I query now something like:
I can see in stdout the expected list of two Products and one GraphQLError, but the graphql response object only contains the errors map, not the valid partial data.
Is there a way to return partial valid data in this case? I'm pretty sure I have seen other / more deeply nested requests, where type-graphql handled partial data and errors as I expected it to do. I was surprised that this was handled as if the error was thrown, altough it is "only" mapped into the result set.
Beta Was this translation helpful? Give feedback.
All reactions