microsoft / graphitation

GraphQL tooling & runtime support needed for MS Teams and beyond
https://microsoft.github.io/graphitation/
MIT License
137 stars 33 forks source link

Revert afterFieldResolve hook invocation #418

Closed sergey-stoyan closed 3 months ago

sergey-stoyan commented 3 months ago
alloy commented 3 months ago

Revert back afterFieldResolve hook invocation way: it is called now when the field is actually resolved.

Hmm, afaik the executor refers to resolving and completing the value separately, so shouldn't this be called afterFieldComplete instead?

sergey-stoyan commented 3 months ago

Hmm, afaik the executor refers to resolving and completing the value separately, so shouldn't this be called afterFieldComplete instead?

Yep, that's why we have 2 hooks: afterFieldComplete and afterFieldResolve. The first one is invoked after the field itself and all it's child fields (if field value is an object) are resolved, so that field resolution can be considered as completed. And the second - when only field itself is resolved, and it's current implementation does not fully correspond to "afterResolve" concept, since the promise could be returned for async resolver. This PR changes that behavior to invoke afterResolve when the field value is actually resolved for both sync and async resolvers.