title: Graphql get direct requested model
body: <p>I implemented a sample of Graphql by Retrofit. I have a response like this:</p>
  <pre><code>                if (response.isSuccessful) {
                  Log.e(&quot;response&quot;, response.body().toString())
  </code></pre>
  <p>Also, this is my interface class:</p>
  <pre><code>suspend fun postDynamicQuery(@Body body: String): Response&lt;String&gt;
  </code></pre>
  <p>Now I want to change my method by giving a direct model. this is the servers' answer.</p>
  <pre><code>{
  &quot;data&quot;: {
      &quot;getCityByName&quot;: {
          &quot;id&quot;: &quot;112931&quot;,
          &quot;name&quot;: &quot;Tehran&quot;,
          &quot;country&quot;: &quot;IR&quot;,
          &quot;coord&quot;: {
              &quot;lon&quot;: 51.4215,
              &quot;lat&quot;: 35.6944
          }
      }
  }
  </code></pre>
  <p>To give a model answer, I should have a model like this:</p>
  <pre><code>data class CityModel(
      val data: Data
  )
  
  data class Data(
      val getCityByName: GetCityByName
  )
  
  data class GetCityByName(
      val id: String,
      val name: String,
      val country: String,
      val coord: Coord
  )
  
  data class Coord(
      val lon: Double,
      val lat: Double
  )
  </code></pre>
  <p>And these two changes:</p>
  <pre><code>                if (response.isSuccessful) {
                  cityModel = response.body()}
  </code></pre>
  <p>and</p>
  <pre><code>suspend fun postDynamicQuery(@Body body: String): Response&lt;CityModel&gt;
  </code></pre>
  <p>PROBLEM: I want a city model without creating a Data model and a CityModel model. this is a boilerplate to make two extra models for each API.</p>
  <ul>
  <li><p>I used GsonConverterFactory for converting to model:</p>
  <pre><code>      .addConverterFactory(ScalarsConverterFactory.create())
        .addConverterFactory(GsonConverterFactory.create())
  </code></pre>
  </li>
  </ul>