-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Null is not treated as a value. #1294
Comments
@nightCapLounge It's expected behavior here is what spec says:
http://facebook.github.io/graphql/draft/#ScalarTypeDefinition Here is direct analogy from JS, e.g. you have overridden
It's absolutely legal but be cautious if you wrap such scalar into Non-Null wrapper it will trigger a runtime error. |
Thank you for the explanation, that tidbit from the spec explains the situation. Though it seems to me that this is a flaw in the spec. Why would it treat the value null exceptionally from other values? This throws a real wrench in the works for any system that uses null as a standard value, (e.g. anything that uses SQL). That wrench is particularly big for someone like myself who wants to implement a translation routine through the custom type system, as I would with any other value. Is there a legitimate reason that I'm missing? @leebyron Insights? |
@IvanGoncharov is correct here. It's quite intentional that I believe the solution to your scenario is just to not rely on custom scalars serialization. In your example I would expect a return type of |
Hello, I have found what I believe to be an issue (v0.11.3). I'm currently writing a custom type and have found that I cannot interact with
null
values. The idea of this snippet is to convert incomingnull
values into -1 and to convert outgoing -1 values intonull
. Here is a quick snippet of a basic implementation:What I find is that these methods are called when an integer is sent with the input type, but are not called when
null
is sent. Why is that? I've read a bunch of issues/articles relating to this issue, many of them indicating that it has been resolved, but it doesn't seem evident.I've also seen indications that GraphQL uses
null
as an indicator that it should omit fields or auto fill them in.Why would a framework that is meant to serve as an interface for databases such as SQL take a valid value such as
null
and apply side effects to the transmission of that value, extending its purpose beyond that of being a simple value?Is what I'm trying to do an anti-pattern? If so, what other solutions are there? Is this not an issue? Suggestions?
Thank you! I'm a huge fan of the GraphQL effort, glad to see that its growing so fast.
The text was updated successfully, but these errors were encountered: