Is there a way on how we can be able to merge the existing and incoming data? I am using cache for the data, however, even if the data has been updated, I can still get the previous value (existing) and I am not sure how to display the incoming data. Here is my code:
Query: {
fields: {
category: {
keyArgs: ['categoryid'],
read (data: any) {
return data;
},
merge (existing: any, incoming: any) {
if (!existing) return incoming;
return {
...incoming,
data: {
...existing.data,
items: [...existing.data.items, incoming.data.items]
pagination: incoming.data.pagination
}
};
}
},
}
},
And here is my data:
existing = {
categoryid: 10,
items: [
{
"productid": "123",
"isnew": true
},
{
"productid": "456",
"isnew": true,
}
]
}
incoming = {
categoryid: 10,
items: [
{
"productid": "123",
"isnew": false
},
{
"productid": "456",
"isnew": false,
}
]
}
Really appreciate it if someone can help me. Thanks