There are currently cache items that are accessed fine that are simple objects but struggling with what should happen when the object passed in to dataIdFromObject is an object with a key of items which is an array of objects. For example:
const dataIdFromObject = (obj) => {
switch(obj.__typename) {
case 'Post':
return `${obj.__typename}.${obj.categoryId}.${obj.postId}
case 'PostConnection':
return obj.items ? obj.items[0].categoryId : defaultDataIdFromObject(obj)
default:
return defaultDataIdFromObject(obj)
}
}
obj.items
is an array of Post objects.
The problem is that data seems to be cached from other categories from time to time using the first item in the array of the nested item. Is there any issue with doing it this way?
Could there ever be a potential race condition if a request is not cancelled that could cause data from another category to be store under the wrong cache key as when looking in localStorage you would be able to see posts under other lets say category a under category b.
PostConnection.a {
items:
cat a item
cat b item
cat b item
}