I’m getting warnings about “Cache data may be lost”, so I decided to check if there are missing IDs by adding a custom function:
dataIdFromObject(responseObject) {
const id = defaultDataIdFromObject(responseObject);
return id;
}
Most responseObjects are shaped like this:
{
"id": "1",
"__typename": "Event",
// other fields
}
Those are correctly assigned IDs. But I noticed some like this:
{
"event": {
"id": "1",
"__typename": "Event",
// other fields
}
}
I traced this back to a mutation that looks like this:
mutation DoAThing($id: ID!) {
event: doAThing(id: $id) {
id
// other fields
}
}
So it’s nesting the result for some reason. I tried removing the alias, but it’s the same shape, just not aliased.
What am I doing wrong? Do I need a custom function to handle this case? Seems like a vanilla case.