houdini 0.17.14 → 0.18.1

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.
Files changed (57) hide show
  1. package/build/cmd-cjs/index.js +442 -203
  2. package/build/cmd-esm/index.js +442 -203
  3. package/build/codegen/utils/flattenSelections.d.ts +3 -1
  4. package/build/codegen-cjs/index.js +409 -182
  5. package/build/codegen-esm/index.js +409 -182
  6. package/build/lib/config.d.ts +8 -3
  7. package/build/lib-cjs/index.js +145 -83
  8. package/build/lib-esm/index.js +145 -83
  9. package/build/runtime/cache/subscription.d.ts +3 -3
  10. package/build/runtime/lib/config.d.ts +2 -1
  11. package/build/runtime/lib/scalars.d.ts +2 -2
  12. package/build/runtime/lib/selection.d.ts +2 -0
  13. package/build/runtime/lib/types.d.ts +26 -16
  14. package/build/runtime-cjs/cache/cache.js +42 -25
  15. package/build/runtime-cjs/cache/lists.js +40 -26
  16. package/build/runtime-cjs/cache/subscription.d.ts +3 -3
  17. package/build/runtime-cjs/cache/subscription.js +23 -21
  18. package/build/runtime-cjs/lib/config.d.ts +2 -1
  19. package/build/runtime-cjs/lib/scalars.d.ts +2 -2
  20. package/build/runtime-cjs/lib/scalars.js +9 -6
  21. package/build/runtime-cjs/lib/selection.d.ts +2 -0
  22. package/build/runtime-cjs/lib/selection.js +39 -0
  23. package/build/runtime-cjs/lib/types.d.ts +26 -16
  24. package/build/runtime-esm/cache/cache.js +42 -25
  25. package/build/runtime-esm/cache/lists.js +40 -26
  26. package/build/runtime-esm/cache/subscription.d.ts +3 -3
  27. package/build/runtime-esm/cache/subscription.js +23 -21
  28. package/build/runtime-esm/lib/config.d.ts +2 -1
  29. package/build/runtime-esm/lib/scalars.d.ts +2 -2
  30. package/build/runtime-esm/lib/scalars.js +9 -6
  31. package/build/runtime-esm/lib/selection.d.ts +2 -0
  32. package/build/runtime-esm/lib/selection.js +15 -0
  33. package/build/runtime-esm/lib/types.d.ts +26 -16
  34. package/build/test/index.d.ts +1 -2
  35. package/build/test-cjs/index.js +489 -197
  36. package/build/test-esm/index.js +489 -197
  37. package/build/vite-cjs/index.js +442 -195
  38. package/build/vite-esm/index.js +442 -195
  39. package/package.json +3 -3
  40. package/build/runtime-cjs/cache/tests/availability.test.js +0 -357
  41. package/build/runtime-cjs/cache/tests/gc.test.js +0 -271
  42. package/build/runtime-cjs/cache/tests/keys.test.js +0 -34
  43. package/build/runtime-cjs/cache/tests/list.test.js +0 -3390
  44. package/build/runtime-cjs/cache/tests/readwrite.test.js +0 -1076
  45. package/build/runtime-cjs/cache/tests/scalars.test.js +0 -181
  46. package/build/runtime-cjs/cache/tests/storage.test.js +0 -280
  47. package/build/runtime-cjs/cache/tests/subscriptions.test.js +0 -1469
  48. package/build/runtime-cjs/lib/scalars.test.js +0 -736
  49. package/build/runtime-esm/cache/tests/availability.test.js +0 -356
  50. package/build/runtime-esm/cache/tests/gc.test.js +0 -270
  51. package/build/runtime-esm/cache/tests/keys.test.js +0 -33
  52. package/build/runtime-esm/cache/tests/list.test.js +0 -3389
  53. package/build/runtime-esm/cache/tests/readwrite.test.js +0 -1075
  54. package/build/runtime-esm/cache/tests/scalars.test.js +0 -180
  55. package/build/runtime-esm/cache/tests/storage.test.js +0 -279
  56. package/build/runtime-esm/cache/tests/subscriptions.test.js +0 -1468
  57. package/build/runtime-esm/lib/scalars.test.js +0 -735
