graphql-go / graphql

An implementation of GraphQL for Go / Golang
MIT License
9.91k stars 839 forks source link

return nil schema on error #540

Open nasermirzaei89 opened 4 years ago

nasermirzaei89 commented 4 years ago

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 commented 4 years ago

Coverage Status

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

bhoriuchi commented 4 years ago

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 commented 4 years ago

I agree with merge it for a major release.