Issues with response serialization #1742
Replies: 4 comments 3 replies
-
Hello, I'm trying to do the same but it doesn't work for me. |
Beta Was this translation helpful? Give feedback.
-
Hi @cesar05 no I don't have any additional information. Maybe we should file an issue as this got no traction. |
Beta Was this translation helpful? Give feedback.
-
If you're calling using a In short, there is no way to control what is returned in the data property directly. For Scalar types, you can control things via a Coercing implementation registered as a bean. If your GraphQL schema doesn't match what your pojo looks like, you need to register a custom |
Beta Was this translation helpful? Give feedback.
-
JSON / Jackson serialization is not involved here at all. If your schema field name diverges from the getter name of your POJO, you need to register a custom DataFetcher (see the graphql-java docs here). By default, graphql-java will try to find a getter that matches the name in the schema. Here's a solution from a similar reported issue. |
Beta Was this translation helpful? Give feedback.
-
Hello, I'm a little unclear about how to go about using Jackson to serialize objects. I have an annotated POJO:
and am invoking GraphQL through the DGS framework:
The
data
property that I get back is anObject
typedLinkedHashMap
that does not appear to have followed the Jackson annotations:It appears that something has per-emptively changed the type to
LinkedHashMaps
prior to running Jackson serialization, resulting in the actual field names, not the annotated JSON properties.If I manually serialize it I get the expected result (the property obeys the
@JsonProperty
annotation):I tried to override the
ObjectMapper
but I still see the same behavior.Beta Was this translation helpful? Give feedback.
All reactions