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
I am trying to create a generic wrapper for the Option type in the Kotlin library, Arrow.
I get the following error: Can't resolve value (/user/register/errors) : type mismatch error, expected type LIST got class arrow.core.None
The error makes sense to me: I am returning an instance of arrow.core.None. "/user/register/errors" is a nullable list of the Error type. GraphQL java tools does not understand that i want to convert the None instance to null.
Im worried if this is even possible at the moment? I was looking at the source code, and it seems that Javas Optional type is handled as a special case, not just a generic wrapper (i think).
I'm hoping someone can tell me if this is possible at the moment, and if not what it would take to make it possible.
Apologies if it is documented somewhere, i couldn't find it :-(
Note: Returning the nullable type in the transformer works on None. So if it is a String? returning "" would work (but is not the ideal solution, we want a null or other None-like scalar).
A workaround I am using now is creating a Union type for every type that I want to have optional. So MaybeUser = User | None and adding the None to the dictionary. Far from ideal.
I think we need to provide a configurable option to handle nullable input argument mapping. Users could provide their own mapping of omitted/null/value to the correct types. It should also solve #388
Edit: Now I see that this is more about the return type than the input argument type.
Activity
ReinierRothuis commentedon May 8, 2020
I am encountering the same problem, all other wrappers are fine, 'Left', 'Right', 'Some'. All except the 'None' data structure.
ReinierRothuis commentedon May 8, 2020
Note: Returning the nullable type in the transformer works on None. So if it is a String? returning "" would work (but is not the ideal solution, we want a null or other None-like scalar).
A workaround I am using now is creating a Union type for every type that I want to have optional. So MaybeUser = User | None and adding the None to the dictionary. Far from ideal.
vojtapol commentedon May 21, 2020
I think we need to provide a configurable option to handle nullable input argument mapping. Users could provide their own mapping of omitted/null/value to the correct types. It should also solve #388
Edit: Now I see that this is more about the return type than the input argument type.
vojtapol commentedon May 21, 2020
Yes,
Optionalis handled as a special case here:graphql-java-tools/src/main/kotlin/graphql/kickstart/tools/TypeClassMatcher.kt
Line 53 in e4690db
The challenge for adding support for Arrow's
Optionwill be to do it without adding dependency on Arrow which we definitely do not want to add.Honor null generic wrapper results