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
}
}