title: Graphql Tools: Map entity type to graphql type
body: <p>I'm using graphql java tools in my spring application. I have an entity like this:</p>
  
  <pre><code>@Entity
  data class Image(
          @Id
          @GeneratedValue(strategy = GenerationType.SEQUENCE)
          @Column(nullable = false)
          val id: Long = 0
  ) {
      @Lob
      @Column(nullable = false)
      var image: Blob? = null
  }
  </code></pre>
  
  <p>And in the GraphQL schema I want to have a different type:</p>
  
  <pre><code>type Image {
      id: ID!
      image: String!
  }   
  </code></pre>
  
  <p>Starting this won't work, of course, because of a schema parsing exception.
  So I thought it must be possible to put something in between the schema parsing to implement a mapping from <code>Blob</code> to <code>String</code>.</p>
  
  <p>Is this somehow possible here?</p>
  
  <pre><code>@Bean
  fun schemaParserDictionary(): SchemaParserDictionary {
      return SchemaParserDictionary()
  }
  </code></pre>
  
  <p><em>EDIT</em></p>
  
  <p>Sorry, it won't give a schema parsing exception. It will simply put the bytes into a string. But I can't use that string then to create the image.</p>
  
  <p><em>Clarification</em></p>
  
  <p>Sorry, I guess I was not clear enough with my question. I don't need to know how to transform a blob into a string. There are very easy solutions for that. For example I can use a simple API function to transform byte code into base64:</p>
  
  <pre><code>val base64 = Base64.getEncoder().encodeToString(byteCode)
  </code></pre>
  
  <p>What I tried to ask was how I can "tell" graphql schema parser to use that "custom" transformation for a specific field. So when my entity object has the field <code>image</code> with datatype <code>blob</code> graphql is automatically transforming this to a <code>string</code>. But the string does not contain the content that I need. So I want to use a custom parsing / mapping / transformation / whatever for that particularly field. Of course, I could also easily get around this by introducing another field which I do not store in the database:</p>
  
  <pre><code>@Entity
  data class Image(
          @Id
          @GeneratedValue(strategy = GenerationType.SEQUENCE)
          @Column(nullable = false)
          val id: Long = 0
  ) {
      @Lob
      @Column(nullable = false)
      var image: Blob? = null
  
      @Transient
      var base64: String = ""
  }
  </code></pre>
  
  <p>but which I make queryable through the graphql api:</p>
  
  <pre><code>type Image {
      id: ID!
      image: String!
      base64: String!
  }
  
  type Images {
      images: [Image!]!
      totalCount: Int!
  }
  
  type Query {
      getImages: Images!
  }
  </code></pre>
  
  <p>And set it in my controller:</p>
  
  <pre><code>private fun getImages(): Images {
      var images: List&lt;Image&gt; = repository.findTop1000()
  
      images.forEach {
          it.base64 = Base64.getEncoder().encodeToString(it.image)
  
          queue.offer(it)
      }
  }
  
  </code></pre>
  
  <p>But it would be cleaner if I could tell the graphql schema parser to do that.</p>