Skip to content
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

Properly handle nil interface resolvers #239

Merged
merged 4 commits into from
Oct 8, 2018

Conversation

tsholmes
Copy link
Contributor

fixes #233

Calling reflect.ValueOf(nil) returns the zero Value, which has type Invalid.
Calling reflect.ValueOf an interface typed nil returns a Value with type Interface.

Both of these cases skipped the null checks and fail later on when trying to resolve fields.

@tonyghita
Copy link
Member

Thanks for the contribution! Can we add a test case for this?

@zombor
Copy link

zombor commented Sep 21, 2018

Hello-

We've ran into this issue on our local server. What kind of test case would be appropriate in order to merge this fix?

@sqs
Copy link
Contributor

sqs commented Sep 29, 2018

I added a test case (as requested in #239 (comment)) in another PR based on this PR: wandb#1.

@tonyghita If you'd like to merge this now, feel free to just cherry-pick my commit or whatever. Thanks!

Prior to the fix, the new TestNilInterface test would fail with:

  graphql: panic occurred: reflect: Method on nil interface value
@tsholmes
Copy link
Contributor Author

tsholmes commented Oct 1, 2018

Thanks @sqs for fixing this up! @tonyghita is this good to merge now?

graphql_test.go Outdated
"testing"
"time"

"github.com/graph-gophers/graphql-go"
graphqlerrors "github.com/graph-gophers/graphql-go/errors"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you, please, rename this graphqlerrors -> gqlerrors to be shorter and to be consistent with gqltesting?

internal/exec/exec.go Show resolved Hide resolved
@pavelnikolov
Copy link
Member

Thank you for your contribution!

@pavelnikolov pavelnikolov merged commit a2b6fc3 into graph-gophers:master Oct 8, 2018
tinnywang pushed a commit to tinnywang/graphql-go that referenced this pull request Dec 13, 2018
Properly handle nil interface resolvers
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

Successfully merging this pull request may close these issues.

Interface can't be used as nullable resolver
5 participants