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
Hi there, in my Netflix DGS schema I have defined objects with fields of the type JSON Scalar since they are String types in the database/entity being returned in the data fetcher, but I want to display them as JSON in my response.
My issue is that in order for a particular field to display as JSON, I cant simply use the JSON scalar on a String field that exists in my entity. Instead I needed to create a separate DTO to the entity containing the field, and make the corresponding field of the type Map. This means that in my data fetcher, I use Jackson Object Mapper to convert my String to a Map, and set the DTO field to this map, returning the DTO in my data fetcher.
How can i convert the string to JSON without having to make a separate DTO with a Map type for the field that needs to be displayed as JSON? I thought the JSON scalar would automatically work on String types
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there, in my Netflix DGS schema I have defined objects with fields of the type
JSON Scalarsince they are String types in the database/entity being returned in the data fetcher, but I want to display them as JSON in my response.My issue is that in order for a particular field to display as
JSON, I cant simply use theJSON scalaron a String field that exists in my entity. Instead I needed to create a separate DTO to the entity containing the field, and make the corresponding field of the typeMap. This means that in my data fetcher, I use Jackson Object Mapper to convert myStringto aMap, and set the DTO field to this map, returning the DTO in my data fetcher.How can i convert the string to JSON without having to make a separate DTO with a
Maptype for the field that needs to be displayed as JSON? I thought the JSON scalar would automatically work on String typesNote - I created and defined the JSON scalar manually via DgsRuntimeWiring as mentioned in the docs https://netflix.github.io/dgs/scalars/
Beta Was this translation helpful? Give feedback.
All reactions