java.lang.Object
com.graphql_java_generator.client.GraphQLJsonMapper

public class GraphQLJsonMapper extends Object
This class is a wrapper around an ObjectMapper. It allows the GraphQL plugin generated code to use its own ObjectMapper, without interfering with the containing app. This insures that the containing app can configure and use "its" ObjectMapper as it wants, and that the GraphQL plugin can use its own ObjectMapper with its own configuration.
This class is not Spring bean, as it is configured for each request, with the list of alias for this GraphQL request.
Author:
etienne-sf
  • Constructor Details

    • GraphQLJsonMapper

      public GraphQLJsonMapper(String graphQLObjectsPackage, Map<Class<?>,Map<String,Field>> aliasFields, String schema)
      Standard creator for the GraphQL ObjectMapper
      Parameters:
      graphQLObjectsPackage - The package where the GraphQL objects have been generated
      aliasFields -
      schema - The schema name, for which this object mapper is created. This allows to retrieve the class, possibly generated, that applies to a type
  • Method Details

    • getAliasValue

      public Object getAliasValue(tools.jackson.core.JsonParser parser, Field targetField, tools.jackson.core.TreeNode value) throws IOException, GraphQLRequestExecutionException
      Parse a TreeNode, and return it as a value, according to the given classes
      Parameters:
      parser - The current json parser
      targetField - The field on which an alias has been set. This allows to retrieve the annotation on this field, to know everything about it's properties, as defined in the GraphQL schema.
      It may be null, in which case enumeration values won't be properly deserialized.
      value - The value to parse
      Returns:
      The parsed value. That is, according to the above sample: a String, a List or a List<List>
      Throws:
      IOException
      GraphQLRequestExecutionException
    • convertValue

      public Map<String,tools.jackson.databind.JsonNode> convertValue(tools.jackson.databind.JsonNode extensions, tools.jackson.core.type.TypeReference<Map<String,tools.jackson.databind.JsonNode>> typeReference)
    • convertValue

      public <T> T convertValue(Object o, Class<T> clazz)
    • readValue

      public <T> T readValue(String msg, Class<T> subscriptionType) throws tools.jackson.databind.DatabindException, tools.jackson.core.JacksonException
      Throws:
      tools.jackson.databind.DatabindException
      tools.jackson.core.JacksonException
    • readTree

      public tools.jackson.databind.JsonNode readTree(String content) throws tools.jackson.databind.DatabindException, tools.jackson.core.JacksonException
      Throws:
      tools.jackson.databind.DatabindException
      tools.jackson.core.JacksonException
    • treeToValue

      public <T> T treeToValue(tools.jackson.core.TreeNode value, Class<T> clazz) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • treeToValue

      public <T> T treeToValue(Map<?,?> map, Class<T> clazz) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • treeToValue

      public <T> T treeToValue(List<?> list, Class<T> clazz) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • writeValueAsString

      public String writeValueAsString(Object o) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • valueToTree

      public tools.jackson.databind.JsonNode valueToTree(Object o)
      See Also:
      • ObjectMapper.valueToTree(Object)