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.
@@ -54804,13 +54804,23 @@ var List = class {
54804
54804
  when(when) {
54805
54805
  return this.manager.lists.get(this.name).get(this.recordID).when(when);
54806
54806
  }
54807
- append(selection, data, variables = {}) {
54808
- return this.addToList(selection, data, variables, "last");
54807
+ append({
54808
+ selection,
54809
+ data,
54810
+ variables = {},
54811
+ layer
54812
+ }) {
54813
+ return this.addToList(selection, data, variables, "last", layer);
54809
54814
  }
54810
- prepend(selection, data, variables = {}) {
54811
- return this.addToList(selection, data, variables, "first");
54815
+ prepend({
54816
+ selection,
54817
+ data,
54818
+ variables = {},
54819
+ layer
54820
+ }) {
54821
+ return this.addToList(selection, data, variables, "first", layer);
54812
54822
  }
54813
- addToList(selection, data, variables = {}, where) {
54823
+ addToList(selection, data, variables = {}, where, layer) {
54814
54824
  const listType = this.listType(data);
54815
54825
  const dataID = this.cache._internal_unstable.id(listType, data);
54816
54826
  if (!this.validateWhen() || !dataID) {
@@ -54888,7 +54898,8 @@ var List = class {
54888
54898
  data: insertData,
54889
54899
  variables,
54890
54900
  parent: this.recordID,
54891
- applyUpdates: [where === "first" ? "prepend" : "append"]
54901
+ applyUpdates: [where === "first" ? "prepend" : "append"],
54902
+ layer: layer?.id
54892
54903
  });
54893
54904
  }
54894
54905
  removeID(id, variables = {}) {
@@ -54981,9 +54992,15 @@ var List = class {
54981
54992
  }
54982
54993
  return ok;
54983
54994
  }
54984
- toggleElement(selection, data, variables = {}, where) {
54995
+ toggleElement({
54996
+ selection,
54997
+ data,
54998
+ variables = {},
54999
+ layer,
55000
+ where
55001
+ }) {
54985
55002
  if (!this.remove(data, variables)) {
54986
- this.addToList(selection, data, variables, where);
55003
+ this.addToList(selection, data, variables, where, layer);
54987
55004
  }
54988
55005
  }
54989
55006
  *[Symbol.iterator]() {
@@ -55991,6 +56008,9 @@ var CacheInternal = class {
55991
56008
  nullable,
55992
56009
  link: !!fieldSelection
55993
56010
  });
56011
+ if (value && typeof value === "object" && "__typename" in value && value["__typename"]) {
56012
+ linkedType = value["__typename"];
56013
+ }
55994
56014
  const currentSubscribers = this.subscriptions.get(parent, key);
55995
56015
  const specs = currentSubscribers.map((sub) => sub[0]);
55996
56016
  const { value: previousValue, displayLayers } = this.storage.get(parent, key);
@@ -56044,7 +56064,6 @@ var CacheInternal = class {
56044
56064
  "Encountered interface type without __typename in the payload"
56045
56065
  );
56046
56066
  }
56047
- linkedType = value.__typename;
56048
56067
  }
56049
56068
  const embedded = this.idFields(linkedType)?.filter(
56050
56069
  (field2) => typeof value[field2] === "undefined"
@@ -56200,7 +56219,8 @@ var CacheInternal = class {
56200
56219
  fieldSelection,
56201
56220
  target,
56202
56221
  variables,
56203
- operation.position || "last"
56222
+ operation.position || "last",
56223
+ layer
56204
56224
  );
56205
56225
  } else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
56206
56226
  this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
@@ -56214,12 +56234,13 @@ var CacheInternal = class {
56214
56234
  }
56215
56235
  this.cache.delete(targetID);
56216
56236
  } else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
56217
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
56218
- fieldSelection,
56219
- target,
56237
+ this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
56238
+ selection: fieldSelection,
56239
+ data: target,
56220
56240
  variables,
56221
- operation.position || "last"
56222
- );
56241
+ where: operation.position || "last",
56242
+ layer
56243
+ });
56223
56244
  }
