Closed darkedges closed 6 days ago
if I remove the inputs and use env.getArgument("last") it returns the error, so it would appear it is having a hard time converting from a null to an int.
Can you please try using Boxed types? We don't support unboxed types with @InputArgument.
@srinivasankavitha thanks for the very rude shutdown.
I found a bug and reported it as per the contributor guide. No where in the documentation does it say use Boxed Types.
https://netflix.github.io/dgs/datafetching/#using-inputargument
It says you don't have to worry about nulls unless you are using Kotlin.
In Java you don't have to worry about this, types can always be null. You do need to null check in your datafetching code
https://netflix.github.io/dgs/datafetching/#nullability-in-kotlin-for-input-arguments
Will create a pull request highlighting this issue in the documentation repository.
My apologies, I did not intend to shut you down and should not have closed the issue without further clarifiaction. We will update our recommendation to specify usage of Boxed types more clearly. This is missing as you pointed out. Thanks for adding more context.
Reopening this issue. In followup discussions, realized there is indeed a related issue with parsing when input is null.
Updated docs to better clarify the supported/unsupported use cases: https://github.com/Netflix/dgs/pull/110
No problem, been trying to work out how Spring Web Framework handles it,as their primary example handles int
https://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/mvc.html#mvc-ann-requestparam
it talks about https://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/mvc.html#mvc-ann-typeconversion
if the target type is not String, Spring automatically converts to the appropriate type. All simple types such as int, long, Date, etc. are supported.
So if Spring Framework supports it then so could DGS.
This is the DataBinder used https://github.com/spring-projects/spring-framework/blob/main/spring-web/src/main/java/org/springframework/web/bind/WebDataBinder.java
Thanks for the reference. We are using a similar mechanism in the framework and are able to handle the different types. I do need understand more about how null inputs are handled in the case of non-nullable input types.
Primitive types in Java are inherently non-nullable. The only thing the framework could do is set it to 0
or something like that, which I think is the wrong thing to do, because a default value is not the same as a null value.
This practically means you should always use boxed types for nullable values. This is now reflected in the docs, so I'm closing this issue because there is nothing else we can do I think.
Please read our contributor guide before creating an issue.
Expected behavior
To execute and return a value
Actual behavior
Steps to reproduce
Create the above graphl schema file and associated @DSGQuery annotated method as above. Then execute the following query
I cannot use any of the input values, returns
https://github.com/Netflix/dgs-framework/issues/270 says this should not be a problem.
if I remove the inputs and use
env.getArgument("first")
it returns50