I am implementing GraphQL API using Spring for GraphQL project and the GraphQL Java Extended Scalars project for handling JSON attributes since the data attribute I have is dynamic and its structure is not known by the server.
This JSON attribute is part of the payload in a mutation input, which POJO looks like this:
@Accessors(fluent = true)
@Builder
@Data
@JsonDeserialize(builder = MutationInputModel.MutationInputModelBuilder.class)
public class MutationInputModel {
private JsonNode data;
...
}
As exemplified above, I am using Lombok annotations for deserialization and accessors generation.
The data
attribute is Jackson's JsonNode
type.
However, when calling this mutation I'm getting the following exception:
org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.fasterxml.jackson.databind.JsonNode]: Is it an abstract class?; nested exception is java.lang.InstantiationException
On a previous GraphQL API implementation using this library this same model would work just fine.
My question is how to properly setup JSON scalar type on the POJOs?
I have tried Jackson's ObjectNode
and Map<String, Object>
with no luck neither.