56224
56245
  }
56225
56246
  }
@@ -56248,7 +56269,7 @@ var CacheInternal = class {
56248
56269
  ])
56249
56270
  );
56250
56271
  }
56251
- let hasData = false;
56272
+ let hasData = !!selection.fragments;
56252
56273
  let partial = false;
56253
56274
  let cascadeNull = false;
56254
56275
  let stale = false;
@@ -56463,13 +56484,12 @@ var CacheInternal = class {
56463
56484
  const embedded = this.idFields(linkedType)?.filter(
56464
56485
  (field) => typeof entry[field] === "undefined"
56465
56486
  ).length > 0;
56466
- const typename = entryObj.__typename;
56467
56487
  let innerType = linkedType;
56468
- if (abstract) {
56469
- if (!typename) {
56470
- throw new Error("Encountered interface type without __typename in the payload");
56471
- }
56488
+ const typename = entryObj.__typename;
56489
+ if (typename) {
56472
56490
  innerType = typename;
56491
+ } else if (abstract) {
56492
+ throw new Error("Encountered interface type without __typename in the payload");
56473
56493
  }
56474
56494
  if (!embedded) {
56475
56495
  const id = this.id(innerType, entry);
@@ -59497,19 +59517,6 @@ function artifactGenerator(stats) {
59497
59517
  if (docKind === ArtifactKind.Fragment && directive) {
59498
59518
  inputs = fragmentArgumentsDefinitions(config2, doc.filename, fragments[0]);
59499
59519
  }
59500
- const mask = selection_default({
59501
- config: config2,
59502
- filepath: doc.filename,
59503
- rootType,
59504
- operations: {},
59505
- document: doc,
59506
- selections: flattenSelections({
59507
- config: config2,
59508
- filepath: doc.filename,
59509
- selections: selectionSet.selections,
59510
- fragmentDefinitions
59511
- })
59512
- });
59513
59520
  let artifact = {
59514
59521
  name,
59515
59522
  kind: docKind,
@@ -59539,7 +59546,23 @@ function artifactGenerator(stats) {
59539
59546
  }),
59540
59547
  pluginData: {}
59541
59548
  };
59542
- applyMask(config2, artifact.selection, mask);
59549
+ applyMask(
59550
+ config2,
59551
+ artifact.selection,
59552
+ selection_default({
59553
+ config: config2,
59554
+ filepath: doc.filename,
59555
+ rootType,
59556
+ operations: {},
59557
+ document: doc,
59558
+ selections: flattenSelections({
59559
+ config: config2,
59560
+ filepath: doc.filename,
59561
+ selections: selectionSet.selections,
59562
+ fragmentDefinitions
59563
+ })
59564
+ })
59565
+ );
59543
59566
  artifact.pluginData = {};
59544
59567
  for (const plugin2 of config2.plugins) {
59545
59568
  if (!plugin2.artifactData) {
@@ -59617,14 +59640,21 @@ function artifactGenerator(stats) {
59617
59640
  };
59618
59641
  }
59619
59642
  function applyMask(config2, target, mask) {
59643
+ const targetFields = Object.entries(target.fields ?? {}).concat(
59644
+ Object.values(target.abstractFields?.fields ?? {}).flatMap((typeMap) => Object.entries(typeMap))
59645
+ );
59620
59646
  for (const [fieldName, value] of Object.entries(mask.fields ?? {})) {
59621
- const targetSelection = target.fields?.[fieldName];
59622
- if (!targetSelection || !mask.fields) {
59623
- continue;
59624
- }
59625
- targetSelection.visible = true;
59626
- if (targetSelection.selection && value.selection) {
59627
- applyMask(config2, targetSelection.selection, value.selection);
59647
+ for (const [potentialFieldName, targetSelection] of targetFields) {
59648
+ if (fieldName !== potentialFieldName) {
59649
+ continue;
59650
+ }
59651
+ if (!targetSelection) {
59652
+ continue;
59653
+ }
59654
+ targetSelection.visible = true;
59655
+ if (targetSelection.selection && value.selection) {
59656
+ applyMask(config2, targetSelection.selection, value.selection);
59657
+ }
59628
59658
  }
59629
59659
  }
59630
59660
  for (const [type, selection] of Object.entries(mask.abstractFields?.fields ?? {})) {
@@ -61235,6 +61265,24 @@ async function addTypename(config2, documents) {
61235
61265
  }
61236
61266
  };
61237
61267
  }
61268
+ },
61269
+ FragmentDefinition(node) {
61270
+ return {
61271
+ ...node,
61272
+ selectionSet: {
61273
+ ...node.selectionSet,
61274
+ selections: [
61275
+ ...node.selectionSet.selections,
61276
+ {
61277
+ kind: graphql22.Kind.FIELD,
61278
+ name: {
61279
+ kind: graphql22.Kind.NAME,
61280
+ value: "__typename"
61281
+ }
61282
+ }
61283
+ ]
61284
+ }
61285
+ };
61238
61286
  }
61239
61287
  });
61240
61288
  }
@@ -54803,13 +54803,23 @@ var List = class {
54803
54803
  when(when) {
54804
54804
  return this.manager.lists.get(this.name).get(this.recordID).when(when);
54805
54805
  }
54806
- append(selection, data, variables = {}) {
54807
- return this.addToList(selection, data, variables, "last");
54806
+ append({
54807
+ selection,
54808
+ data,
54809
+ variables = {},
54810
+ layer
54811
+ }) {
54812
+ return this.addToList(selection, data, variables, "last", layer);
54808
54813
  }
54809
- prepend(selection, data, variables = {}) {
54810
- return this.addToList(selection, data, variables, "first");
54814
+ prepend({
54815
+ selection,
54816
+ data,
54817
+ variables = {},
54818
+ layer
54819
+ }) {
54820
+ return this.addToList(selection, data, variables, "first", layer);
54811
54821
  }
54812
- addToList(selection, data, variables = {}, where) {
54822
+ addToList(selection, data, variables = {}, where, layer) {
54813
54823
  const listType = this.listType(data);
54814
54824
  const dataID = this.cache._internal_unstable.id(listType, data);
54815
54825
  if (!this.validateWhen() || !dataID) {
@@ -54887,7 +54897,8 @@ var List = class {
54887
54897
  data: insertData,
54888
54898
  variables,
54889
54899
  parent: this.recordID,
54890
- applyUpdates: [where === "first" ? "prepend" : "append"]
54900
+ applyUpdates: [where === "first" ? "prepend" : "append"],
54901
+ layer: layer?.id
54891
54902
  });
54892
54903
  }
54893
54904
  removeID(id, variables = {}) {
@@ -54980,9 +54991,15 @@ var List = class {
54980
54991
  }
54981
54992
  return ok;
54982
54993
  }
54983
- toggleElement(selection, data, variables = {}, where) {
54994
+ toggleElement({
54995
+ selection,
54996
+ data,
54997
+ variables = {},
54998
+ layer,
54999
+ where
55000
+ }) {
54984
55001
  if (!this.remove(data, variables)) {
54985
- this.addToList(selection, data, variables, where);
55002
+ this.addToList(selection, data, variables, where, layer);
54986
55003
  }
54987
55004
  }
54988
55005
  *[Symbol.iterator]() {
@@ -55990,6 +56007,9 @@ var CacheInternal = class {
55990
56007
  nullable,
55991
56008
  link: !!fieldSelection
55992
56009
  });
56010
+ if (value && typeof value === "object" && "__typename" in value && value["__typename"]) {
56011
+ linkedType = value["__typename"];
56012
+ }
55993
56013
  const currentSubscribers = this.subscriptions.get(parent, key);
55994
56014
  const specs = currentSubscribers.map((sub) => sub[0]);
55995
56015
  const { value: previousValue, displayLayers } = this.storage.get(parent, key);
@@ -56043,7 +56063,6 @@ var CacheInternal = class {
56043
56063
  "Encountered interface type without __typename in the payload"
56044
56064
  );
56045
56065
  }
56046
- linkedType = value.__typename;
56047
56066
  }
56048
56067
  const embedded = this.idFields(linkedType)?.filter(
56049
56068
  (field2) => typeof value[field2] === "undefined"
@@ -56199,7 +56218,8 @@ var CacheInternal = class {
56199
56218
  fieldSelection,
56200
56219
  target,
56201
56220
  variables,
56202
- operation.position || "last"
56221
+ operation.position || "last",
56222
+ layer
56203
56223
  );
56204
56224
  } else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
56205
56225
  this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
@@ -56213,12 +56233,13 @@ var CacheInternal = class {
56213
56233
  }
56214
56234
  this.cache.delete(targetID);
56215
56235
  } else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
56216
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
56217
- fieldSelection,
56218
- target,
56236
+ this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
56237
+ selection: fieldSelection,
56238
+ data: target,
56219
56239
  variables,
56220
- operation.position || "last"
56221
- );
56240
+ where: operation.position || "last",
56241
+ layer
56242
+ });
56222
56243
  }
