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
graphql-js doesn't proactively short-circuit executions when they are guaranteed to end up ignored by a null-bubbling, as long as the execution actually started due to there being Promises involved.
Let’s say you have { x y { ARBITRARY_SELECTION_SET} } } where x has a non-null return type, and x and y both have resolvers that return Promises. And let’s say that x returns a Promise that rejects (or resolves to null). What this means is that we’re going to eventually end up with {data: null} (nothing under y will actually matter), but that graphql-js execution will continue running whatever is under ARBITRARY_SELECTION_SET without any sort of short circuiting. (Its response ends up in a Promise that is being captured by a Promise.all which has already rejected.). In fact, the Promise returned from execute itself can happily resolve while execution is still chugging away on an arbitrary amount of fields under that ARBITRARY_SELECTION_SET. There’s no way to detect from the outside “all the execution related to this operation is done”, nor to “short-circuit” execution so that it stops going.
In an ideal world, we'd be able to stop processing a selection set as soon as it becomes clear that its results will be ignored. At the very least, it would be nice if we didn't continue running new fields after the overall execute Promise resolves.
The text was updated successfully, but these errors were encountered:
(I thought I'd filed this a while ago but apparently not! Came from apollographql/apollo-server#4472 (comment))
graphql-js
doesn't proactively short-circuit executions when they are guaranteed to end up ignored by a null-bubbling, as long as the execution actually started due to there being Promises involved.Let’s say you have
{ x y { ARBITRARY_SELECTION_SET} } }
where x has a non-null return type, and x and y both have resolvers that return Promises. And let’s say thatx
returns a Promise that rejects (or resolves to null). What this means is that we’re going to eventually end up with{data: null}
(nothing under y will actually matter), but thatgraphql-js
execution will continue running whatever is underARBITRARY_SELECTION_SET
without any sort of short circuiting. (Its response ends up in a Promise that is being captured by aPromise.all
which has already rejected.). In fact, the Promise returned from execute itself can happily resolve while execution is still chugging away on an arbitrary amount of fields under thatARBITRARY_SELECTION_SET
. There’s no way to detect from the outside “all the execution related to this operation is done”, nor to “short-circuit” execution so that it stops going.In an ideal world, we'd be able to stop processing a selection set as soon as it becomes clear that its results will be ignored. At the very least, it would be nice if we didn't continue running new fields after the overall execute Promise resolves.
The text was updated successfully, but these errors were encountered: