houdini: Filtering items with duplicate IDs on Insert

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.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16

Most upvoted comments

@thormuller - that happens here

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)

Thanks as always for a detailed and thoughtful response. These are perfectly reasonable approaches, and I certainly agree on avoiding extra complexity. I’ll give your block a try and report back.