houdini 1.1.1 → 1.1.2

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.
@@ -67191,13 +67191,23 @@ var List = class {
67191
67191
  when(when) {
67192
67192
  return this.manager.lists.get(this.name).get(this.recordID).when(when);
67193
67193
  }
67194
- append(selection, data, variables = {}) {
67195
- return this.addToList(selection, data, variables, "last");
67194
+ append({
67195
+ selection,
67196
+ data,
67197
+ variables = {},
67198
+ layer
67199
+ }) {
67200
+ return this.addToList(selection, data, variables, "last", layer);
67196
67201
  }
67197
- prepend(selection, data, variables = {}) {
67198
- return this.addToList(selection, data, variables, "first");
67202
+ prepend({
67203
+ selection,
67204
+ data,
67205
+ variables = {},
67206
+ layer
67207
+ }) {
67208
+ return this.addToList(selection, data, variables, "first", layer);
67199
67209
  }
67200
- addToList(selection, data, variables = {}, where) {
67210
+ addToList(selection, data, variables = {}, where, layer) {
67201
67211
  const listType = this.listType(data);
67202
67212
  const dataID = this.cache._internal_unstable.id(listType, data);
67203
67213
  if (!this.validateWhen() || !dataID) {
@@ -67275,7 +67285,8 @@ var List = class {
67275
67285
  data: insertData,
67276
67286
  variables,
67277
67287
  parent: this.recordID,
67278
- applyUpdates: [where === "first" ? "prepend" : "append"]
67288
+ applyUpdates: [where === "first" ? "prepend" : "append"],
67289
+ layer: layer?.id
67279
67290
  });
67280
67291
  }
67281
67292
  removeID(id, variables = {}) {
@@ -67368,9 +67379,15 @@ var List = class {
67368
67379
  }
67369
67380
  return ok;
67370
67381
  }
67371
- toggleElement(selection, data, variables = {}, where) {
67382
+ toggleElement({
67383
+ selection,
67384
+ data,
67385
+ variables = {},
67386
+ layer,
67387
+ where
67388
+ }) {
67372
67389
  if (!this.remove(data, variables)) {
67373
- this.addToList(selection, data, variables, where);
67390
+ this.addToList(selection, data, variables, where, layer);
67374
67391
  }
67375
67392
  }
67376
67393
  *[Symbol.iterator]() {
@@ -68378,6 +68395,9 @@ var CacheInternal = class {
68378
68395
  nullable,
68379
68396
  link: !!fieldSelection
68380
68397
  });
68398
+ if (value && typeof value === "object" && "__typename" in value && value["__typename"]) {
68399
+ linkedType = value["__typename"];
68400
+ }
68381
68401
  const currentSubscribers = this.subscriptions.get(parent, key);
68382
68402
  const specs = currentSubscribers.map((sub) => sub[0]);
68383
68403
  const { value: previousValue, displayLayers } = this.storage.get(parent, key);
@@ -68431,7 +68451,6 @@ var CacheInternal = class {
68431
68451
  "Encountered interface type without __typename in the payload"
68432
68452
  );
68433
68453
  }
68434
- linkedType = value.__typename;
68435
68454
  }
68436
68455
  const embedded = this.idFields(linkedType)?.filter(
68437
68456
  (field2) => typeof value[field2] === "undefined"
@@ -68587,7 +68606,8 @@ var CacheInternal = class {
68587
68606
  fieldSelection,
68588
68607
  target,
68589
68608
  variables,
68590
- operation.position || "last"
68609
+ operation.position || "last",
68610
+ layer
68591
68611
  );
68592
68612
  } else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
68593
68613
  this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
@@ -68601,12 +68621,13 @@ var CacheInternal = class {
68601
68621
  }
68602
68622
  this.cache.delete(targetID);
68603
68623
  } else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
68604
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
68605
- fieldSelection,
68606
- target,
68624
+ this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
68625
+ selection: fieldSelection,
68626
+ data: target,
68607
68627
  variables,
68608
- operation.position || "last"
68609
- );
68628
+ where: operation.position || "last",
68629
+ layer
68630
+ });
68610
68631
  }
68611
68632
  }
68612
68633
  }
@@ -68635,7 +68656,7 @@ var CacheInternal = class {
68635
68656
  ])
68636
68657
  );
68637
68658
  }
68638
- let hasData = false;
68659
+ let hasData = !!selection.fragments;
68639
68660
  let partial = false;
68640
68661
  let cascadeNull = false;
68641
68662
  let stale = false;
@@ -68850,13 +68871,12 @@ var CacheInternal = class {
68850
68871
  const embedded = this.idFields(linkedType)?.filter(
68851
68872
  (field) => typeof entry[field] === "undefined"
68852
68873
  ).length > 0;
68853
- const typename = entryObj.__typename;
68854
68874
  let innerType = linkedType;
68855
- if (abstract) {
68856
- if (!typename) {
68857
- throw new Error("Encountered interface type without __typename in the payload");
68858
- }
68875
+ const typename = entryObj.__typename;
68876
+ if (typename) {
68859
68877
  innerType = typename;
68878
+ } else if (abstract) {
68879
+ throw new Error("Encountered interface type without __typename in the payload");
68860
68880
  }
68861
68881
  if (!embedded) {
68862
68882
  const id = this.id(innerType, entry);
@@ -72662,19 +72682,6 @@ function artifactGenerator(stats) {
72662
72682
  if (docKind === ArtifactKind.Fragment && directive) {
72663
72683
  inputs = fragmentArgumentsDefinitions(config4, doc.filename, fragments[0]);
72664
72684
  }
72665
- const mask = selection_default({
72666
- config: config4,
72667
- filepath: doc.filename,
72668
- rootType,
72669
- operations: {},
72670
- document: doc,
72671
- selections: flattenSelections({
72672
- config: config4,
72673
- filepath: doc.filename,
72674
- selections: selectionSet.selections,
72675
- fragmentDefinitions
72676
- })
72677
- });
72678
72685
  let artifact = {
72679
72686
  name,
72680
72687
  kind: docKind,
@@ -72704,7 +72711,23 @@ function artifactGenerator(stats) {
72704
72711
  }),
72705
72712
  pluginData: {}
72706
72713
  };
72707
- applyMask(config4, artifact.selection, mask);
72714
+ applyMask(
72715
+ config4,
72716
+ artifact.selection,
72717
+ selection_default({
72718
+ config: config4,
72719
+ filepath: doc.filename,
72720
+ rootType,
72721
+ operations: {},
72722
+ document: doc,
72723
+ selections: flattenSelections({
72724
+ config: config4,
72725
+ filepath: doc.filename,
72726
+ selections: selectionSet.selections,
72727
+ fragmentDefinitions
72728
+ })
72729
+ })
72730
+ );
72708
72731
  artifact.pluginData = {};
72709
72732
  for (const plugin2 of config4.plugins) {
72710
72733
  if (!plugin2.artifactData) {
@@ -72782,14 +72805,21 @@ function artifactGenerator(stats) {
72782
72805
  };
72783
72806
  }
72784
72807
  function applyMask(config4, target, mask) {
72808
+ const targetFields = Object.entries(target.fields ?? {}).concat(
72809
+ Object.values(target.abstractFields?.fields ?? {}).flatMap((typeMap) => Object.entries(typeMap))
72810
+ );
72785
72811
  for (const [fieldName, value] of Object.entries(mask.fields ?? {})) {
72786
- const targetSelection = target.fields?.[fieldName];
72787
- if (!targetSelection || !mask.fields) {
72788
- continue;
72789
- }
72790
- targetSelection.visible = true;
72791
- if (targetSelection.selection && value.selection) {
72792
- applyMask(config4, targetSelection.selection, value.selection);
72812
+ for (const [potentialFieldName, targetSelection] of targetFields) {
72813
+ if (fieldName !== potentialFieldName) {
72814
+ continue;
72815
+ }
72816
+ if (!targetSelection) {
72817
+ continue;
72818
+ }
72819
+ targetSelection.visible = true;
72820
+ if (targetSelection.selection && value.selection) {
72821
+ applyMask(config4, targetSelection.selection, value.selection);
72822
+ }
72793
72823
  }
72794
72824
  }
72795
72825
  for (const [type, selection] of Object.entries(mask.abstractFields?.fields ?? {})) {
@@ -74400,6 +74430,24 @@ async function addTypename(config4, documents) {
74400
74430
  }
74401
74431
  };
74402
74432
  }
74433
+ },
74434
+ FragmentDefinition(node) {
74435
+ return {
74436
+ ...node,
74437
+ selectionSet: {
74438
+ ...node.selectionSet,
74439
+ selections: [
74440
+ ...node.selectionSet.selections,
74441
+ {
74442
+ kind: graphql23.Kind.FIELD,
74443
+ name: {
74444
+ kind: graphql23.Kind.NAME,
74445
+ value: "__typename"
74446
+ }
74447
+ }
74448
+ ]
74449
+ }
74450
+ };
74403
74451
  }
74404
74452
  });
74405
74453
  }
@@ -67186,13 +67186,23 @@ var List = class {
67186
67186
  when(when) {
67187
67187
  return this.manager.lists.get(this.name).get(this.recordID).when(when);
67188
67188
  }
67189
- append(selection, data, variables = {}) {
67190
- return this.addToList(selection, data, variables, "last");
67189
+ append({
67190
+ selection,
67191
+ data,
67192
+ variables = {},
67193
+ layer
67194
+ }) {
67195
+ return this.addToList(selection, data, variables, "last", layer);
67191
67196
  }
67192
- prepend(selection, data, variables = {}) {
67193
- return this.addToList(selection, data, variables, "first");
67197
+ prepend({
67198
+ selection,
67199
+ data,
67200
+ variables = {},
67201
+ layer
67202
+ }) {
67203
+ return this.addToList(selection, data, variables, "first", layer);
67194
67204
  }
67195
- addToList(selection, data, variables = {}, where) {
67205
+ addToList(selection, data, variables = {}, where, layer) {
67196
67206
  const listType = this.listType(data);
67197
67207
  const dataID = this.cache._internal_unstable.id(listType, data);
67198
67208
  if (!this.validateWhen() || !dataID) {
@@ -67270,7 +67280,8 @@ var List = class {
67270
67280
  data: insertData,
67271
67281
  variables,
67272
67282
  parent: this.recordID,
67273
- applyUpdates: [where === "first" ? "prepend" : "append"]
67283
+ applyUpdates: [where === "first" ? "prepend" : "append"],
67284
+ layer: layer?.id
67274
67285
  });
67275
67286
  }
67276
67287
  removeID(id, variables = {}) {
@@ -67363,9 +67374,15 @@ var List = class {
67363
67374
  }
67364
67375
  return ok;
67365
67376
  }
67366
- toggleElement(selection, data, variables = {}, where) {
67377
+ toggleElement({
67378
+ selection,
67379
+ data,
67380
+ variables = {},
67381
+ layer,
67382
+ where
67383
+ }) {
67367
67384
  if (!this.remove(data, variables)) {
67368
- this.addToList(selection, data, variables, where);
67385
+ this.addToList(selection, data, variables, where, layer);
67369
67386
  }
67370
67387
  }
67371
67388
  *[Symbol.iterator]() {
@@ -68373,6 +68390,9 @@ var CacheInternal = class {
68373
68390
  nullable,
68374
68391
  link: !!fieldSelection
68375
68392
  });
68393
+ if (value && typeof value === "object" && "__typename" in value && value["__typename"]) {
68394
+ linkedType = value["__typename"];
68395
+ }
68376
68396
  const currentSubscribers = this.subscriptions.get(parent, key);
68377
68397
  const specs = currentSubscribers.map((sub) => sub[0]);
68378
68398
  const { value: previousValue, displayLayers } = this.storage.get(parent, key);
@@ -68426,7 +68446,6 @@ var CacheInternal = class {
68426
68446
  "Encountered interface type without __typename in the payload"
68427
68447
  );
68428
68448
  }
68429
- linkedType = value.__typename;
68430
68449
  }
68431
68450
  const embedded = this.idFields(linkedType)?.filter(
68432
68451
  (field2) => typeof value[field2] === "undefined"
@@ -68582,7 +68601,8 @@ var CacheInternal = class {
68582
68601
  fieldSelection,
68583
68602
  target,
68584
68603
  variables,
68585
- operation.position || "last"
68604
+ operation.position || "last",
68605
+ layer
68586
68606
  );
68587
68607
  } else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
68588
68608
  this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
@@ -68596,12 +68616,13 @@ var CacheInternal = class {
68596
68616
  }
68597
68617
  this.cache.delete(targetID);
68598
68618
  } else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
68599
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
68600
- fieldSelection,
68601
- target,
68619
+ this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
68620
+ selection: fieldSelection,
68621
+ data: target,
68602
68622
  variables,
68603
- operation.position || "last"
68604
- );
68623
+ where: operation.position || "last",
68624
+ layer
68625
+ });
68605
68626
  }
