You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
allow coercing's parseLiteral to return null #1362
I am implementing a custom scalar called LocalDateTime which parse a string input to java.time.LocalDateTime. when I accept a null or empty string, I want to interpret it as a null LocalDateTime, but Coercing interface doesn't allow me to return a null value.
a possible solution is to provide a config to ScalarType
I would need to check the spec again, but I am not sure this is allowed: you will not get null as argument in a scalar, because null means null and no coercing is needed. The question is now if you are allowed to return null, and I don't think so (but I maybe wrong): A non null scalar value must result in a non null coerced value.
Activity
andimarek commentedon Dec 26, 2018
I would need to check the spec again, but I am not sure this is allowed: you will not get null as argument in a scalar, because null means null and no coercing is needed. The question is now if you are allowed to return null, and I don't think so (but I maybe wrong): A non null scalar value must result in a non null coerced value.
bbakerman commentedon Dec 28, 2018
Also check out https://github.com/graphql-java/graphql-java-extended-scalars
andimarek commentedon Jan 21, 2019
After looking more into this issues we agree: we should allow returning
nullvalues from a Scalar forserialize.graphql-js also added it explicitly: graphql/graphql-js@daa7759
andimarek commentedon Jan 21, 2019
@HenryLauu do you need it for
parserLiteralorserialize?