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

return nil schema on error #540

Open
wants to merge 1 commit into
base: master
from

Conversation

@nasermirzaei89
Copy link

@nasermirzaei89 nasermirzaei89 commented Apr 25, 2020

Golang methods shouldn't return zero value structs on error. So, we should return *Schema on the NewSchema method.

Why:
https://groups.google.com/d/msg/golang-nuts/4yBldwsjZwo/sFcz1KVhU3wJ

@coveralls
Copy link

@coveralls coveralls commented Apr 25, 2020

Coverage Status

Coverage remained the same at 92.376% when pulling 51495a7 on nasermirzaei89:pointer-return into 02caa89 on graphql-go:master.

@nasermirzaei89 nasermirzaei89 force-pushed the nasermirzaei89:pointer-return branch from fcd314a to 51495a7 Apr 25, 2020
@bhoriuchi
Copy link
Contributor

@bhoriuchi bhoriuchi commented May 18, 2020

This will break a lot of people's code. So while I agree that it should be done, it should probably be done so in a major release. Additionally you should be checking the error returned before you attempt to access the schema. If the "programmer is to lazy to check the error" then they are probably too lazy to check that the schema returned nil, so they will still get an exception regardless.

@nasermirzaei89
Copy link
Author

@nasermirzaei89 nasermirzaei89 commented May 18, 2020

I agree with merge it for a major release.

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

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.