You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks good to me, but it is the last line that I am concerned about. They apparently want to ignore their errors and cast them to false (I guess they missed a || null). This works in GraphQL, assuming the schema allows a nullable array. But is this really "the way", dataloader community?
What about doing it like this instead?
returnresults.map((result)=>{if(result.status==='rejected'){if(result.reasoninstanceofError){returnresult.reason;}returnnewError(`Rejected with ${JSON.stringify(result.reason)}`);}returnresult.value;});
The reason for this is because .load doesn't care, it throws as soon at the first sight of trouble anyway. But .loadMany does care and does expect the error to be returned by the batchLoadFn argument.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I was reading this blog post and looked at the code snippet:
It looks good to me, but it is the last line that I am concerned about. They apparently want to ignore their errors and cast them to
false
(I guess they missed a|| null
). This works in GraphQL, assuming the schema allows a nullable array. But is this really "the way", dataloader community?What about doing it like this instead?
The reason for this is because
.load
doesn't care, it throws as soon at the first sight of trouble anyway. But.loadMany
does care and does expect the error to be returned by thebatchLoadFn
argument.So, am I right or did I miss something? 🤔
Beta Was this translation helpful? Give feedback.
All reactions