Skip to content

Extension ResolveFieldFinishFunc executed before resolver runs value function #483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
benmai opened this issue May 24, 2019 · 0 comments

Comments

@benmai
Copy link

benmai commented May 24, 2019

When using an extension with a schema which has a resolver that returns a function value, e.g.

func(p graphql.ResolveParams) (interface{}, error) {
        return func() (interface{}, error) {
                return "hello", nil
        }, nil
}

the ResolveFieldFinishFunc (as registered by the ResolveFieldDidStart method on the extension) is called before the function value is executed. If I'm reading the source correctly below for resolveField, resolveFieldFinishFn is called immediately after the resolveFn, but before completeValueCatchingError actually evaluates the resolver value if it is a function.

graphql/executor.go

Lines 657 to 663 in bed865f

extErrs = resolveFieldFinishFn(result, resolveFnError)
if len(extErrs) != 0 {
eCtx.Errors = append(eCtx.Errors, extErrs...)
}
completed := completeValueCatchingError(eCtx, returnType, fieldASTs, info, path, result)
return completed, resultState

Is there a reason for this? Since the Extension interface was created in part to support tracing use cases as per #448, that we would want to only run the ResolveFieldFinishFunc after the resolver value is fully evaluated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant