Is it expected that object property names cannot be mapped in the client response using @Name annotation? #2157
Replies: 5 comments 1 reply
-
Yes you should be able to use |
Beta Was this translation helpful? Give feedback.
-
I can't reproduce this problem (... or what do you actually get as the behavior?).
Then in the generated query, it asks for So if it doesn't work correctly for some cases, I think I need a reproducer. To see the generated query, add this to the configuration:
|
Beta Was this translation helpful? Give feedback.
-
@jmartisk , @phillip-kruger, here is the reproducer (see tests) |
Beta Was this translation helpful? Give feedback.
-
Hello @alexpoletaev
Please see a test: |
Beta Was this translation helpful? Give feedback.
-
@mskacelik thank you for the answer, but there is no way I can change the response from the 3rd party API in real project. The real response almost the same as I posted here earlier and I need a way to map those properties into the java class. And you are saying that there is no way to map class properties in the graphql client response with the builtin annotations from the graphql module and I need a 3rd party library (jackson) for that, am I right? Honestly, that sounds strange. Or do I miss something? UPD: From the test I see that it's possible to workaround that with the graphql aliases, but I want to understand if it's possible to do within Java code without 3rd party libraries. Thanks in advance. |
Beta Was this translation helpful? Give feedback.
-
I'm not sure if it's feature or bug, but I haven't find a way how to map object properties with different names from the client response using native smallrye graphql
@Name
annotation.For example, I'm getting next response:
since those property names are reserved in Java, I cannot use same names for the properties. I though it's possible to use a
@Name
annotation like this:however here you will find that it takes an alias for name and according to this method it seems that it should be possible to use
@Name
annotation, but here you will find that if the@Name
annotation is used, then the raw name is returned. The workaround is to use the Jackson's@JsonProperty
annotation, but I think it should be possible to do the same with the@Name
annotation as wellBeta Was this translation helpful? Give feedback.
All reactions