68606
68627
  }
68607
68628
  }
@@ -68630,7 +68651,7 @@ var CacheInternal = class {
68630
68651
  ])
68631
68652
  );
68632
68653
  }
68633
- let hasData = false;
68654
+ let hasData = !!selection.fragments;
68634
68655
  let partial = false;
68635
68656
  let cascadeNull = false;
68636
68657
  let stale = false;
@@ -68845,13 +68866,12 @@ var CacheInternal = class {
68845
68866
  const embedded = this.idFields(linkedType)?.filter(
68846
68867
  (field) => typeof entry[field] === "undefined"
68847
68868
  ).length > 0;
68848
- const typename = entryObj.__typename;
68849
68869
  let innerType = linkedType;
68850
- if (abstract) {
68851
- if (!typename) {
68852
- throw new Error("Encountered interface type without __typename in the payload");
68853
- }
68870
+ const typename = entryObj.__typename;
68871
+ if (typename) {
68854
68872
  innerType = typename;
68873
+ } else if (abstract) {
68874
+ throw new Error("Encountered interface type without __typename in the payload");
68855
68875
  }
68856
68876
  if (!embedded) {
68857
68877
  const id = this.id(innerType, entry);
@@ -72656,19 +72676,6 @@ function artifactGenerator(stats) {
72656
72676
  if (docKind === ArtifactKind.Fragment && directive) {
72657
72677
  inputs = fragmentArgumentsDefinitions(config4, doc.filename, fragments[0]);
72658
72678
  }
72659
- const mask = selection_default({
72660
- config: config4,
72661
- filepath: doc.filename,
72662
- rootType,
72663
- operations: {},
72664
- document: doc,
72665
- selections: flattenSelections({
72666
- config: config4,
72667
- filepath: doc.filename,
72668
- selections: selectionSet.selections,
72669
- fragmentDefinitions
72670
- })
72671
- });
72672
72679
  let artifact = {
72673
72680
  name,
72674
72681
  kind: docKind,
@@ -72698,7 +72705,23 @@ function artifactGenerator(stats) {
72698
72705
  }),
72699
72706
  pluginData: {}
72700
72707
  };
72701
- applyMask(config4, artifact.selection, mask);
72708
+ applyMask(
72709
+ config4,
72710
+ artifact.selection,
72711
+ selection_default({
72712
+ config: config4,
72713
+ filepath: doc.filename,
72714
+ rootType,
72715
+ operations: {},
72716
+ document: doc,
72717
+ selections: flattenSelections({
72718
+ config: config4,
72719
+ filepath: doc.filename,
72720
+ selections: selectionSet.selections,
72721
+ fragmentDefinitions
72722
+ })
72723
+ })
72724
+ );
72702
72725
  artifact.pluginData = {};
72703
72726
  for (const plugin2 of config4.plugins) {
72704
72727
  if (!plugin2.artifactData) {
@@ -72776,14 +72799,21 @@ function artifactGenerator(stats) {
72776
72799
  };
72777
72800
  }
72778
72801
  function applyMask(config4, target, mask) {
72802
+ const targetFields = Object.entries(target.fields ?? {}).concat(
72803
+ Object.values(target.abstractFields?.fields ?? {}).flatMap((typeMap) => Object.entries(typeMap))
72804
+ );
72779
72805
  for (const [fieldName, value] of Object.entries(mask.fields ?? {})) {
72780
- const targetSelection = target.fields?.[fieldName];
72781
- if (!targetSelection || !mask.fields) {
72782
- continue;
72783
- }
72784
- targetSelection.visible = true;
72785
- if (targetSelection.selection && value.selection) {
72786
- applyMask(config4, targetSelection.selection, value.selection);
72806
+ for (const [potentialFieldName, targetSelection] of targetFields) {
72807
+ if (fieldName !== potentialFieldName) {
72808
+ continue;
72809
+ }
72810
+ if (!targetSelection) {
72811
+ continue;
72812
+ }
72813
+ targetSelection.visible = true;
72814
+ if (targetSelection.selection && value.selection) {
72815
+ applyMask(config4, targetSelection.selection, value.selection);
72816
+ }
72787
72817
  }
72788
72818
  }
72789
72819
  for (const [type, selection] of Object.entries(mask.abstractFields?.fields ?? {})) {
@@ -74394,6 +74424,24 @@ async function addTypename(config4, documents) {
74394
74424
  }
74395
74425
  };
74396
74426
  }
74427
+ },
74428
+ FragmentDefinition(node) {
74429
+ return {
74430
+ ...node,
74431
+ selectionSet: {
74432
+ ...node.selectionSet,
74433
+ selections: [
74434
+ ...node.selectionSet.selections,
74435
+ {
74436
+ kind: graphql23.Kind.FIELD,
74437
+ name: {
74438
+ kind: graphql23.Kind.NAME,
74439
+ value: "__typename"
74440
+ }
74441
+ }
74442
+ ]
74443
+ }
74444
+ };
74397
74445
  }
74398
74446
  });
74399
74447
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",