I am returning MOCK JSON response for GraphQL query response in Apollo iOS client. But Apollo client is not parsing the MOCK json content.
Error: __typename missing in mock response.
I found the solution after spending some time on Apollo Client framework iOS.
Mock JSON response must contains __typename key-value in each structure inside it. So that Apollo client decoding functions can decide the corresponding struct models for the response.
{
"data": {
"summary": {
"__typename": "AccountSummaryResponse"
"accountSummary": [{
"token": "45454"
"type": "club"
"__typename": "AccountSummary"
},
{
"token": "4344"
"type": "clubA"
"__typename": "AccountSummary"
}
]
}
}
}
You will get the __typename value from API.swift automated generated file by Apollo Code-gen.