question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Filtering items with duplicate IDs on Insert

See original GitHub issue

Situation: A list of items is retrieved at load (Active_Items). A subscription fetches the latest item that appears on the server (NewItem). The Insert method within the Subscription adds the latest item to the list, BUT because the latest item is already included in the Active_Items list Svelte generates the following error:

Error: Cannot have duplicate keys in a keyed each

Alas, some Graphql server implementations don’t provide an easy way to limit subscriptions only to mutate events so they’ll start by pulling the latest item. Ideally the Insert method would filter out duplicate ids to avoid this issue.

Thoughts or suggestions? I can probably figure out a workaround with my graphl server (Dgraph) but thought I’d mention the challenge here.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:16

github_iconTop GitHub Comments

1reaction
AlecAivaziscommented, Jun 21, 2021

@thormuller - that happens here

1reaction
AlecAivaziscommented, Jun 14, 2021

Well thank you for making the video! It definitely seems like strange behavior. It’s strange that the example doesn’t behave this way (i see the new records get added to the list). Today is a pretty busy day for me so I dont know if I’ll have time to dive into this but you can try adding something similar to the example app to see if you are noticing the same behavior.

Oh, its also probably worth mentioning that along the way in putting together #95 I did encounter an issue which caused me to clean up a rather ugly part of the cache’s implementation. You might want to try pulling that branch down and see if it fixes the problem (this is a guess on my part, it might not be related at all)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to filter duplicate id products taking in consideration other ...
As for your second question, map will eliminate the duplicate keys values, keeping only last inserted value of the same key. Remember that...
Read more >
Filter for unique values or remove duplicate values
In Excel, there are several ways to filter for unique values—or remove duplicate values: To filter for unique values, click Data > Sort...
Read more >
Filter for Duplicates with Conditional Formatting - YouTube
Learn how to filter for duplicates with conditional formatting in Excel. This video is a free sample lesson from my Filters 101 Course....
Read more >
How to Filter for Duplicates with Conditional Formatting
In this video you will learn one technique to quickly filter a column for duplicate values.
Read more >
How to filter out duplicate IDs leaving only the last duplicate?
The problem is that sometimes, devices are retested within the same dataset, which leads to duplicate values for the ID and wafer columns....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found