@@ -5099,7 +5099,7 @@ var require_definition = __commonJS({
5099
5099
  exports.assertObjectType = assertObjectType;
5100
5100
  exports.isInterfaceType = isInterfaceType12;
5101
5101
  exports.assertInterfaceType = assertInterfaceType;
5102
- exports.isUnionType = isUnionType12;
5102
+ exports.isUnionType = isUnionType13;
5103
5103
  exports.assertUnionType = assertUnionType;
5104
5104
  exports.isEnumType = isEnumType9;
5105
5105
  exports.assertEnumType = assertEnumType;
@@ -5117,7 +5117,7 @@ var require_definition = __commonJS({
5117
5117
  exports.assertLeafType = assertLeafType;
5118
5118
  exports.isCompositeType = isCompositeType;
5119
5119
  exports.assertCompositeType = assertCompositeType;
5120
- exports.isAbstractType = isAbstractType;
5120
+ exports.isAbstractType = isAbstractType2;
5121
5121
  exports.assertAbstractType = assertAbstractType;
5122
5122
  exports.GraphQLList = GraphQLList6;
5123
5123
  exports.GraphQLNonNull = GraphQLNonNull6;
@@ -5172,7 +5172,7 @@ var require_definition = __commonJS({
5172
5172
  return Constructor;
5173
5173
  }
5174
5174
  function isType(type) {
5175
- return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType12(type) || isEnumType9(type) || isInputObjectType7(type) || isListType8(type) || isNonNullType10(type);
5175
+ return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType9(type) || isInputObjectType7(type) || isListType8(type) || isNonNullType10(type);
5176
5176
  }
5177
5177
  function assertType(type) {
5178
5178
  if (!isType(type)) {
@@ -5207,11 +5207,11 @@ var require_definition = __commonJS({
5207
5207
  }
5208
5208
  return type;
5209
5209
  }
5210
- function isUnionType12(type) {
5210
+ function isUnionType13(type) {
5211
5211
  return (0, _instanceOf.default)(type, GraphQLUnionType3);
5212
5212
  }
5213
5213
  function assertUnionType(type) {
5214
- if (!isUnionType12(type)) {
5214
+ if (!isUnionType13(type)) {
5215
5215
  throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Union type."));
5216
5216
  }
5217
5217
  return type;
@@ -5262,7 +5262,7 @@ var require_definition = __commonJS({
5262
5262
  return type;
5263
5263
  }
5264
5264
  function isOutputType(type) {
5265
- return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType12(type) || isEnumType9(type) || isWrappingType(type) && isOutputType(type.ofType);
5265
+ return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType9(type) || isWrappingType(type) && isOutputType(type.ofType);
5266
5266
  }
5267
5267
  function assertOutputType(type) {
5268
5268
  if (!isOutputType(type)) {
@@ -5280,7 +5280,7 @@ var require_definition = __commonJS({
5280
5280
  return type;
5281
5281
  }
5282
5282
  function isCompositeType(type) {
5283
- return isObjectType11(type) || isInterfaceType12(type) || isUnionType12(type);
5283
+ return isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type);
5284
5284
  }
5285
5285
  function assertCompositeType(type) {
5286
5286
  if (!isCompositeType(type)) {
@@ -5288,11 +5288,11 @@ var require_definition = __commonJS({
5288
5288
  }
5289
5289
  return type;
5290
5290
  }
5291
- function isAbstractType(type) {
5292
- return isInterfaceType12(type) || isUnionType12(type);
5291
+ function isAbstractType2(type) {
5292
+ return isInterfaceType12(type) || isUnionType13(type);
5293
5293
  }
5294
5294
  function assertAbstractType(type) {
5295
- if (!isAbstractType(type)) {
5295
+ if (!isAbstractType2(type)) {
5296
5296
  throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL abstract type."));
5297
5297
  }
5298
5298
  return type;
@@ -5359,7 +5359,7 @@ var require_definition = __commonJS({
5359
5359
  }
5360
5360
  }
5361
5361
  function isNamedType4(type) {
5362
- return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType12(type) || isEnumType9(type) || isInputObjectType7(type);
5362
+ return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType9(type) || isInputObjectType7(type);
5363
5363
  }
5364
5364
  function assertNamedType(type) {
5365
5365
  if (!isNamedType4(type)) {
@@ -67736,6 +67736,20 @@ function deepEquals(objA, objB, map = /* @__PURE__ */ new WeakMap()) {
67736
67736
  return true;
67737
67737
  }
67738
67738
 
67739
+ // src/runtime/lib/selection.ts
67740
+ function getFieldsForType(selection2, __typename) {
67741
+ let targetSelection = selection2.fields || {};
67742
+ if (selection2.abstractFields && __typename) {
67743
+ const mappedType = selection2.abstractFields.typeMap[__typename];
67744
+ if (mappedType) {
67745
+ targetSelection = selection2.abstractFields.fields[mappedType];
67746
+ } else if (selection2.abstractFields.fields[__typename]) {
67747
+ targetSelection = selection2.abstractFields.fields[__typename];
67748
+ }
67749
+ }
67750
+ return targetSelection;
67751
+ }
67752
+
67739
67753
  // src/runtime/cache/gc.ts
67740
67754
  var GarbageCollector = class {
67741
67755
  cache;
@@ -67958,23 +67972,32 @@ var List = class {
67958
67972
  let insertData = data;
67959
67973
  if (this.connection) {
67960
67974
  insertSelection = {
67961
- newEntry: {
67962
- keyRaw: this.key,
67963
- type: "Connection",
67964
- fields: {
67965
- edges: {
67966
- keyRaw: "edges",
67967
- type: "ConnectionEdge",
67968
- update: where === "first" ? "prepend" : "append",
67975
+ fields: {
67976
+ newEntry: {
67977
+ keyRaw: this.key,
67978
+ type: "Connection",
67979
+ selection: {
67969
67980
  fields: {
67970
- node: {
67971
- type: listType,
67972
- keyRaw: "node",
67973
- fields: {
67974
- ...selection2,
67975
- __typename: {
67976
- keyRaw: "__typename",
67977
- type: "String"
67981
+ edges: {
67982
+ keyRaw: "edges",
67983
+ type: "ConnectionEdge",
67984
+ update: where === "first" ? "prepend" : "append",
67985
+ selection: {
67986
+ fields: {
67987
+ node: {
67988
+ type: listType,
67989
+ keyRaw: "node",
67990
+ selection: {
67991
+ ...selection2,
67992
+ fields: {
67993
+ ...selection2.fields,
67994
+ __typename: {
67995
+ keyRaw: "__typename",
67996
+ type: "String"
67997
+ }
67998
+ }
67999
+ }
68000
+ }
67978
68001
  }
67979
68002
  }
67980
68003
  }
@@ -67990,15 +68013,20 @@ var List = class {
67990
68013
  };
67991
68014
  } else {
67992
68015
  insertSelection = {
67993
- newEntries: {
67994
- keyRaw: this.key,
67995
- type: listType,
67996
- update: where === "first" ? "prepend" : "append",
67997
- fields: {
67998
- ...selection2,
67999
- __typename: {
68000
- keyRaw: "__typename",
68001
- type: "String"
68016
+ fields: {
68017
+ newEntries: {
68018
+ keyRaw: this.key,
68019
+ type: listType,
68020
+ update: where === "first" ? "prepend" : "append",
68021
+ selection: {
68022
+ ...selection2,
68023
+ fields: {
68024
+ ...selection2.fields,
68025
+ __typename: {
68026
+ keyRaw: "__typename",
68027
+ type: "String"
68028
+ }
68029
+ }
68002
68030
  }
68003
68031
  }
68004
68032
  }
@@ -68058,7 +68086,7 @@ var List = class {
68058
68086
  const subscribers = this.cache._internal_unstable.subscriptions.get(this.recordID, this.key);
68059
68087
  this.cache._internal_unstable.subscriptions.remove(
68060
68088
  targetID,
68061
- this.connection ? this.selection.edges.fields : this.selection,
68089
+ this.connection ? this.selection.fields.edges.selection : this.selection,
68062
68090
  subscribers,
68063
68091
  variables
68064
68092
  );
@@ -68547,18 +68575,20 @@ var InMemorySubscriptions = class {
68547
68575
  variables,
68548
68576
  parentType
68549
68577
  }) {
68550
- for (const fieldSelection of Object.values(selection2)) {
68551
- const { keyRaw, fields, type } = fieldSelection;
68578
+ const __typename = this.cache._internal_unstable.storage.get(parent, "__typename").value;
68579
+ let targetSelection = getFieldsForType(selection2, __typename);
68580
+ for (const fieldSelection of Object.values(targetSelection || {})) {
68581
+ const { keyRaw, selection: innerSelection, type } = fieldSelection;
68552
68582
  const key = evaluateKey(keyRaw, variables);
68553
68583
  this.addFieldSubscription({
68554
68584
  id: parent,
68555
68585
  key,
68556
- selection: fieldSelection,
68586
+ field: fieldSelection,
68557
68587
  spec,
68558
68588
  parentType: parentType || spec.rootType,
68559
68589
  variables
68560
68590
  });
68561
- if (fields) {
68591
+ if (innerSelection) {
68562
68592
  const { value: linkedRecord } = this.cache._internal_unstable.storage.get(
68563
68593
  parent,
68564
68594
  key
@@ -68571,7 +68601,7 @@ var InMemorySubscriptions = class {
68571
68601
  this.add({
68572
68602
  parent: child,
68573
68603
  spec,
68574
- selection: fields,
68604
+ selection: innerSelection,
68575
68605
  variables,
68576
68606
  parentType: type
68577
68607
  });
@@ -68582,7 +68612,7 @@ var InMemorySubscriptions = class {
68582
68612
  addFieldSubscription({
68583
68613
  id,
68584
68614
  key,
68585
- selection: selection2,
68615
+ field,
68586
68616
  spec,
68587
68617
  parentType,
68588
68618
  variables
@@ -68609,8 +68639,8 @@ var InMemorySubscriptions = class {
68609
68639
  const counts = this.referenceCounts[id][key];
68610
68640
  counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
68611
68641
  this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
68612
- const { fields, list, filters } = selection2;
68613
- if (fields && list) {
68642
+ const { selection: selection2, list, filters } = field;
68643
+ if (selection2 && list) {
68614
68644
  this.cache._internal_unstable.lists.add({
68615
68645
  name: list.name,
68616
68646
  connection: list.connection,
@@ -68618,7 +68648,7 @@ var InMemorySubscriptions = class {
68618
68648
  recordType: this.cache._internal_unstable.storage.get(id, "__typename")?.value || parentType,
68619
68649
  listType: list.type,
68620
68650
  key,
68621
- selection: fields,
68651
+ selection: selection2,
68622
68652
  filters: Object.entries(filters || {}).reduce((acc, [key2, { kind, value }]) => {
68623
68653
  return {
68624
68654
  ...acc,
@@ -68635,20 +68665,21 @@ var InMemorySubscriptions = class {
68635
68665
  subscribers,
68636
68666
  parentType
68637
68667
  }) {
68638
- for (const fieldSelection of Object.values(selection2)) {
68639
- const { type: linkedType, keyRaw, fields } = fieldSelection;
68668
+ let targetSelection = getFieldsForType(selection2, parentType);
68669
+ for (const fieldSelection of Object.values(targetSelection)) {
68670
+ const { type: linkedType, keyRaw, selection: innerSelection } = fieldSelection;
68640
68671
  const key = evaluateKey(keyRaw, variables);
68641
68672
  for (const spec of subscribers) {
68642
68673
  this.addFieldSubscription({
68643
68674
  id: parent,
68644
68675
  key,
68645
- selection: fieldSelection,
68676
+ field: fieldSelection,
68646
68677
  spec,
68647
68678
  parentType,
68648
68679
  variables
68649
68680
  });
68650
68681
  }
68651
- if (fields) {
68682
+ if (innerSelection) {
68652
68683
  const { value: link } = this.cache._internal_unstable.storage.get(parent, key);
68653
68684
  const children = !Array.isArray(link) ? [link] : flattenList(link);
68654
68685
  for (const linkedRecord of children) {
@@ -68657,7 +68688,7 @@ var InMemorySubscriptions = class {
68657
68688
  }
68658
68689
  this.addMany({
68659
68690
  parent: linkedRecord,
68660
- selection: fields,
68691
+ selection: innerSelection,
68661
68692
  variables,
68662
68693
  subscribers,
68663
68694
  parentType: linkedType
@@ -68669,22 +68700,20 @@ var InMemorySubscriptions = class {
68669
68700
  get(id, field) {
68670
68701
  return this.subscribers[id]?.[field] || [];
68671
68702
  }
68672
- remove(id, fields, targets, variables, visited = []) {
68703
+ remove(id, selection2, targets, variables, visited = []) {
68673
68704
  visited.push(id);
68674
68705
  const linkedIDs = [];
68675
- for (const selection2 of Object.values(fields)) {
68676
- const key = evaluateKey(selection2.keyRaw, variables);
68706
+ for (const fieldSelection of Object.values(selection2.fields || {})) {
68707
+ const key = evaluateKey(fieldSelection.keyRaw, variables);
68677
68708
  this.removeSubscribers(id, key, targets);
68678
- if (!selection2.fields) {
68709
+ if (!fieldSelection.selection?.fields) {
68679
68710
  continue;
68680
68711
  }
68681
- if (selection2.list) {
68682
- }
68683
68712
  const { value: previousValue } = this.cache._internal_unstable.storage.get(id, key);
68684
68713
  const links = !Array.isArray(previousValue) ? [previousValue] : flattenList(previousValue);
68685
68714
  for (const link of links) {
68686
68715
  if (link !== null) {
68687
- linkedIDs.push([link, selection2.fields]);
68716
+ linkedIDs.push([link, fieldSelection.selection || {}]);
68688
68717
  }
68689
68718
  }
68690
68719
  }
@@ -68839,10 +68868,12 @@ var CacheInternal = class {
68839
68868
  this.lists = lists;
68840
68869
  this.cache = cache;
68841
68870
  this.lifetimes = lifetimes;
68871
+ this._disabled = typeof globalThis.window === "undefined";
68842
68872
  try {
68843
- this._disabled = process.env.HOUDINI_TEST !== "true";
68873
+ if (process.env.HOUDINI_TEST === "true") {
68874
+ this._disabled = false;
68875
+ }
68844
68876
  } catch {
68845
- this._disabled = typeof globalThis.window === "undefined";
68846
68877
  }
68847
68878
  }
68848
68879
  setConfig(config2) {
@@ -68862,8 +68893,9 @@ var CacheInternal = class {
68862
68893
  if (this._disabled) {
68863
68894
  return [];
68864
68895
  }
68896
+ let targetSelection = getFieldsForType(selection2, data["__typename"]);
68865
68897
  for (const [field, value] of Object.entries(data)) {
68866
- if (!selection2 || !selection2[field]) {
68898
+ if (!selection2 || !targetSelection[field]) {
68867
68899
  throw new Error(
68868
68900
  "Could not find field listing in selection for " + field + " @ " + JSON.stringify(selection2)
68869
68901
  );
@@ -68871,11 +68903,11 @@ var CacheInternal = class {
68871
68903
  let {
68872
68904
  type: linkedType,
68873
68905
  keyRaw,
68874
- fields,
68906
+ selection: fieldSelection,
68875
68907
  operations,
68876
68908
  abstract: isAbstract,
68877
68909
  update
68878
- } = selection2[field];
68910
+ } = targetSelection[field];
68879
68911
  const key = evaluateKey(keyRaw, variables);
68880
68912
  const currentSubscribers = this.subscriptions.get(parent, key);
68881
68913
  const { value: previousValue, displayLayers } = this.storage.get(parent, key);
@@ -68883,7 +68915,7 @@ var CacheInternal = class {
68883
68915
  if (displayLayer) {
68884
68916
  this.lifetimes.resetLifetime(parent, key);
68885
68917
  }
68886
- if (!fields) {
68918
+ if (!fieldSelection) {
68887
68919
  let newValue = value;
68888
68920
  if (Array.isArray(value) && applyUpdates && update) {
68889
68921
  if (update === "append") {
@@ -68903,7 +68935,7 @@ var CacheInternal = class {
68903
68935
  }
68904
68936
  const previousLinks = flattenList([previousValue]);
68905
68937
  for (const link of previousLinks) {
68906
- this.subscriptions.remove(link, fields, currentSubscribers, variables);
68938
+ this.subscriptions.remove(link, fieldSelection, currentSubscribers, variables);
68907
68939
  }
68908
68940
  layer.writeLink(parent, key, null);
68909
68941
  toNotify.push(...currentSubscribers);
@@ -68929,14 +68961,14 @@ var CacheInternal = class {
68929
68961
  if (previousValue && typeof previousValue === "string") {
68930
68962
  this.subscriptions.remove(
68931
68963
  previousValue,
68932
- fields,
68964
+ fieldSelection,
68933
68965
  currentSubscribers,
68934
68966
  variables
68935
68967
  );
68936
68968
  }
68937
68969
  this.subscriptions.addMany({
68938
68970
  parent: linkedID,
68939
- selection: fields,
68971
+ selection: fieldSelection,
68940
68972
  subscribers: currentSubscribers,
68941
68973
  variables,
68942
68974
  parentType: linkedType
@@ -68946,14 +68978,14 @@ var CacheInternal = class {
68946
68978
  if (linkedID) {
68947
68979
  this.writeSelection({
68948
68980
  root,
68949
- selection: fields,
68981
+ selection: fieldSelection,
68950
68982
  parent: linkedID,
68951
68983
  data: value,
68952
68984
  variables,
68953
68985
  toNotify,
68954
68986
  applyUpdates,
68955
68987
  layer,
68956
- forceNotify: true
68988
+ forceNotify
68957
68989
  });
68958
68990
  }
68959
68991
  } else if (Array.isArray(value) && (typeof previousValue === "undefined" || Array.isArray(previousValue))) {
@@ -68982,7 +69014,7 @@ var CacheInternal = class {
68982
69014
  key,
68983
69015
  linkedType,
68984
69016
  variables,
68985
- fields,
69017
+ fields: fieldSelection,
68986
69018
  layer,
68987
69019
  forceNotify
68988
69020
  });
@@ -69032,7 +69064,7 @@ var CacheInternal = class {
69032
69064
  if (linkedIDs.includes(lostID) || !lostID) {
69033
69065
  continue;
69034
69066
  }
69035
- this.subscriptions.remove(lostID, fields, currentSubscribers, variables);
69067
+ this.subscriptions.remove(lostID, fieldSelection, currentSubscribers, variables);
69036
69068
  }
69037
69069
  if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
69038
69070
  layer.writeLink(parent, key, linkedIDs);
@@ -69043,7 +69075,7 @@ var CacheInternal = class {
69043
69075
  }
69044
69076
  this.subscriptions.addMany({
69045
69077
  parent: id,
69046
- selection: fields,
69078
+ selection: fieldSelection,
69047
69079
  subscribers: currentSubscribers,
69048
69080
  variables,
69049
69081
  parentType: linkedType
@@ -69068,9 +69100,14 @@ var CacheInternal = class {
69068
69100
  }
69069
69101
  const targets = Array.isArray(value) ? value : [value];
69070
69102
  for (const target of targets) {
69071
- if (operation.action === "insert" && target instanceof Object && fields && operation.list) {
69072
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(fields, target, variables, operation.position || "last");
69073
- } else if (operation.action === "remove" && target instanceof Object && fields && operation.list) {
69103
+ if (operation.action === "insert" && target instanceof Object && fieldSelection && operation.list) {
69104
+ this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(
69105
+ fieldSelection,
69106
+ target,
69107
+ variables,
69108
+ operation.position || "last"
69109
+ );
69110
+ } else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
69074
69111
  this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
69075
69112
  } else if (operation.action === "delete" && operation.type) {
69076
69113
  if (typeof target !== "string") {
@@ -69081,8 +69118,13 @@ var CacheInternal = class {
69081
69118
  continue;
69082
69119
  }
69083
69120
  this.cache.delete(targetID);
69084
- } else if (operation.action === "toggle" && target instanceof Object && fields && operation.list) {
69085
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(fields, target, variables, operation.position || "last");
69121
+ } else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
69122
+ this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
69123
+ fieldSelection,
69124
+ target,
69125
+ variables,
69126
+ operation.position || "last"
69127
+ );
69086
69128
  }
69087
69129
  }
69088
69130
  }
@@ -69102,9 +69144,12 @@ var CacheInternal = class {
69102
69144
  let hasData = false;
69103
69145
  let partial = false;
69104
69146
  let cascadeNull = false;
69105
- for (const [attributeName, { type, keyRaw, fields, nullable, list }] of Object.entries(
69106
- selection2
69107
- )) {
69147
+ const typename = this.storage.get(parent, "__typename").value;
69148
+ let targetSelection = getFieldsForType(selection2, typename);
69149
+ for (const [
69150
+ attributeName,
69151
+ { type, keyRaw, selection: fieldSelection, nullable, list }
69152
+ ] of Object.entries(targetSelection)) {
69108
69153
  const key = evaluateKey(keyRaw, variables);
69109
69154
  const { value } = this.storage.get(parent, key);
69110
69155
  let nextStep = stepsFromConnection;
@@ -69127,7 +69172,7 @@ var CacheInternal = class {
69127
69172
  if (typeof value !== "undefined") {
69128
69173
  hasData = true;
69129
69174
  }
69130
- } else if (!fields) {
69175
+ } else if (!fieldSelection) {
69131
69176
  const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
69132
69177
  if (fnUnmarshal) {
69133
69178
  target[attributeName] = fnUnmarshal(value);
@@ -69137,7 +69182,7 @@ var CacheInternal = class {
69137
69182
  hasData = true;
69138
69183
  } else if (Array.isArray(value)) {
69139
69184
  const listValue = this.hydrateNestedList({
69140
- fields,
69185
+ fields: fieldSelection,
69141
69186
  variables,
69142
69187
  linkedList: value,
69143
69188
  stepsFromConnection: nextStep
@@ -69152,7 +69197,7 @@ var CacheInternal = class {
69152
69197
  } else {
69153
69198
  const objectFields = this.getSelection({
69154
69199
  parent: value,
69155
- selection: fields,
69200
+ selection: fieldSelection,
69156
69201
  variables,
69157
69202
  stepsFromConnection: nextStep
69158
69203
  });
@@ -70886,7 +70931,7 @@ var Config = class {
70886
70931
  typeConfig;
70887
70932
  configFile;
70888
70933
  logLevel;
70889
- disableMasking;
70934
+ defaultFragmentMasking = "enable";
70890
70935
  configIsRoute = null;
70891
70936
  routesDir;
70892
70937
  schemaPollInterval;
@@ -70899,6 +70944,11 @@ var Config = class {
70899
70944
  ...configFile
70900
70945
  }) {
70901
70946
  this.configFile = defaultConfigValues(configFile);
70947
+ if (configFile.disableMasking !== void 0) {
70948
+ throw new HoudiniError({
70949
+ message: `"disableMasking" was replaced by "defaultFragmentMasking". Please update your config file.`
70950
+ });
70951
+ }
70902
70952
  let {
70903
70953
  schema,
70904
70954
  schemaPath = "./schema.graphql",
@@ -70915,7 +70965,7 @@ var Config = class {
70915
70965
  defaultKeys,
70916
70966
  types: types14 = {},
70917
70967
  logLevel,
70918
- disableMasking = false,
70968
+ defaultFragmentMasking = "enable",
70919
70969
  schemaPollInterval = 2e3,
70920
70970
  schemaPollHeaders = {},
70921
70971
  projectDir
@@ -70934,7 +70984,11 @@ var Config = class {
70934
70984
  logLevel = LogLevel.Summary;
70935
70985
  }
70936
70986
  this.schemaPath = schemaPath;
70937
- this.apiUrl = apiUrl;
70987
+ if (apiUrl && apiUrl.startsWith("env:")) {
70988
+ this.apiUrl = process.env[apiUrl.slice("env:".length)];
70989
+ } else {
70990
+ this.apiUrl = apiUrl;
70991
+ }
70938
70992
  this.filepath = filepath;
70939
70993
  this.exclude = Array.isArray(exclude) ? exclude : [exclude];
70940
70994
  this.module = module2;
@@ -70946,10 +71000,10 @@ var Config = class {
70946
71000
  this.defaultCachePolicy = defaultCachePolicy;
70947
71001
  this.defaultPartial = defaultPartial;
70948
71002
  this.internalListPosition = defaultListPosition === "append" ? "last" : "first";
70949
- this.defaultListTarget == defaultListTarget;
71003
+ this.defaultListTarget = defaultListTarget;
70950
71004
  this.definitionsFolder = definitionsPath;
70951
71005
  this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
70952
- this.disableMasking = disableMasking;
71006
+ this.defaultFragmentMasking = defaultFragmentMasking;
70953
71007
  this.routesDir = join2(this.projectRoot, "src", "routes");
70954
71008
  this.schemaPollInterval = schemaPollInterval;
70955
71009
  this.schemaPollHeaders = schemaPollHeaders;
@@ -71143,8 +71197,14 @@ var Config = class {
71143
71197
  pluginDirectory(name2) {
71144
71198
  return houdini_mode.is_testing ? resolve("../../../", name2) : join2(this.rootDir, "plugins", name2);
71145
71199
  }
71146
- get houdiniDirective() {
71147
- return "houdini";
71200
+ get manualLoadDirective() {
71201
+ return "manual_load";
71202
+ }
71203
+ get maskEnableDirective() {
71204
+ return "mask_enable";
71205
+ }
71206
+ get maskDisableDirective() {
71207
+ return "mask_disable";
71148
71208
  }
71149
71209
  get listDirective() {
71150
71210
  return "list";
@@ -71156,9 +71216,9 @@ var Config = class {
71156
71216
  return "append";
71157
71217
  }
71158
71218
  get listParentDirective() {
71159
- return this.listDirectiveParentIDArg;
71219
+ return "parentID";
71160
71220
  }
71161
- get listDirectiveParentIDArg() {
71221
+ get deprecatedlistDirectiveParentIDArg() {
71162
71222
  return "parentID";
71163
71223
  }
71164
71224
  get listAllListsDirective() {
@@ -71244,7 +71304,7 @@ var Config = class {
71244
71304
  this.listDirective,
71245
71305
  this.listPrependDirective,
71246
71306
  this.listAppendDirective,
71247
- this.listDirectiveParentIDArg,
71307
+ this.listParentDirective,
71248
71308
  this.listAllListsDirective,
71249
71309
  this.whenDirective,
71250
71310
  this.whenNotDirective,
@@ -71252,7 +71312,9 @@ var Config = class {
71252
71312
  this.withDirective,
71253
71313
  this.paginateDirective,
71254
71314
  this.cacheDirective,
71255
- this.houdiniDirective
71315
+ this.manualLoadDirective,
71316
+ this.maskEnableDirective,
71317
+ this.maskDisableDirective
71256
71318
  ].includes(name2.value) || this.isDeleteDirective(name2.value);
71257
71319
  }
71258
71320
  isListFragment(name2) {
@@ -71823,13 +71885,17 @@ function flattenSelections({
71823
71885
  config: config2,
71824
71886
  filepath,
71825
71887
  selections,
71826
- fragmentDefinitions
71888
+ fragmentDefinitions,
71889
+ applyFragments,
71890
+ ignoreMaskDisable
71827
71891
  }) {
71828
71892
  const fields = new FieldCollection({
71829
71893
  config: config2,
71830
71894
  filepath,
71831
71895
  selections,
71832
- fragmentDefinitions
71896
+ fragmentDefinitions,
71897
+ applyFragments,
71898
+ ignoreMaskDisable: !!ignoreMaskDisable
71833
71899
  });
71834
71900
  return fields.toSelectionSet();
71835
71901
  }
@@ -71840,9 +71906,13 @@ var FieldCollection = class {
71840
71906
  fields;
71841
71907
  inlineFragments;
71842
71908
  fragmentSpreads;
71909
+ applyFragments;
71910
+ ignoreMaskDisable;
71843
71911
  constructor(args) {
71844
71912
  this.config = args.config;
71845
71913
  this.fragmentDefinitions = args.fragmentDefinitions;
71914
+ this.applyFragments = args.applyFragments;
71915
+ this.ignoreMaskDisable = args.ignoreMaskDisable;
71846
71916
  this.fields = {};
71847
71917
  this.inlineFragments = {};
71848
71918
  this.fragmentSpreads = {};
@@ -71871,31 +71941,28 @@ var FieldCollection = class {
71871
71941
  }
71872
71942
  }
71873
71943
  if (selection2.kind === "InlineFragment" && selection2.typeCondition) {
71874
- const key = selection2.typeCondition.name.value;
71875
- if (!this.inlineFragments[key]) {
71876
- this.inlineFragments[key] = {
71877
- astNode: selection2,
71878
- selection: this.empty()
71879
- };
71880
- }
71881
- for (const subselect of selection2.selectionSet?.selections || []) {
71882
- this.inlineFragments[key].selection.add(subselect);
71883
- }
71944
+ this.walkInlineFragment(selection2);
71884
71945
  return;
71885
71946
  }
71886
71947
  if (selection2.kind === "FragmentSpread") {
71887
71948
  this.fragmentSpreads[selection2.name.value] = selection2;
71888
- const houdiniDirective = selection2.directives?.find(
71889
- ({ name: name2 }) => name2.value === this.config.houdiniDirective
71949
+ let includeFragments = this.config.defaultFragmentMasking === "disable";
71950
+ const maskEnableDirective = selection2.directives?.find(
71951
+ ({ name: name2 }) => name2.value === this.config.maskEnableDirective
71890
71952
  );
71891
- const maskArgument = houdiniDirective?.arguments?.find(
71892
- ({ name: name2 }) => name2.value === "mask"
71953
+ if (maskEnableDirective) {
71954
+ includeFragments = false;
71955
+ }
71956
+ const maskDisableDirective = selection2.directives?.find(
71957
+ ({ name: name2 }) => name2.value === this.config.maskDisableDirective
71893
71958
  );
71894
- let includeFragments = this.config.disableMasking;
71895
- if (maskArgument?.value.kind === "BooleanValue") {
71896
- includeFragments = !maskArgument.value.value;
71959
+ if (maskDisableDirective) {
71960
+ includeFragments = true;
71897
71961
  }
71898
- if (!includeFragments) {
71962
+ if (this.ignoreMaskDisable) {
71963
+ includeFragments = true;
71964
+ }
71965
+ if (!includeFragments || !this.applyFragments) {
71899
71966
  return;
71900
71967
  }
71901
71968
  const definition = this.fragmentDefinitions[selection2.name.value];
@@ -71905,9 +71972,20 @@ var FieldCollection = class {
71905
71972
  message: "Could not find referenced fragment definition: " + selection2.name.value
71906
71973
  });
71907
71974
  }
71908
- for (const subselect of definition.selectionSet.selections) {
71909
- this.add(subselect);
71910
- }
71975
+ this.add({
71976
+ kind: "InlineFragment",
71977
+ typeCondition: {
71978
+ kind: "NamedType",
71979
+ name: {
71980
+ kind: "Name",
71981
+ value: definition.typeCondition.name.value
71982
+ }
71983
+ },
71984
+ selectionSet: {
71985
+ kind: "SelectionSet",
71986
+ selections: [...definition.selectionSet.selections]
71987
+ }
71988
+ });
71911
71989
  }
71912
71990
  }
71913
71991
  toSelectionSet() {
@@ -71923,12 +72001,30 @@ var FieldCollection = class {
71923
72001
  })
71924
72002
  ).concat(Object.values(this.fragmentSpreads));
71925
72003
  }
72004
+ walkInlineFragment(selection2) {
72005
+ const key = selection2.typeCondition.name.value;
72006
+ if (!this.inlineFragments[key]) {
72007
+ this.inlineFragments[key] = {
72008
+ astNode: selection2,
72009
+ selection: this.empty()
72010
+ };
72011
+ }
72012
+ for (const subselect of selection2.selectionSet.selections || []) {
72013
+ if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
72014
+ this.inlineFragments[key].selection.add(subselect);
72015
+ continue;
72016
+ }
72017
+ this.walkInlineFragment(subselect);
72018
+ }
72019
+ }
71926
72020
  empty() {
71927
72021
  return new FieldCollection({
71928
72022
  config: this.config,
71929
72023
  fragmentDefinitions: this.fragmentDefinitions,
71930
72024
  selections: [],
71931
- filepath: this.filepath
72025
+ filepath: this.filepath,
72026
+ applyFragments: this.applyFragments,
72027
+ ignoreMaskDisable: this.ignoreMaskDisable
71932
72028
  });
71933
72029
  }
71934
72030
  };
@@ -72283,11 +72379,6 @@ function operationObject({
72283
72379
  const when = internalDirectives.find(({ name: name2 }) => name2.value === "when");
72284
72380
  const when_not = internalDirectives.find(({ name: name2 }) => name2.value === "when_not");
72285
72381
  let parentIDArg = parent?.arguments?.find((argument) => argument.name.value === "value");
72286
- if (!parentIDArg) {
72287
- parentIDArg = (append || prepend)?.arguments?.find(
72288
- ({ name: name2 }) => name2.value === config2.listDirectiveParentIDArg
72289
- );
72290
- }
72291
72382
  if (parentIDArg) {
72292
72383
  if (parentIDArg.value.kind === "StringValue") {
72293
72384
  parentID = parentIDArg.value.value;
@@ -73315,6 +73406,8 @@ function selection({
73315
73406
  markEdges
73316
73407
  }) {
73317
73408
  let object = {};
73409
+ const typeMap = {};
73410
+ const abstractTypes = [];
73318
73411
  for (const field of selections) {
73319
73412
  if (field.kind === "FragmentSpread" && includeFragments) {
73320
73413
  const fragmentDefinition = document.document.definitions.find(
@@ -73341,20 +73434,68 @@ function selection({
73341
73434
  })
73342
73435
  );
73343
73436
  } else if (field.kind === "InlineFragment") {
73344
- object = deepMerge(
73345
- filepath,
73346
- object,
73347
- selection({
73348
- config: config2,
73437
+ if (!field.typeCondition || field.typeCondition.name.value === rootType) {
73438
+ object.fields = deepMerge(
73349
73439
  filepath,
73350
- rootType: field.typeCondition?.name.value || rootType,
73351
- operations,
73352
- selections: field.selectionSet.selections,
73353
- path: path2,
73354
- includeFragments,
73355
- document
73356
- })
73357
- );
73440
+ object.fields || {},
73441
+ selection({
73442
+ config: config2,
73443
+ filepath,
73444
+ rootType: field.typeCondition?.name.value || rootType,
73445
+ operations,
73446
+ selections: field.selectionSet.selections,
73447
+ path: path2,
73448
+ includeFragments,
73449
+ document
73450
+ }).fields || {}
73451
+ );
73452
+ } else {
73453
+ if (!object.abstractFields) {
73454
+ object.abstractFields = {
73455
+ fields: {},
73456
+ typeMap: {}
73457
+ };
73458
+ }
73459
+ const parentType = config2.schema.getType(rootType);
73460
+ const typeConditionName = field.typeCondition.name.value;
73461
+ const typeCondition = config2.schema.getType(typeConditionName);
73462
+ const possibleTypes = [];
73463
+ if (!graphql12.isAbstractType(typeCondition)) {
73464
+ } else if (graphql12.isAbstractType(parentType)) {
73465
+ const possibleParentTypes = config2.schema.getPossibleTypes(parentType).map((type) => type.name);
73466
+ for (const possible of config2.schema.getPossibleTypes(typeCondition)) {
73467
+ if (possibleParentTypes.includes(possible.name)) {
73468
+ possibleTypes.push(possible.name);
73469
+ }
73470
+ }
73471
+ } else {
73472
+ possibleTypes.push(rootType);
73473
+ }
73474
+ if (possibleTypes.length > 0) {
73475
+ for (const type of possibleTypes) {
73476
+ const existing = typeMap[type];
73477
+ if (!existing || !existing.includes(type)) {
73478
+ typeMap[type] = [typeConditionName].concat(existing || []);
73479
+ }
73480
+ if (!abstractTypes.includes(typeConditionName)) {
73481
+ abstractTypes.push(typeConditionName);
73482
+ }
73483
+ }
73484
+ }
73485
+ object.abstractFields.fields = {
73486
+ ...object.abstractFields.fields,
73487
+ [field.typeCondition.name.value]: selection({
73488
+ config: config2,
73489
+ filepath,
73490
+ rootType: field.typeCondition?.name.value || rootType,
73491
+ operations,
73492
+ selections: field.selectionSet.selections,
73493
+ path: path2,
73494
+ includeFragments,
73495
+ document
73496
+ }).fields
73497
+ };
73498
+ }
73358
73499
  } else if (field.kind === "Field") {
73359
73500
  const type = config2.schema.getType(rootType);
73360
73501
  if (!type) {
@@ -73412,7 +73553,7 @@ function selection({
73412
73553
  }
73413
73554
  if (field.selectionSet) {
73414
73555
  const edgesMark = paginated && document.refetch?.method === "cursor" ? document.refetch.update : markEdges;
73415
- fieldObj.fields = selection({
73556
+ fieldObj.selection = selection({
73416
73557
  config: config2,
73417
73558
  filepath,
73418
73559
  rootType: typeName,
@@ -73436,11 +73577,49 @@ function selection({
73436
73577
  if (graphql12.isInterfaceType(fieldType) || graphql12.isUnionType(fieldType)) {
73437
73578
  fieldObj.abstract = true;
73438
73579
  }
73439
- object[attributeName] = deepMerge(
73440
- filepath,
73441
- fieldObj,
73442
- object[attributeName] || {}
73443
- );
73580
+ object.fields = {
73581
+ ...object.fields,
73582
+ [attributeName]: fieldObj
73583
+ };
73584
+ }
73585
+ }
73586
+ if (Object.keys(object.fields || {}).length > 0 && object.abstractFields && Object.keys(object.abstractFields.fields).length > 0) {
73587
+ for (const [typeName, possibles] of Object.entries(typeMap)) {
73588
+ let overlap = false;
73589
+ for (const possible of possibles) {
73590
+ if (object.abstractFields.fields[typeName]) {
73591
+ object.abstractFields.fields[typeName] = deepMerge(
73592
+ filepath,
73593
+ object.abstractFields.fields[typeName] || {},
73594
+ object.abstractFields.fields[possible]
73595
+ );
73596
+ overlap = true;
73597
+ }
73598
+ }
73599
+ if (overlap) {
73600
+ delete typeMap[typeName];
73601
+ }
73602
+ }
73603
+ for (const [type, options] of Object.entries(typeMap)) {
73604
+ if (options.length > 1) {
73605
+ object.abstractFields.fields[type] = deepMerge(
73606
+ filepath,
73607
+ ...options.map((opt) => object.abstractFields.fields[opt] || {})
73608
+ );
73609
+ delete typeMap[type];
73610
+ }
73611
+ }
73612
+ for (const [type, sel] of Object.entries(object.abstractFields?.fields || {})) {
73613
+ object.abstractFields.fields[type] = deepMerge(filepath, sel || {}, object.fields);
73614
+ }
73615
+ for (const [type, options] of Object.entries(typeMap)) {
73616
+ object.abstractFields.typeMap[type] = options[0];
73617
+ }
73618
+ const usedTypes = Object.values(object.abstractFields.typeMap);
73619
+ for (const type of abstractTypes) {
73620
+ if (!usedTypes.includes(type)) {
73621
+ delete object.abstractFields.fields[type];
73622
+ }
73444
73623
  }
73445
73624
  }
73446
73625
  return object;
@@ -73575,6 +73754,22 @@ function artifactGenerator(stats) {
73575
73754
  selectionSet = matchingFragment.selectionSet;
73576
73755
  }
73577
73756
  const inputs = operations[0]?.variableDefinitions;
73757
+ const mergedSelection = flattenSelections({
73758
+ config: config2,
73759
+ filepath: doc.filename,
73760
+ selections: selectionSet.selections,
73761
+ fragmentDefinitions: doc.document.definitions.filter(
73762
+ (definition) => definition.kind === "FragmentDefinition"
73763
+ ).reduce(
73764
+ (prev, definition) => ({
73765
+ ...prev,
73766
+ [definition.name.value]: definition
73767
+ }),
73768
+ {}
73769
+ ),
73770
+ ignoreMaskDisable: docKind === "HoudiniQuery",
73771
+ applyFragments: docKind !== "HoudiniFragment"
73772
+ });
73578
73773
  const artifact = {
73579
73774
  name: name2,
73580
73775
  kind: docKind,
@@ -73586,7 +73781,7 @@ function artifactGenerator(stats) {
73586
73781
  config: config2,
73587
73782
  filepath: doc.filename,
73588
73783
  rootType,
73589
- selections: selectionSet.selections,
73784
+ selections: mergedSelection,
73590
73785
  operations: operationsByPath(
73591
73786
  config2,
73592
73787
  doc.filename,
@@ -73882,6 +74077,17 @@ function inlineType({
73882
74077
  continue;
73883
74078
  }
73884
74079
  const possibleParents = config2.schema.getPossibleTypes(type).map((t2) => t2.name);
74080
+ const freeSelections = [];
74081
+ const typeSpecificSelections = {};
74082
+ for (const node of selection2.selectionSet.selections) {
74083
+ if (node.kind !== "InlineFragment") {
74084
+ freeSelections.push(node);
74085
+ } else if (node.typeCondition) {
74086
+ typeSpecificSelections[node.typeCondition.name.value] = node.selectionSet.selections;
74087
+ } else {
74088
+ freeSelections.push(...node.selectionSet.selections);
74089
+ }
74090
+ }
73885
74091
  for (const possibleType of config2.schema.getPossibleTypes(fragmentType)) {
73886
74092
  if (!possibleParents.includes(possibleType.name)) {
73887
74093
  continue;
@@ -73889,7 +74095,12 @@ function inlineType({
73889
74095
  if (!inlineFragments[possibleType.name]) {
73890
74096
  inlineFragments[possibleType.name] = [];
73891
74097
  }
73892
- inlineFragments[possibleType.name].push(...selection2.selectionSet.selections);
74098
+ inlineFragments[possibleType.name].push(...freeSelections);
74099
+ if (typeSpecificSelections[possibleType.name]) {
74100
+ inlineFragments[possibleType.name].push(
74101
+ ...typeSpecificSelections[possibleType.name]
74102
+ );
74103
+ }
73893
74104
  }
73894
74105
  } else if (selection2.kind === "InlineFragment" && !selection2.typeCondition) {
73895
74106
  selectedFields.push(...selection2.selectionSet.selections);
@@ -73901,12 +74112,7 @@ function inlineType({
73901
74112
  ...(selectedFields || []).filter(
73902
74113
  (field) => field.kind === "Field"
73903
74114
  ).map((selection2) => {
73904
- const { type: type2, field } = selectionTypeInfo(
73905
- config2.schema,
73906
- filepath,
73907
- rootObj,
73908
- selection2
73909
- );
74115
+ const { field } = selectionTypeInfo(config2.schema, filepath, rootObj, selection2);
73910
74116
  const attributeName = selection2.alias?.value || selection2.name.value;
73911
74117
  let attributeType = inlineType({
73912
74118
  config: config2,
@@ -74105,7 +74311,8 @@ async function typescriptGenerator(config2, docs) {
74105
74311
  config: config2,
74106
74312
  filepath: filename,
74107
74313
  selections: definition.selectionSet.selections,
74108
- fragmentDefinitions
74314
+ fragmentDefinitions,
74315
+ applyFragments: definition.kind === "OperationDefinition"
74109
74316
  });
74110
74317
  if (definition?.kind === "OperationDefinition") {
74111
74318
  await generateOperationTypeDefs(
@@ -74618,14 +74825,12 @@ directive @${config2.paginateDirective}(${config2.paginateNameArg}: String) on F
74618
74825
  """
74619
74826
  @${config2.listPrependDirective} is used to tell the runtime to add the result to the end of the list
74620
74827
  """
74621
- directive @${config2.listPrependDirective}(
74622
- ${config2.listDirectiveParentIDArg}: ID
74623
- ) on FRAGMENT_SPREAD
74828
+ directive @${config2.listPrependDirective} on FRAGMENT_SPREAD
74624
74829
 
74625
74830
  """
74626
74831
  @${config2.listAppendDirective} is used to tell the runtime to add the result to the start of the list
74627
74832
  """
74628
- directive @${config2.listAppendDirective}(${config2.listDirectiveParentIDArg}: ID) on FRAGMENT_SPREAD
74833
+ directive @${config2.listAppendDirective} on FRAGMENT_SPREAD
74629
74834
 
74630
74835
  """
74631
74836
  @${config2.listAllListsDirective} is used to tell the runtime to add the result to all list
@@ -74659,18 +74864,19 @@ directive @${config2.argumentsDirective} on FRAGMENT_DEFINITION
74659
74864
  directive @${config2.cacheDirective}(${config2.cachePolicyArg}: CachePolicy, ${config2.cachePartialArg}: Boolean) on QUERY
74660
74865
 
74661
74866
  """
74662
- @${config2.houdiniDirective} is used to configure houdini's internal behavior
74867
+ @${config2.manualLoadDirective} is used to disable automatic fetch (no load, no auto fetch in component), you will have to do it manually.
74868
+ """
74869
+ directive @${config2.manualLoadDirective} on QUERY
74870
+
74871
+ """
74872
+ @${config2.maskEnableDirective} to enable masking on fragment (overwriting the global conf)
74873
+ """
74874
+ directive @${config2.maskEnableDirective} on FRAGMENT_SPREAD
74875
+
74876
+ """
74877
+ @${config2.maskDisableDirective} to disable masking on fragment (overwriting the global conf)
74663
74878
  """
74664
- directive @${config2.houdiniDirective}(
74665
- """
74666
- Opt-in to an automatic load function (only valid when used at queries)
74667
- """
74668
- load: Boolean! = true
74669
- """
74670
- Mask fragment fields (only valid when used at a fragment spread)
74671
- """
74672
- mask: Boolean! = ${config2.disableMasking ? "false" : "true"}
74673
- ) on QUERY | FRAGMENT_SPREAD
74879
+ directive @${config2.maskDisableDirective} on FRAGMENT_SPREAD
74674
74880
  `;
74675
74881
  let currentSchema = graphql21.printSchema(config2.schema);
74676
74882
  if (!currentSchema.includes(`directive @${config2.listDirective}`)) {
@@ -75163,26 +75369,42 @@ async function typeCheck(config2, docs) {
75163
75369
  ),
75164
75370
  targetField.selectionSet
75165
75371
  );
75166
- const missingIDFields = config2.keyFieldsForType(type.name).filter((fieldName) => !type.getFields()[fieldName]);
75167
- if (missingIDFields.length > 0) {
75168
- if (error) {
75169
- errors.push(
75170
- new HoudiniError({
75171
- filepath: filename,
75172
- message: error
75173
- })
75174
- );
75175
- } else {
75176
- errors.push(
75177
- new HoudiniError({
75178
- filepath: filename,
75179
- message: `@${config2.listDirective} can only be applied to types with the necessary id fields: ${missingIDFields.join(
75180
- ", "
75181
- )}.`
75182
- })
75183
- );
75372
+ let targetTypes = [type];
75373
+ if (graphql25.isUnionType(type)) {
75374
+ targetTypes = config2.schema.getPossibleTypes(type);
75375
+ } else if (graphql25.isInterfaceType(type)) {
75376
+ try {
75377
+ for (const key of config2.keyFieldsForType(type.name)) {
75378
+ if (!type.getFields()[key]) {
75379
+ throw new Error("continue");
75380
+ }
75381
+ }
75382
+ } catch {
75383
+ targetTypes = config2.schema.getPossibleTypes(type);
75384
+ }
75385
+ }
75386
+ for (const targetType of targetTypes) {
75387
+ const missingIDFields = config2.keyFieldsForType(targetType.name).filter((fieldName) => !targetType.getFields()[fieldName]);
75388
+ if (missingIDFields.length > 0) {
75389
+ if (error) {
75390
+ errors.push(
75391
+ new HoudiniError({
75392
+ filepath: filename,
75393
+ message: error
75394
+ })
75395
+ );
75396
+ } else {
75397
+ errors.push(
75398
+ new HoudiniError({
75399
+ filepath: filename,
75400
+ message: `@${config2.listDirective} can only be applied to types with the necessary id fields: ${missingIDFields.join(
75401
+ ", "
75402
+ )}.`
75403
+ })
75404
+ );
75405
+ }
75406
+ return;
75184
75407
  }
75185
- return;
75186
75408
  }
75187
75409
  lists.push(listName);
75188
75410
  listTypes.push(type.name);
@@ -75212,6 +75434,7 @@ async function typeCheck(config2, docs) {
75212
75434
  fragments
75213
75435
  }),
75214
75436
  checkMutationOperation(config2),
75437
+ checkMaskDirective(config2),
75215
75438
  nodeDirectives(config2, [config2.paginateDirective]),
75216
75439
  knownArguments(config2),
75217
75440
  validateFragmentArguments(config2, filepath, fragments),
@@ -75276,10 +75499,14 @@ var validateLists = ({
75276
75499
  ]);
75277
75500
  if (directive) {
75278
75501
  let parentArg = directive.arguments?.find(
75279
- (arg) => arg.name.value === config2.listDirectiveParentIDArg
75502
+ (arg) => arg.name.value === config2.deprecatedlistDirectiveParentIDArg
75280
75503
  );
75281
75504
  if (parentArg) {
75282
- parentIdFound = true;
75505
+ ctx.reportError(
75506
+ new graphql25.GraphQLError(
75507
+ `@${config2.deprecatedlistDirectiveParentIDArg} should be defined only in it's own directive now`
75508
+ )
75509
+ );
75283
75510
  }
75284
75511
  }
75285
75512
  if (parentIdFound) {
@@ -75675,6 +75902,28 @@ function checkMutationOperation(config2) {
75675
75902
  };
75676
75903
  };
75677
75904
  }
75905
+ function checkMaskDirective(config2) {
75906
+ return function(ctx) {
75907
+ return {
75908
+ FragmentSpread(node, _, __, ___, ancestors) {
75909
+ const maskEnableDirective = node.directives?.find(
75910
+ (c) => c.name.value === config2.maskEnableDirective
75911
+ );
75912
+ const maskDisableDirective = node.directives?.find(
75913
+ (c) => c.name.value === config2.maskDisableDirective
75914
+ );
75915
+ if (maskEnableDirective && maskDisableDirective) {
75916
+ ctx.reportError(
75917
+ new graphql25.GraphQLError(
75918
+ `You can't apply both @${config2.maskEnableDirective} and @${config2.maskDisableDirective} at the same time`
75919
+ )
75920
+ );
75921
+ return;
75922
+ }
75923
+ }
75924
+ };
75925
+ };
75926
+ }
75678
75927
  function getAndVerifyNodeInterface(config2) {
75679
75928
  const { schema } = config2;
75680
75929
  const nodeInterface = schema.getType("Node");
@@ -75972,12 +76221,7 @@ async function collectDocuments(config2) {
75972
76221
  }
75973
76222
  async function processJSFile(config2, contents) {
75974
76223
  const documents = [];
75975
- try {
75976
- var program3 = (await parseJS(contents)).script;
75977
- } catch (e2) {
75978
- console.log(contents);
75979
- throw e2;
75980
- }
76224
+ var program3 = (await parseJS(contents)).script;
75981
76225
  await find_graphql(config2, program3, {
75982
76226
  tag({ tagContent }) {
75983
76227
  documents.push(tagContent);
@@ -76277,7 +76521,6 @@ async function init(_path, args) {
76277
76521
  const sourceDir = path_exports.join(targetPath, "src");
76278
76522
  const configPath = path_exports.join(targetPath, "houdini.config.js");
76279
76523
  const houdiniClientPath = typescript ? path_exports.join(sourceDir, "client.ts") : path_exports.join(sourceDir, "client.js");
76280
- const houdiniClientImport = "./src/client";
76281
76524
  console.log("\u{1F6A7} Generating project files...");
76282
76525
  await updatePackageJSON(targetPath);
76283
76526
  if (is_remote_endpoint) {
@@ -76287,8 +76530,7 @@ async function init(_path, args) {
76287
76530
  configPath,
76288
76531
  schemaPath,
76289
76532
  module: module2,
76290
- url: is_remote_endpoint ? url : null,
76291
- houdiniClientImport
76533
+ url: is_remote_endpoint ? url : null
76292
76534
  });
76293
76535
  await fs_exports.writeFile(houdiniClientPath, networkFile(url, typescript));
76294
76536
  await graphqlRCFile(targetPath);
@@ -76345,8 +76587,7 @@ var writeConfigFile = async ({
76345
76587
  configPath,
76346
76588
  schemaPath,
76347
76589
  module: module2,
76348
- url,
76349
- houdiniClientImport
76590
+ url
76350
76591
  }) => {
76351
76592
  const config2 = {};
76352
76593
  if (url !== null) {
@@ -76359,9 +76600,7 @@ var writeConfigFile = async ({
76359
76600
  config2.module = module2;
76360
76601
  }
76361
76602
  config2.plugins = {
76362
- "houdini-svelte": {
76363
- client: houdiniClientImport
76364
- }
76603
+ "houdini-svelte": {}
76365
76604
  };
76366
76605
  const configObj = JSON.stringify(config2, null, 4);
76367
76606
  const content_base = `/// <references types="houdini-svelte">
@@ -76535,8 +76774,8 @@ async function updatePackageJSON(targetPath) {
76535
76774
  }
76536
76775
  packageJSON.devDependencies = {
76537
76776
  ...packageJSON.devDependencies,
76538
- houdini: "^0.17.14",
76539
- "houdini-svelte": "^0.17.14",
76777
+ houdini: "^0.18.1",
76778
+ "houdini-svelte": "^0.18.1",
76540
76779
  graphql: "^15.8.0"
76541
76780
  };
76542
76781
  await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));