houdini 1.5.6 → 1.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -72562,20 +72562,21 @@ var CacheInternal = class {
72562
72562
  }
72563
72563
  } else if (Array.isArray(value) && (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
72564
72564
  let oldIDs = [...previousValue || []];
72565
- const emptyEdges = !updates ? [] : oldIDs.map((id) => {
72566
- if (!id) {
72567
- return "";
72568
- }
72569
- const { value: cursorField } = this.storage.get(id, "cursor");
72570
- if (cursorField) {
72571
- return "";
72572
- }
72573
- const { value: node } = this.storage.get(id, "node");
72574
- if (!node) {
72575
- return "";
72576
- }
72577
- return node;
72578
- });
72565
+ if (updates?.includes("append") || updates?.includes("prepend")) {
72566
+ oldIDs = oldIDs.filter((id) => {
72567
+ for (const layer2 of this.storage.data) {
72568
+ for (const operation of Object.values(layer2.operations)) {
72569
+ if (operation.fields?.[key])
72570
+ for (const listOperation of operation.fields[key]) {
72571
+ if ("id" in listOperation && listOperation.id === id) {
72572
+ return false;
72573
+ }
72574
+ }
72575
+ }
72576
+ }
72577
+ return true;
72578
+ });
72579
+ }
72579
72580
  let linkedIDs = [];
72580
72581
  const { newIDs, nestedIDs } = this.extractNestedListIDs({
72581
72582
  value,
@@ -72594,39 +72595,45 @@ var CacheInternal = class {
72594
72595
  layer.writeLink(parent2, key, linkedIDs);
72595
72596
  };
72596
72597
  if (applyUpdates && updates) {
72597
- if (key === "edges") {
72598
- const newNodeIDs = [];
72599
- for (const id of newIDs) {
72598
+ const filterIDs = (keep, insert) => {
72599
+ const existingIDs = /* @__PURE__ */ new Set();
72600
+ for (const id of keep) {
72600
72601
  if (!id) {
72601
72602
  continue;
72602
72603
  }
72603
72604
  const { value: node } = this.storage.get(id, "node");
72604
- if (typeof node !== "string") {
72605
+ if (!node) {
72605
72606
  continue;
72606
72607
  }
72607
- if (!node || !this.storage.get(node, "__typename")) {
72608
+ const nodeID = this.storage.get(node, "id");
72609
+ if (!nodeID) {
72608
72610
  continue;
72609
72611
  }
72610
- newNodeIDs.push(node);
72612
+ existingIDs.add(nodeID.value);
72611
72613
  }
72612
- oldIDs = oldIDs.filter((id) => {
72614
+ return insert.filter((id) => {
72613
72615
  if (!id) {
72614
72616
  return true;
72615
72617
  }
72616
- const { value: value2 } = this.storage.get(id, "node");
72617
- const node = value2;
72618
- if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
72619
- return false;
72618
+ const { value: node } = this.storage.get(id, "node");
72619
+ if (!node) {
72620
+ return true;
72620
72621
  }
72621
- return true;
72622
+ const nodeID = this.storage.get(node, "id");
72623
+ if (!nodeID) {
72624
+ return true;
72625
+ }
72626
+ return !existingIDs.has(nodeID.value);
72622
72627
  });
72623
- }
72628
+ };
72624
72629
  for (const update of applyUpdates) {
72625
72630
  if (update !== "replace" && !updates.includes(update)) {
72626
72631
  continue;
72627
72632
  }
72628
72633
  if (update === "prepend") {
72629
- linkedIDs = newIDs.concat(oldIDs);
72634
+ linkedIDs = newIDs.concat(
72635
+ filterIDs(newIDs, oldIDs)
72636
+ );
72630
72637
  if (layer?.optimistic) {
72631
72638
  action = () => {
72632
72639
  for (const id of newIDs) {
@@ -72637,7 +72644,7 @@ var CacheInternal = class {
72637
72644
  };
72638
72645
  }
72639
72646
  } else if (update === "append") {
72640
- linkedIDs = oldIDs.concat(newIDs);
72647
+ linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
72641
72648
  if (layer?.optimistic) {
72642
72649
  action = () => {
72643
72650
  for (const id of newIDs) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "1.5.6",
3
+ "version": "1.5.8",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",