How can I parse a stored JSON response in React and pass to a component that is expecting graphql response?
This is what I am trying, but it is not reading the data correctly:
const client = new ApolloClient({
cache: new InMemoryCache({ addTypename: true })
});
client.cache.writeQuery({
query: __Query,
data: ratingDataWithoutTypename, // JSON response
});
const ratingSummaryData = client.cache.readQuery<RatingQuery>({ query: __Query });
console.log('ratingSummaryData:', ratingSummaryData);
only root elements are getting read, and the objects are empty - summary
, metadata
:
{
"productRatingSummary": {
"sectionHeadingAccessibilityText": "Reviews",
"summary": {},
"metadata": {},
"info": null,
"impressionAnalytics": null
}
}