Parse JSON response into GraphQL response with alias and custom adapter

Hi
I have a use-case of parsing a JSON response into GraphQL response using adapters autogenerated by Apollo Kotlin. I have defined some aliases into my GraphQL query which i want to be mapped accordingly but since there is no information present in Adapters about alias, they would be missed. I had generated alias map using CompiledSelection (also autogenerated by Apollo) but failing to deserialising the response specifically because of Unions.

Example JSON:

{
  "__typename": "ProductHeadline",
  "featuredMessages": [
    {
      "__typename": "EGDSStandardBadge",
      "text": "VIP Access"
    }
  ],
  "primary": "San Carlos Hotel",
  "supportingMessages": [
    {
      "__typename": "EGDSPlainText",
      "text": "Luxury hotel with a 24-hour fitness center and a 24-hour business center"
    }
  ]
}

here featuredMessages and supportingMessages is of type ProductSupportingMessages which is a Union of several types including EGDSStandardBadge and EGDSPlainText

My query is like

productHeadline {
    primary
    featuredMessages {
       ... productSupportingMessages
    }
    supportingMessages {
       ... productSupportingMessages
    }
}

fragment productSupportingMessages on ProductSupportingMessage {
    ... on EGDSStandardBadge {
        badgeText: text
    }
    .... on EGDSPlainText {
        text
    }
}

Hi!

When aliases are used, the JSON response should have the alias as the key of the field. In other words, you should receive something like:

    {
      "__typename": "EGDSStandardBadge",
      "badgeText": "VIP Access"
    }

And the generated adapters will expect this.

Can you double check the response?

Yeah this is the problem, my JSON response has original field instead of alias. So i am searching of the ways to substitute them wherever required. This ideally is handled at graphql-java level i guess and i want to replicate the similar behaviour under my use-case.