56223
56244
  }
56224
56245
  }
@@ -56247,7 +56268,7 @@ var CacheInternal = class {
56247
56268
  ])
56248
56269
  );
56249
56270
  }
56250
- let hasData = false;
56271
+ let hasData = !!selection.fragments;
56251
56272
  let partial = false;
56252
56273
  let cascadeNull = false;
56253
56274
  let stale = false;
@@ -56462,13 +56483,12 @@ var CacheInternal = class {
56462
56483
  const embedded = this.idFields(linkedType)?.filter(
56463
56484
  (field) => typeof entry[field] === "undefined"
56464
56485
  ).length > 0;
56465
- const typename = entryObj.__typename;
56466
56486
  let innerType = linkedType;
56467
- if (abstract) {
56468
- if (!typename) {
56469
- throw new Error("Encountered interface type without __typename in the payload");
56470
- }
56487
+ const typename = entryObj.__typename;
56488
+ if (typename) {
56471
56489
  innerType = typename;
56490
+ } else if (abstract) {
56491
+ throw new Error("Encountered interface type without __typename in the payload");
56472
56492
  }
56473
56493
  if (!embedded) {
56474
56494
  const id = this.id(innerType, entry);
@@ -59495,19 +59515,6 @@ function artifactGenerator(stats) {
59495
59515
  if (docKind === ArtifactKind.Fragment && directive) {
59496
59516
  inputs = fragmentArgumentsDefinitions(config2, doc.filename, fragments[0]);
59497
59517
  }
59498
- const mask = selection_default({
59499
- config: config2,
59500
- filepath: doc.filename,
59501
- rootType,
59502
- operations: {},
59503
- document: doc,
59504
- selections: flattenSelections({
59505
- config: config2,
59506
- filepath: doc.filename,
59507
- selections: selectionSet.selections,
59508
- fragmentDefinitions
59509
- })
59510
- });
59511
59518
  let artifact = {
59512
59519
  name,
59513
59520
  kind: docKind,
@@ -59537,7 +59544,23 @@ function artifactGenerator(stats) {
59537
59544
  }),
59538
59545
  pluginData: {}
59539
59546
  };
59540
- applyMask(config2, artifact.selection, mask);
59547
+ applyMask(
59548
+ config2,
59549
+ artifact.selection,
59550
+ selection_default({
59551
+ config: config2,
59552
+ filepath: doc.filename,
59553
+ rootType,
59554
+ operations: {},
59555
+ document: doc,
59556
+ selections: flattenSelections({
59557
+ config: config2,
59558
+ filepath: doc.filename,
59559
+ selections: selectionSet.selections,
59560
+ fragmentDefinitions
59561
+ })
59562
+ })
59563
+ );
59541
59564
  artifact.pluginData = {};
59542
59565
  for (const plugin2 of config2.plugins) {
59543
59566
  if (!plugin2.artifactData) {
@@ -59615,14 +59638,21 @@ function artifactGenerator(stats) {
59615
59638
  };
59616
59639
  }
59617
59640
  function applyMask(config2, target, mask) {
59641
+ const targetFields = Object.entries(target.fields ?? {}).concat(
59642
+ Object.values(target.abstractFields?.fields ?? {}).flatMap((typeMap) => Object.entries(typeMap))
59643
+ );
59618
59644
  for (const [fieldName, value] of Object.entries(mask.fields ?? {})) {
59619
- const targetSelection = target.fields?.[fieldName];
59620
- if (!targetSelection || !mask.fields) {
59621
- continue;
59622
- }
59623
- targetSelection.visible = true;
59624
- if (targetSelection.selection && value.selection) {
59625
- applyMask(config2, targetSelection.selection, value.selection);
59645
+ for (const [potentialFieldName, targetSelection] of targetFields) {
59646
+ if (fieldName !== potentialFieldName) {
59647
+ continue;
59648
+ }
59649
+ if (!targetSelection) {
59650
+ continue;
59651
+ }
59652
+ targetSelection.visible = true;
59653
+ if (targetSelection.selection && value.selection) {
59654
+ applyMask(config2, targetSelection.selection, value.selection);
59655
+ }
59626
59656
  }
59627
59657
  }
59628
59658
  for (const [type, selection] of Object.entries(mask.abstractFields?.fields ?? {})) {
@@ -61233,6 +61263,24 @@ async function addTypename(config2, documents) {
61233
61263
  }
61234
61264
  };
61235
61265
  }
61266
+ },
61267
+ FragmentDefinition(node) {
61268
+ return {
61269
+ ...node,
61270
+ selectionSet: {
61271
+ ...node.selectionSet,
61272
+ selections: [
61273
+ ...node.selectionSet.selections,
61274
+ {
61275
+ kind: graphql22.Kind.FIELD,
61276
+ name: {
61277
+ kind: graphql22.Kind.NAME,
61278
+ value: "__typename"
61279
+ }
61280
+ }
61281
+ ]
61282
+ }
61283
+ };
61236
61284
  }
61237
61285
  });
61238
61286
  }
@@ -63828,13 +63828,23 @@ var List = class {
63828
63828
  when(when) {
63829
63829
  return this.manager.lists.get(this.name).get(this.recordID).when(when);
63830
63830
  }
63831
- append(selection, data, variables = {}) {
63832
- return this.addToList(selection, data, variables, "last");
63831
+ append({
63832
+ selection,
63833
+ data,
63834
+ variables = {},
63835
+ layer
63836
+ }) {
63837
+ return this.addToList(selection, data, variables, "last", layer);
63833
63838
  }
63834
- prepend(selection, data, variables = {}) {
63835
- return this.addToList(selection, data, variables, "first");
63839
+ prepend({
63840
+ selection,
63841
+ data,
63842
+ variables = {},
63843
+ layer
63844
+ }) {
63845
+ return this.addToList(selection, data, variables, "first", layer);
63836
63846
  }
63837
- addToList(selection, data, variables = {}, where) {
63847
+ addToList(selection, data, variables = {}, where, layer) {
63838
63848
  const listType = this.listType(data);
63839
63849
  const dataID = this.cache._internal_unstable.id(listType, data);
63840
63850
  if (!this.validateWhen() || !dataID) {
@@ -63912,7 +63922,8 @@ var List = class {
63912
63922
  data: insertData,
63913
63923
  variables,
63914
63924
  parent: this.recordID,
63915
- applyUpdates: [where === "first" ? "prepend" : "append"]
63925
+ applyUpdates: [where === "first" ? "prepend" : "append"],
63926
+ layer: layer?.id
63916
63927
  });
63917
63928
  }
63918
63929
  removeID(id, variables = {}) {
@@ -64005,9 +64016,15 @@ var List = class {
64005
64016
  }
64006
64017
  return ok;
64007
64018
  }
64008
- toggleElement(selection, data, variables = {}, where) {
64019
+ toggleElement({
64020
+ selection,
64021
+ data,
64022
+ variables = {},
64023
+ layer,
64024
+ where
64025
+ }) {
64009
64026
  if (!this.remove(data, variables)) {
64010
- this.addToList(selection, data, variables, where);
64027
+ this.addToList(selection, data, variables, where, layer);
64011
64028
  }
64012
64029
  }
64013
64030
  *[Symbol.iterator]() {
@@ -65015,6 +65032,9 @@ var CacheInternal = class {
65015
65032
  nullable,
65016
65033
  link: !!fieldSelection
65017
65034
  });
65035
+ if (value && typeof value === "object" && "__typename" in value && value["__typename"]) {
65036
+ linkedType = value["__typename"];
65037
+ }
65018
65038
  const currentSubscribers = this.subscriptions.get(parent, key);
65019
65039
  const specs = currentSubscribers.map((sub) => sub[0]);
65020
65040
  const { value: previousValue, displayLayers } = this.storage.get(parent, key);
@@ -65068,7 +65088,6 @@ var CacheInternal = class {
65068
65088
  "Encountered interface type without __typename in the payload"
65069
65089
  );
65070
65090
  }
65071
- linkedType = value.__typename;
65072
65091
  }
65073
65092
  const embedded = this.idFields(linkedType)?.filter(
65074
65093
  (field2) => typeof value[field2] === "undefined"
@@ -65224,7 +65243,8 @@ var CacheInternal = class {
65224
65243
  fieldSelection,
65225
65244
  target,
65226
65245
  variables,
65227
- operation.position || "last"
65246
+ operation.position || "last",
65247
+ layer
65228
65248
  );
65229
65249
  } else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
65230
65250
  this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
@@ -65238,12 +65258,13 @@ var CacheInternal = class {
65238
65258
  }
65239
65259
  this.cache.delete(targetID);
65240
65260
  } else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
65241
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
65242
- fieldSelection,
65243
- target,
65261
+ this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
65262
+ selection: fieldSelection,
65263
+ data: target,
65244
65264
  variables,
65245
- operation.position || "last"
65246
- );
65265
+ where: operation.position || "last",
65266
+ layer
65267
+ });
65247
65268
  }
65248
65269
  }
65249
65270
  }
@@ -65272,7 +65293,7 @@ var CacheInternal = class {
65272
65293
  ])
65273
65294
  );
65274
65295
  }
65275
- let hasData = false;
65296
+ let hasData = !!selection.fragments;
65276
65297
  let partial = false;
65277
65298
  let cascadeNull = false;
65278
65299
  let stale = false;
@@ -65487,13 +65508,12 @@ var CacheInternal = class {
65487
65508
  const embedded = this.idFields(linkedType)?.filter(
65488
65509
  (field) => typeof entry[field] === "undefined"
65489
65510
  ).length > 0;
65490
- const typename = entryObj.__typename;
65491
65511
  let innerType = linkedType;
65492
- if (abstract) {
65493
- if (!typename) {
65494
- throw new Error("Encountered interface type without __typename in the payload");
65495
- }
65512
+ const typename = entryObj.__typename;
65513
+ if (typename) {
65496
65514
  innerType = typename;
65515
+ } else if (abstract) {
65516
+ throw new Error("Encountered interface type without __typename in the payload");
65497
65517
  }
65498
65518
  if (!embedded) {
65499
65519
  const id = this.id(innerType, entry);