-
I have a super simple todo app. The schema looks like this:
I'm using graphcache to update the cache when the client sends an
However this results in duplication of keys. So far what I have is a check at the callback of Is this be the best way to handle this situation? I also had the thought of sending the Thank you very much for your time! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
That's a really good safe guard and I'd implement that if you can either way. But I'd also check whether the list that you're adding to already has an item with an identical ID. Since it doesn't matter what query you use (or fragment) you'd typically just make a one-off GraphQL query with the list and its keyable fields (e.g. |
Beta Was this translation helpful? Give feedback.
That's a really good safe guard and I'd implement that if you can either way.
But I'd also check whether the list that you're adding to already has an item with an identical ID. Since it doesn't matter what query you use (or fragment) you'd typically just make a one-off GraphQL query with the list and its keyable fields (e.g.
id
); the update of the list item will already be taken care of automatically. So therefore you'd just have to make sure you don't add any duplicates manually