consider allowing a sentinel error to be returned instead of nil,nil to indicate null value #1891
Replies: 2 comments
-
Bonus thought: we have our own error type that we use internally to indicate "not found". It would be pretty cool if that could get automatically translated by gqlgen to a null response. |
Beta Was this translation helpful? Give feedback.
-
gqlgen is mapping graphql semantics to go, leaning in favour of graphql. Any error returned by a handler should be surfaced to the client under errors. This would be a deviation from that, requiring us to peel a particular (or worse yet, configurable) sentinel out, return null and not send an error (unless it was a required field) It is interesting though, I'm always on the lookout for good linters that catch bugs. I'm not so sure this one though, given it would generate hits in the stdlib. |
Beta Was this translation helpful? Give feedback.
-
What happened?
I recently turned on the linter https://github.com/Antonboom/nilnil
I noticed that gqlgen encourages writing a lot of code that returns
nil,nil
.What did you expect?
It would be nice if there's a way to return something like
nil, gqlgen.NullObjectError()
Minimal graphql.schema and models to reproduce
Any schema with a non-required field
versions
gqlgen version
? all of themgo version
? n/aAnyway, this is definitely not a real issue/bug. Just an idea.
Beta Was this translation helpful? Give feedback.
All reactions