Skip to content
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

List's of custom scalar types no longer work as arguments with Jackson 2.10 #635

Closed
alexsparrow opened this issue Mar 8, 2020 · 6 comments
Labels
type: bug Something isn't working

Comments

@alexsparrow
Copy link

alexsparrow commented Mar 8, 2020

Library Version
2.0.0-RC10

Describe the bug
As noted in #518, the behaviour of convertValue appears to have changed in Jackson 2.10 so that it no longer short-circuits when the input value is already of a suitable type.

For my use case, this causes an issue when a function on my TopLevelObject takes a list of non-primitive types e.g.

fun foo(ids: List<UUID>)

I have registered UUID as a scalar type using SchemaGeneratorHooks and defined a suitable Coercing for it.

With Jackson 2.9.X, this works as expected.

With Jackson 2.10.X, when I try to query this function, I get an exception like:

java.lang.ClassCastException: class java.lang.String cannot be cast to class java.util.UUID (java.lang.String and java.util.UUID are in module java.base of loader 'bootstrap')

I believe this is due to the usage of convertValue in FunctionDataFetcher.convertParameterValue. In Jackson 2.10.X the list will always go through a serialization/deserialization step, losing the type information.

To Reproduce
See above.

Expected behavior
Expect the List<UUID> to be forwarded as-is to my function.

Thanks for any help :-)

@alexsparrow alexsparrow added the type: bug Something isn't working label Mar 8, 2020
@alexsparrow alexsparrow changed the title List's of primitive types no longer work as arguments with Jackson 2.10 List's of custom scalar types no longer work as arguments with Jackson 2.10 Mar 8, 2020
@smyrick
Copy link
Contributor

smyrick commented Mar 9, 2020

@alexsparrow Can you verify that you can run #636 locally? I checked out from the master branch I am not seeing any errors and we are running on jackson 2.10.2

Do you happen to be running groovy? I found this issue related to something similar https://bugs.openjdk.java.net/browse/JDK-8218540

@alexsparrow
Copy link
Author

Hey @smyrick thanks for the response and the tests! I left a couple of comments on your PR.

I don't think I'm running groovy (and definitely for the code that's causing the error).

@smyrick
Copy link
Contributor

smyrick commented Mar 9, 2020

@alexsparrow Ah, yes. I see now. It seems that we lose the information for converting custom scalars. We only added support for lists as input types in this PR: #546

If you change the type to Array<UUID> then it should work. I will investigate why Lists are not working.

@smyrick
Copy link
Contributor

smyrick commented Mar 9, 2020

@alexsparrow I found the issue. It was infact in FunctionDataFetcher. I updated my PR to include the bug fix

@alexsparrow
Copy link
Author

Awesome thanks a lot for looking into this. The bug fix looks good and the workaround with Array is handy in the meantime.

@smyrick
Copy link
Contributor

smyrick commented Mar 12, 2020

Fixed in #636

@smyrick smyrick closed this as completed Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Development

No branches or pull requests

2 participants