houdini 0.17.13 → 0.18.0

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 +438 -201
  2. package/build/cmd-esm/index.js +438 -201
  3. package/build/codegen/utils/flattenSelections.d.ts +3 -1
  4. package/build/codegen-cjs/index.js +405 -180
  5. package/build/codegen-esm/index.js +405 -180
  6. package/build/lib/config.d.ts +8 -3
  7. package/build/lib-cjs/index.js +141 -81
  8. package/build/lib-esm/index.js +141 -81
  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 +38 -23
  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 +38 -23
  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 +485 -195
  36. package/build/test-esm/index.js +485 -195
  37. package/build/vite-cjs/index.js +438 -193
  38. package/build/vite-esm/index.js +438 -193
  39. package/package.json +2 -2
  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
@@ -5105,7 +5105,7 @@ var require_definition = __commonJS({
5105
5105
  exports.assertObjectType = assertObjectType;
5106
5106
  exports.isInterfaceType = isInterfaceType12;
5107
5107
  exports.assertInterfaceType = assertInterfaceType;
5108
- exports.isUnionType = isUnionType12;
5108
+ exports.isUnionType = isUnionType13;
5109
5109
  exports.assertUnionType = assertUnionType;
5110
5110
  exports.isEnumType = isEnumType9;
5111
5111
  exports.assertEnumType = assertEnumType;
@@ -5123,7 +5123,7 @@ var require_definition = __commonJS({
5123
5123
  exports.assertLeafType = assertLeafType;
5124
5124
  exports.isCompositeType = isCompositeType;
5125
5125
  exports.assertCompositeType = assertCompositeType;
5126
- exports.isAbstractType = isAbstractType;
5126
+ exports.isAbstractType = isAbstractType2;
5127
5127
  exports.assertAbstractType = assertAbstractType;
5128
5128
  exports.GraphQLList = GraphQLList6;
5129
5129
  exports.GraphQLNonNull = GraphQLNonNull6;
@@ -5178,7 +5178,7 @@ var require_definition = __commonJS({
5178
5178
  return Constructor;
5179
5179
  }
5180
5180
  function isType(type) {
5181
- return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType12(type) || isEnumType9(type) || isInputObjectType7(type) || isListType8(type) || isNonNullType10(type);
5181
+ return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType9(type) || isInputObjectType7(type) || isListType8(type) || isNonNullType10(type);
5182
5182
  }
5183
5183
  function assertType(type) {
5184
5184
  if (!isType(type)) {
@@ -5213,11 +5213,11 @@ var require_definition = __commonJS({
5213
5213
  }
5214
5214
  return type;
5215
5215
  }
5216
- function isUnionType12(type) {
5216
+ function isUnionType13(type) {
5217
5217
  return (0, _instanceOf.default)(type, GraphQLUnionType3);
5218
5218
  }
5219
5219
  function assertUnionType(type) {
5220
- if (!isUnionType12(type)) {
5220
+ if (!isUnionType13(type)) {
5221
5221
  throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Union type."));
5222
5222
  }
5223
5223
  return type;
@@ -5268,7 +5268,7 @@ var require_definition = __commonJS({
5268
5268
  return type;
5269
5269
  }
5270
5270
  function isOutputType(type) {
5271
- return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType12(type) || isEnumType9(type) || isWrappingType(type) && isOutputType(type.ofType);
5271
+ return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType9(type) || isWrappingType(type) && isOutputType(type.ofType);
5272
5272
  }
5273
5273
  function assertOutputType(type) {
5274
5274
  if (!isOutputType(type)) {
@@ -5286,7 +5286,7 @@ var require_definition = __commonJS({
5286
5286
  return type;
5287
5287
  }
5288
5288
  function isCompositeType(type) {
5289
- return isObjectType11(type) || isInterfaceType12(type) || isUnionType12(type);
5289
+ return isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type);
5290
5290
  }
5291
5291
  function assertCompositeType(type) {
5292
5292
  if (!isCompositeType(type)) {
@@ -5294,11 +5294,11 @@ var require_definition = __commonJS({
5294
5294
  }
5295
5295
  return type;
5296
5296
  }
5297
- function isAbstractType(type) {
5298
- return isInterfaceType12(type) || isUnionType12(type);
5297
+ function isAbstractType2(type) {
5298
+ return isInterfaceType12(type) || isUnionType13(type);
5299
5299
  }
5300
5300
  function assertAbstractType(type) {
5301
- if (!isAbstractType(type)) {
5301
+ if (!isAbstractType2(type)) {
5302
5302
  throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL abstract type."));
5303
5303
  }
5304
5304
  return type;
@@ -5365,7 +5365,7 @@ var require_definition = __commonJS({
5365
5365
  }
5366
5366
  }
5367
5367
  function isNamedType4(type) {
5368
- return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType12(type) || isEnumType9(type) || isInputObjectType7(type);
5368
+ return isScalarType12(type) || isObjectType11(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType9(type) || isInputObjectType7(type);
5369
5369
  }
5370
5370
  function assertNamedType(type) {
5371
5371
  if (!isNamedType4(type)) {
@@ -67742,6 +67742,20 @@ function deepEquals(objA, objB, map = /* @__PURE__ */ new WeakMap()) {
67742
67742
  return true;
67743
67743
  }
67744
67744
 
67745
+ // src/runtime/lib/selection.ts
67746
+ function getFieldsForType(selection2, __typename) {
67747
+ let targetSelection = selection2.fields || {};
67748
+ if (selection2.abstractFields && __typename) {
67749
+ const mappedType = selection2.abstractFields.typeMap[__typename];
67750
+ if (mappedType) {
67751
+ targetSelection = selection2.abstractFields.fields[mappedType];
67752
+ } else if (selection2.abstractFields.fields[__typename]) {
67753
+ targetSelection = selection2.abstractFields.fields[__typename];
67754
+ }
67755
+ }
67756
+ return targetSelection;
67757
+ }
67758
+
67745
67759
  // src/runtime/cache/gc.ts
67746
67760
  var GarbageCollector = class {
67747
67761
  cache;
@@ -67964,23 +67978,32 @@ var List = class {
67964
67978
  let insertData = data;
67965
67979
  if (this.connection) {
67966
67980
  insertSelection = {
67967
- newEntry: {
67968
- keyRaw: this.key,
67969
- type: "Connection",
67970
- fields: {
67971
- edges: {
67972
- keyRaw: "edges",
67973
- type: "ConnectionEdge",
67974
- update: where === "first" ? "prepend" : "append",
67981
+ fields: {
67982
+ newEntry: {
67983
+ keyRaw: this.key,
67984
+ type: "Connection",
67985
+ selection: {
67975
67986
  fields: {
67976
- node: {
67977
- type: listType,
67978
- keyRaw: "node",
67979
- fields: {
67980
- ...selection2,
67981
- __typename: {
67982
- keyRaw: "__typename",
67983
- type: "String"
67987
+ edges: {
67988
+ keyRaw: "edges",
67989
+ type: "ConnectionEdge",
67990
+ update: where === "first" ? "prepend" : "append",
67991
+ selection: {
67992
+ fields: {
67993
+ node: {
67994
+ type: listType,
67995
+ keyRaw: "node",
67996
+ selection: {
67997
+ ...selection2,
67998
+ fields: {
67999
+ ...selection2.fields,
68000
+ __typename: {
68001
+ keyRaw: "__typename",
68002
+ type: "String"
68003
+ }
68004
+ }
68005
+ }
68006
+ }
67984
68007
  }
67985
68008
  }
67986
68009
  }
@@ -67996,15 +68019,20 @@ var List = class {
67996
68019
  };
67997
68020
  } else {
67998
68021
  insertSelection = {
67999
- newEntries: {
68000
- keyRaw: this.key,
68001
- type: listType,
68002
- update: where === "first" ? "prepend" : "append",
68003
- fields: {
68004
- ...selection2,
68005
- __typename: {
68006
- keyRaw: "__typename",
68007
- type: "String"
68022
+ fields: {
68023
+ newEntries: {
68024
+ keyRaw: this.key,
68025
+ type: listType,
68026
+ update: where === "first" ? "prepend" : "append",
68027
+ selection: {
68028
+ ...selection2,
68029
+ fields: {
68030
+ ...selection2.fields,
68031
+ __typename: {
68032
+ keyRaw: "__typename",
68033
+ type: "String"
68034
+ }
68035
+ }
68008
68036
  }
68009
68037
  }
68010
68038
  }
@@ -68064,7 +68092,7 @@ var List = class {
68064
68092
  const subscribers = this.cache._internal_unstable.subscriptions.get(this.recordID, this.key);
68065
68093
  this.cache._internal_unstable.subscriptions.remove(
68066
68094
  targetID,
68067
- this.connection ? this.selection.edges.fields : this.selection,
68095
+ this.connection ? this.selection.fields.edges.selection : this.selection,
68068
68096
  subscribers,
68069
68097
  variables
68070
68098
  );
@@ -68553,18 +68581,20 @@ var InMemorySubscriptions = class {
68553
68581
  variables,
68554
68582
  parentType
68555
68583
  }) {
68556
- for (const fieldSelection of Object.values(selection2)) {
68557
- const { keyRaw, fields, type } = fieldSelection;
68584
+ const __typename = this.cache._internal_unstable.storage.get(parent, "__typename").value;
68585
+ let targetSelection = getFieldsForType(selection2, __typename);
68586
+ for (const fieldSelection of Object.values(targetSelection || {})) {
68587
+ const { keyRaw, selection: innerSelection, type } = fieldSelection;
68558
68588
  const key = evaluateKey(keyRaw, variables);
68559
68589
  this.addFieldSubscription({
68560
68590
  id: parent,
68561
68591
  key,
68562
- selection: fieldSelection,
68592
+ field: fieldSelection,
68563
68593
  spec,
68564
68594
  parentType: parentType || spec.rootType,
68565
68595
  variables
68566
68596
  });
68567
- if (fields) {
68597
+ if (innerSelection) {
68568
68598
  const { value: linkedRecord } = this.cache._internal_unstable.storage.get(
68569
68599
  parent,
68570
68600
  key
@@ -68577,7 +68607,7 @@ var InMemorySubscriptions = class {
68577
68607
  this.add({
68578
68608
  parent: child,
68579
68609
  spec,
68580
- selection: fields,
68610
+ selection: innerSelection,
68581
68611
  variables,
68582
68612
  parentType: type
68583
68613
  });
@@ -68588,7 +68618,7 @@ var InMemorySubscriptions = class {
68588
68618
  addFieldSubscription({
68589
68619
  id,
68590
68620
  key,
68591
- selection: selection2,
68621
+ field,
68592
68622
  spec,
68593
68623
  parentType,
68594
68624
  variables
@@ -68615,8 +68645,8 @@ var InMemorySubscriptions = class {
68615
68645
  const counts = this.referenceCounts[id][key];
68616
68646
  counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
68617
68647
  this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
68618
- const { fields, list, filters } = selection2;
68619
- if (fields && list) {
68648
+ const { selection: selection2, list, filters } = field;
68649
+ if (selection2 && list) {
68620
68650
  this.cache._internal_unstable.lists.add({
68621
68651
  name: list.name,
68622
68652
  connection: list.connection,
@@ -68624,7 +68654,7 @@ var InMemorySubscriptions = class {
68624
68654
  recordType: this.cache._internal_unstable.storage.get(id, "__typename")?.value || parentType,
68625
68655
  listType: list.type,
68626
68656
  key,
68627
- selection: fields,
68657
+ selection: selection2,
68628
68658
  filters: Object.entries(filters || {}).reduce((acc, [key2, { kind, value }]) => {
68629
68659
  return {
68630
68660
  ...acc,
@@ -68641,20 +68671,21 @@ var InMemorySubscriptions = class {
68641
68671
  subscribers,
68642
68672
  parentType
68643
68673
  }) {
68644
- for (const fieldSelection of Object.values(selection2)) {
68645
- const { type: linkedType, keyRaw, fields } = fieldSelection;
68674
+ let targetSelection = getFieldsForType(selection2, parentType);
68675
+ for (const fieldSelection of Object.values(targetSelection)) {
68676
+ const { type: linkedType, keyRaw, selection: innerSelection } = fieldSelection;
68646
68677
  const key = evaluateKey(keyRaw, variables);
68647
68678
  for (const spec of subscribers) {
68648
68679
  this.addFieldSubscription({
68649
68680
  id: parent,
68650
68681
  key,
68651
- selection: fieldSelection,
68682
+ field: fieldSelection,
68652
68683
  spec,
68653
68684
  parentType,
68654
68685
  variables
68655
68686
  });
68656
68687
  }
68657
- if (fields) {
68688
+ if (innerSelection) {
68658
68689
  const { value: link } = this.cache._internal_unstable.storage.get(parent, key);
68659
68690
  const children = !Array.isArray(link) ? [link] : flattenList(link);
68660
68691
  for (const linkedRecord of children) {
@@ -68663,7 +68694,7 @@ var InMemorySubscriptions = class {
68663
68694
  }
68664
68695
  this.addMany({
68665
68696
  parent: linkedRecord,
68666
- selection: fields,
68697
+ selection: innerSelection,
68667
68698
  variables,
68668
68699
  subscribers,
68669
68700
  parentType: linkedType
@@ -68675,22 +68706,20 @@ var InMemorySubscriptions = class {
68675
68706
  get(id, field) {
68676
68707
  return this.subscribers[id]?.[field] || [];
68677
68708
  }
68678
- remove(id, fields, targets, variables, visited = []) {
68709
+ remove(id, selection2, targets, variables, visited = []) {
68679
68710
  visited.push(id);
68680
68711
  const linkedIDs = [];
68681
- for (const selection2 of Object.values(fields)) {
68682
- const key = evaluateKey(selection2.keyRaw, variables);
68712
+ for (const fieldSelection of Object.values(selection2.fields || {})) {
68713
+ const key = evaluateKey(fieldSelection.keyRaw, variables);
68683
68714
  this.removeSubscribers(id, key, targets);
68684
- if (!selection2.fields) {
68715
+ if (!fieldSelection.selection?.fields) {
68685
68716
  continue;
68686
68717
  }
68687
- if (selection2.list) {
68688
- }
68689
68718
  const { value: previousValue } = this.cache._internal_unstable.storage.get(id, key);
68690
68719
  const links = !Array.isArray(previousValue) ? [previousValue] : flattenList(previousValue);
68691
68720
  for (const link of links) {
68692
68721
  if (link !== null) {
68693
- linkedIDs.push([link, selection2.fields]);
68722
+ linkedIDs.push([link, fieldSelection.selection || {}]);
68694
68723
  }
68695
68724
  }
68696
68725
  }
@@ -68868,8 +68897,9 @@ var CacheInternal = class {
68868
68897
  if (this._disabled) {
68869
68898
  return [];
68870
68899
  }
68900
+ let targetSelection = getFieldsForType(selection2, data["__typename"]);
68871
68901
  for (const [field, value] of Object.entries(data)) {
68872
- if (!selection2 || !selection2[field]) {
68902
+ if (!selection2 || !targetSelection[field]) {
68873
68903
  throw new Error(
68874
68904
  "Could not find field listing in selection for " + field + " @ " + JSON.stringify(selection2)
68875
68905
  );
@@ -68877,11 +68907,11 @@ var CacheInternal = class {
68877
68907
  let {
68878
68908
  type: linkedType,
68879
68909
  keyRaw,
68880
- fields,
68910
+ selection: fieldSelection,
68881
68911
  operations,
68882
68912
  abstract: isAbstract,
68883
68913
  update
68884
- } = selection2[field];
68914
+ } = targetSelection[field];
68885
68915
  const key = evaluateKey(keyRaw, variables);
68886
68916
  const currentSubscribers = this.subscriptions.get(parent, key);
68887
68917
  const { value: previousValue, displayLayers } = this.storage.get(parent, key);
@@ -68889,7 +68919,7 @@ var CacheInternal = class {
68889
68919
  if (displayLayer) {
68890
68920
  this.lifetimes.resetLifetime(parent, key);
68891
68921
  }
68892
- if (!fields) {
68922
+ if (!fieldSelection) {
68893
68923
  let newValue = value;
68894
68924
  if (Array.isArray(value) && applyUpdates && update) {
68895
68925
  if (update === "append") {
@@ -68909,7 +68939,7 @@ var CacheInternal = class {
68909
68939
  }
68910
68940
  const previousLinks = flattenList([previousValue]);
68911
68941
  for (const link of previousLinks) {
68912
- this.subscriptions.remove(link, fields, currentSubscribers, variables);
68942
+ this.subscriptions.remove(link, fieldSelection, currentSubscribers, variables);
68913
68943
  }
68914
68944
  layer.writeLink(parent, key, null);
68915
68945
  toNotify.push(...currentSubscribers);
@@ -68935,14 +68965,14 @@ var CacheInternal = class {
68935
68965
  if (previousValue && typeof previousValue === "string") {
68936
68966
  this.subscriptions.remove(
68937
68967
  previousValue,
68938
- fields,
68968
+ fieldSelection,
68939
68969
  currentSubscribers,
68940
68970
  variables
68941
68971
  );
68942
68972
  }
68943
68973
  this.subscriptions.addMany({
68944
68974
  parent: linkedID,
68945
- selection: fields,
68975
+ selection: fieldSelection,
68946
68976
  subscribers: currentSubscribers,
68947
68977
  variables,
68948
68978
  parentType: linkedType
@@ -68952,14 +68982,14 @@ var CacheInternal = class {
68952
68982
  if (linkedID) {
68953
68983
  this.writeSelection({
68954
68984
  root,
68955
- selection: fields,
68985
+ selection: fieldSelection,
68956
68986
  parent: linkedID,
68957
68987
  data: value,
68958
68988
  variables,
68959
68989
  toNotify,
68960
68990
  applyUpdates,
68961
68991
  layer,
68962
- forceNotify: true
68992
+ forceNotify
68963
68993
  });
68964
68994
  }
68965
68995
  } else if (Array.isArray(value) && (typeof previousValue === "undefined" || Array.isArray(previousValue))) {
@@ -68988,7 +69018,7 @@ var CacheInternal = class {
68988
69018
  key,
68989
69019
  linkedType,
68990
69020
  variables,
68991
- fields,
69021
+ fields: fieldSelection,
68992
69022
  layer,
68993
69023
  forceNotify
68994
69024
  });
@@ -69038,7 +69068,7 @@ var CacheInternal = class {
69038
69068
  if (linkedIDs.includes(lostID) || !lostID) {
69039
69069
  continue;
69040
69070
  }
69041
- this.subscriptions.remove(lostID, fields, currentSubscribers, variables);
69071
+ this.subscriptions.remove(lostID, fieldSelection, currentSubscribers, variables);
69042
69072
  }
69043
69073
  if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
69044
69074
  layer.writeLink(parent, key, linkedIDs);
@@ -69049,7 +69079,7 @@ var CacheInternal = class {
69049
69079
  }
69050
69080
  this.subscriptions.addMany({
69051
69081
  parent: id,
69052
- selection: fields,
69082
+ selection: fieldSelection,
69053
69083
  subscribers: currentSubscribers,
69054
69084
  variables,
69055
69085
  parentType: linkedType
@@ -69074,9 +69104,14 @@ var CacheInternal = class {
69074
69104
  }
69075
69105
  const targets = Array.isArray(value) ? value : [value];
69076
69106
  for (const target of targets) {
69077
- if (operation.action === "insert" && target instanceof Object && fields && operation.list) {
69078
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(fields, target, variables, operation.position || "last");
69079
- } else if (operation.action === "remove" && target instanceof Object && fields && operation.list) {
69107
+ if (operation.action === "insert" && target instanceof Object && fieldSelection && operation.list) {
69108
+ this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(
69109
+ fieldSelection,
69110
+ target,
69111
+ variables,
69112
+ operation.position || "last"
69113
+ );
69114
+ } else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
69080
69115
  this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
69081
69116
  } else if (operation.action === "delete" && operation.type) {
69082
69117
  if (typeof target !== "string") {
@@ -69087,8 +69122,13 @@ var CacheInternal = class {
69087
69122
  continue;
69088
69123
  }
69089
69124
  this.cache.delete(targetID);
69090
- } else if (operation.action === "toggle" && target instanceof Object && fields && operation.list) {
69091
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(fields, target, variables, operation.position || "last");
69125
+ } else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
69126
+ this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
69127
+ fieldSelection,
69128
+ target,
69129
+ variables,
69130
+ operation.position || "last"
69131
+ );
69092
69132
  }
69093
69133
  }
69094
69134
  }
@@ -69108,9 +69148,12 @@ var CacheInternal = class {
69108
69148
  let hasData = false;
69109
69149
  let partial = false;
69110
69150
  let cascadeNull = false;
69111
- for (const [attributeName, { type, keyRaw, fields, nullable, list }] of Object.entries(
69112
- selection2
69113
- )) {
69151
+ const typename = this.storage.get(parent, "__typename").value;
69152
+ let targetSelection = getFieldsForType(selection2, typename);
69153
+ for (const [
69154
+ attributeName,
69155
+ { type, keyRaw, selection: fieldSelection, nullable, list }
69156
+ ] of Object.entries(targetSelection)) {
69114
69157
  const key = evaluateKey(keyRaw, variables);
69115
69158
  const { value } = this.storage.get(parent, key);
69116
69159
  let nextStep = stepsFromConnection;
@@ -69133,7 +69176,7 @@ var CacheInternal = class {
69133
69176
  if (typeof value !== "undefined") {
69134
69177
  hasData = true;
69135
69178
  }
69136
- } else if (!fields) {
69179
+ } else if (!fieldSelection) {
69137
69180
  const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
69138
69181
  if (fnUnmarshal) {
69139
69182
  target[attributeName] = fnUnmarshal(value);
@@ -69143,7 +69186,7 @@ var CacheInternal = class {
69143
69186
  hasData = true;
69144
69187
  } else if (Array.isArray(value)) {
69145
69188
  const listValue = this.hydrateNestedList({
69146
- fields,
69189
+ fields: fieldSelection,
69147
69190
  variables,
69148
69191
  linkedList: value,
69149
69192
  stepsFromConnection: nextStep
@@ -69158,7 +69201,7 @@ var CacheInternal = class {
69158
69201
  } else {
69159
69202
  const objectFields = this.getSelection({
69160
69203
  parent: value,
69161
- selection: fields,
69204
+ selection: fieldSelection,
69162
69205
  variables,
69163
69206
  stepsFromConnection: nextStep
69164
69207
  });
@@ -70891,7 +70934,7 @@ var Config = class {
70891
70934
  typeConfig;
70892
70935
  configFile;
70893
70936
  logLevel;
70894
- disableMasking;
70937
+ defaultFragmentMasking = "enable";
70895
70938
  configIsRoute = null;
70896
70939
  routesDir;
70897
70940
  schemaPollInterval;
@@ -70904,6 +70947,11 @@ var Config = class {
70904
70947
  ...configFile
70905
70948
  }) {
70906
70949
  this.configFile = defaultConfigValues(configFile);
70950
+ if (configFile.disableMasking !== void 0) {
70951
+ throw new HoudiniError({
70952
+ message: `"disableMasking" was replaced by "defaultFragmentMasking". Please update your config file.`
70953
+ });
70954
+ }
70907
70955
  let {
70908
70956
  schema,
70909
70957
  schemaPath = "./schema.graphql",
@@ -70920,7 +70968,7 @@ var Config = class {
70920
70968
  defaultKeys,
70921
70969
  types: types14 = {},
70922
70970
  logLevel,
70923
- disableMasking = false,
70971
+ defaultFragmentMasking = "enable",
70924
70972
  schemaPollInterval = 2e3,
70925
70973
  schemaPollHeaders = {},
70926
70974
  projectDir
@@ -70939,7 +70987,11 @@ var Config = class {
70939
70987
  logLevel = LogLevel.Summary;
70940
70988
  }
70941
70989
  this.schemaPath = schemaPath;
70942
- this.apiUrl = apiUrl;
70990
+ if (apiUrl && apiUrl.startsWith("env:")) {
70991
+ this.apiUrl = process.env[apiUrl.slice("env:".length)];
70992
+ } else {
70993
+ this.apiUrl = apiUrl;
70994
+ }
70943
70995
  this.filepath = filepath;
70944
70996
  this.exclude = Array.isArray(exclude) ? exclude : [exclude];
70945
70997
  this.module = module;
@@ -70951,10 +71003,10 @@ var Config = class {
70951
71003
  this.defaultCachePolicy = defaultCachePolicy;
70952
71004
  this.defaultPartial = defaultPartial;
70953
71005
  this.internalListPosition = defaultListPosition === "append" ? "last" : "first";
70954
- this.defaultListTarget == defaultListTarget;
71006
+ this.defaultListTarget = defaultListTarget;
70955
71007
  this.definitionsFolder = definitionsPath;
70956
71008
  this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
70957
- this.disableMasking = disableMasking;
71009
+ this.defaultFragmentMasking = defaultFragmentMasking;
70958
71010
  this.routesDir = join2(this.projectRoot, "src", "routes");
70959
71011
  this.schemaPollInterval = schemaPollInterval;
70960
71012
  this.schemaPollHeaders = schemaPollHeaders;
@@ -71148,8 +71200,14 @@ var Config = class {
71148
71200
  pluginDirectory(name2) {
71149
71201
  return houdini_mode.is_testing ? resolve("../../../", name2) : join2(this.rootDir, "plugins", name2);
71150
71202
  }
71151
- get houdiniDirective() {
71152
- return "houdini";
71203
+ get manualLoadDirective() {
71204
+ return "manual_load";
71205
+ }
71206
+ get maskEnableDirective() {
71207
+ return "mask_enable";
71208
+ }
71209
+ get maskDisableDirective() {
71210
+ return "mask_disable";
71153
71211
  }
71154
71212
  get listDirective() {
71155
71213
  return "list";
@@ -71161,9 +71219,9 @@ var Config = class {
71161
71219
  return "append";
71162
71220
  }
71163
71221
  get listParentDirective() {
71164
- return this.listDirectiveParentIDArg;
71222
+ return "parentID";
71165
71223
  }
71166
- get listDirectiveParentIDArg() {
71224
+ get deprecatedlistDirectiveParentIDArg() {
71167
71225
  return "parentID";
71168
71226
  }
71169
71227
  get listAllListsDirective() {
@@ -71249,7 +71307,7 @@ var Config = class {
71249
71307
  this.listDirective,
71250
71308
  this.listPrependDirective,
71251
71309
  this.listAppendDirective,
71252
- this.listDirectiveParentIDArg,
71310
+ this.listParentDirective,
71253
71311
  this.listAllListsDirective,
71254
71312
  this.whenDirective,
71255
71313
  this.whenNotDirective,
@@ -71257,7 +71315,9 @@ var Config = class {
71257
71315
  this.withDirective,
71258
71316
  this.paginateDirective,
71259
71317
  this.cacheDirective,
71260
- this.houdiniDirective
71318
+ this.manualLoadDirective,
71319
+ this.maskEnableDirective,
71320
+ this.maskDisableDirective
71261
71321
  ].includes(name2.value) || this.isDeleteDirective(name2.value);
71262
71322
  }
71263
71323
  isListFragment(name2) {
@@ -71828,13 +71888,17 @@ function flattenSelections({
71828
71888
  config: config2,
71829
71889
  filepath,
71830
71890
  selections,
71831
- fragmentDefinitions
71891
+ fragmentDefinitions,
71892
+ applyFragments,
71893
+ ignoreMaskDisable
71832
71894
  }) {
71833
71895
  const fields = new FieldCollection({
71834
71896
  config: config2,
71835
71897
  filepath,
71836
71898
  selections,
71837
- fragmentDefinitions
71899
+ fragmentDefinitions,
71900
+ applyFragments,
71901
+ ignoreMaskDisable: !!ignoreMaskDisable
71838
71902
  });
71839
71903
  return fields.toSelectionSet();
71840
71904
  }
@@ -71845,9 +71909,13 @@ var FieldCollection = class {
71845
71909
  fields;
71846
71910
  inlineFragments;
71847
71911
  fragmentSpreads;
71912
+ applyFragments;
71913
+ ignoreMaskDisable;
71848
71914
  constructor(args) {
71849
71915
  this.config = args.config;
71850
71916
  this.fragmentDefinitions = args.fragmentDefinitions;
71917
+ this.applyFragments = args.applyFragments;
71918
+ this.ignoreMaskDisable = args.ignoreMaskDisable;
71851
71919
  this.fields = {};
71852
71920
  this.inlineFragments = {};
71853
71921
  this.fragmentSpreads = {};
@@ -71876,31 +71944,28 @@ var FieldCollection = class {
71876
71944
  }
71877
71945
  }
71878
71946
  if (selection2.kind === "InlineFragment" && selection2.typeCondition) {
71879
- const key = selection2.typeCondition.name.value;
71880
- if (!this.inlineFragments[key]) {
71881
- this.inlineFragments[key] = {
71882
- astNode: selection2,
71883
- selection: this.empty()
71884
- };
71885
- }
71886
- for (const subselect of selection2.selectionSet?.selections || []) {
71887
- this.inlineFragments[key].selection.add(subselect);
71888
- }
71947
+ this.walkInlineFragment(selection2);
71889
71948
  return;
71890
71949
  }
71891
71950
  if (selection2.kind === "FragmentSpread") {
71892
71951
  this.fragmentSpreads[selection2.name.value] = selection2;
71893
- const houdiniDirective = selection2.directives?.find(
71894
- ({ name: name2 }) => name2.value === this.config.houdiniDirective
71952
+ let includeFragments = this.config.defaultFragmentMasking === "disable";
71953
+ const maskEnableDirective = selection2.directives?.find(
71954
+ ({ name: name2 }) => name2.value === this.config.maskEnableDirective
71895
71955
  );
71896
- const maskArgument = houdiniDirective?.arguments?.find(
71897
- ({ name: name2 }) => name2.value === "mask"
71956
+ if (maskEnableDirective) {
71957
+ includeFragments = false;
71958
+ }
71959
+ const maskDisableDirective = selection2.directives?.find(
71960
+ ({ name: name2 }) => name2.value === this.config.maskDisableDirective
71898
71961
  );
71899
- let includeFragments = this.config.disableMasking;
71900
- if (maskArgument?.value.kind === "BooleanValue") {
71901
- includeFragments = !maskArgument.value.value;
71962
+ if (maskDisableDirective) {
71963
+ includeFragments = true;
71902
71964
  }
71903
- if (!includeFragments) {
71965
+ if (this.ignoreMaskDisable) {
71966
+ includeFragments = true;
71967
+ }
71968
+ if (!includeFragments || !this.applyFragments) {
71904
71969
  return;
71905
71970
  }
71906
71971
  const definition = this.fragmentDefinitions[selection2.name.value];
@@ -71910,9 +71975,20 @@ var FieldCollection = class {
71910
71975
  message: "Could not find referenced fragment definition: " + selection2.name.value
71911
71976
  });
71912
71977
  }
71913
- for (const subselect of definition.selectionSet.selections) {
71914
- this.add(subselect);
71915
- }
71978
+ this.add({
71979
+ kind: "InlineFragment",
71980
+ typeCondition: {
71981
+ kind: "NamedType",
71982
+ name: {
71983
+ kind: "Name",
71984
+ value: definition.typeCondition.name.value
71985
+ }
71986
+ },
71987
+ selectionSet: {
71988
+ kind: "SelectionSet",
71989
+ selections: [...definition.selectionSet.selections]
71990
+ }
71991
+ });
71916
71992
  }
71917
71993
  }
71918
71994
  toSelectionSet() {
@@ -71928,12 +72004,30 @@ var FieldCollection = class {
71928
72004
  })
71929
72005
  ).concat(Object.values(this.fragmentSpreads));
71930
72006
  }
72007
+ walkInlineFragment(selection2) {
72008
+ const key = selection2.typeCondition.name.value;
72009
+ if (!this.inlineFragments[key]) {
72010
+ this.inlineFragments[key] = {
72011
+ astNode: selection2,
72012
+ selection: this.empty()
72013
+ };
72014
+ }
72015
+ for (const subselect of selection2.selectionSet.selections || []) {
72016
+ if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
72017
+ this.inlineFragments[key].selection.add(subselect);
72018
+ continue;
72019
+ }
72020
+ this.walkInlineFragment(subselect);
72021
+ }
72022
+ }
71931
72023
  empty() {
71932
72024
  return new FieldCollection({
71933
72025
  config: this.config,
71934
72026
  fragmentDefinitions: this.fragmentDefinitions,
71935
72027
  selections: [],
71936
- filepath: this.filepath
72028
+ filepath: this.filepath,
72029
+ applyFragments: this.applyFragments,
72030
+ ignoreMaskDisable: this.ignoreMaskDisable
71937
72031
  });
71938
72032
  }
71939
72033
  };
@@ -72288,11 +72382,6 @@ function operationObject({
72288
72382
  const when = internalDirectives.find(({ name: name2 }) => name2.value === "when");
72289
72383
  const when_not = internalDirectives.find(({ name: name2 }) => name2.value === "when_not");
72290
72384
  let parentIDArg = parent?.arguments?.find((argument) => argument.name.value === "value");
72291
- if (!parentIDArg) {
72292
- parentIDArg = (append || prepend)?.arguments?.find(
72293
- ({ name: name2 }) => name2.value === config2.listDirectiveParentIDArg
72294
- );
72295
- }
72296
72385
  if (parentIDArg) {
72297
72386
  if (parentIDArg.value.kind === "StringValue") {
72298
72387
  parentID = parentIDArg.value.value;
@@ -73320,6 +73409,8 @@ function selection({
73320
73409
  markEdges
73321
73410
  }) {
73322
73411
  let object = {};
73412
+ const typeMap = {};
73413
+ const abstractTypes = [];
73323
73414
  for (const field of selections) {
73324
73415
  if (field.kind === "FragmentSpread" && includeFragments) {
73325
73416
  const fragmentDefinition = document.document.definitions.find(
@@ -73346,20 +73437,68 @@ function selection({
73346
73437
  })
73347
73438
  );
73348
73439
  } else if (field.kind === "InlineFragment") {
73349
- object = deepMerge(
73350
- filepath,
73351
- object,
73352
- selection({
73353
- config: config2,
73440
+ if (!field.typeCondition || field.typeCondition.name.value === rootType) {
73441
+ object.fields = deepMerge(
73354
73442
  filepath,
73355
- rootType: field.typeCondition?.name.value || rootType,
73356
- operations,
73357
- selections: field.selectionSet.selections,
73358
- path: path2,
73359
- includeFragments,
73360
- document
73361
- })
73362
- );
73443
+ object.fields || {},
73444
+ selection({
73445
+ config: config2,
73446
+ filepath,
73447
+ rootType: field.typeCondition?.name.value || rootType,
73448
+ operations,
73449
+ selections: field.selectionSet.selections,
73450
+ path: path2,
73451
+ includeFragments,
73452
+ document
73453
+ }).fields || {}
73454
+ );
73455
+ } else {
73456
+ if (!object.abstractFields) {
73457
+ object.abstractFields = {
73458
+ fields: {},
73459
+ typeMap: {}
73460
+ };
73461
+ }
73462
+ const parentType = config2.schema.getType(rootType);
73463
+ const typeConditionName = field.typeCondition.name.value;
73464
+ const typeCondition = config2.schema.getType(typeConditionName);
73465
+ const possibleTypes = [];
73466
+ if (!graphql12.isAbstractType(typeCondition)) {
73467
+ } else if (graphql12.isAbstractType(parentType)) {
73468
+ const possibleParentTypes = config2.schema.getPossibleTypes(parentType).map((type) => type.name);
73469
+ for (const possible of config2.schema.getPossibleTypes(typeCondition)) {
73470
+ if (possibleParentTypes.includes(possible.name)) {
73471
+ possibleTypes.push(possible.name);
73472
+ }
73473
+ }
73474
+ } else {
73475
+ possibleTypes.push(rootType);
73476
+ }
73477
+ if (possibleTypes.length > 0) {
73478
+ for (const type of possibleTypes) {
73479
+ const existing = typeMap[type];
73480
+ if (!existing || !existing.includes(type)) {
73481
+ typeMap[type] = [typeConditionName].concat(existing || []);
73482
+ }
73483
+ if (!abstractTypes.includes(typeConditionName)) {
73484
+ abstractTypes.push(typeConditionName);
73485
+ }
73486
+ }
73487
+ }
73488
+ object.abstractFields.fields = {
73489
+ ...object.abstractFields.fields,
73490
+ [field.typeCondition.name.value]: selection({
73491
+ config: config2,
73492
+ filepath,
73493
+ rootType: field.typeCondition?.name.value || rootType,
73494
+ operations,
73495
+ selections: field.selectionSet.selections,
73496
+ path: path2,
73497
+ includeFragments,
73498
+ document
73499
+ }).fields
73500
+ };
73501
+ }
73363
73502
  } else if (field.kind === "Field") {
73364
73503
  const type = config2.schema.getType(rootType);
73365
73504
  if (!type) {
@@ -73417,7 +73556,7 @@ function selection({
73417
73556
  }
73418
73557
  if (field.selectionSet) {
73419
73558
  const edgesMark = paginated && document.refetch?.method === "cursor" ? document.refetch.update : markEdges;
73420
- fieldObj.fields = selection({
73559
+ fieldObj.selection = selection({
73421
73560
  config: config2,
73422
73561
  filepath,
73423
73562
  rootType: typeName,
@@ -73441,11 +73580,49 @@ function selection({
73441
73580
  if (graphql12.isInterfaceType(fieldType) || graphql12.isUnionType(fieldType)) {
73442
73581
  fieldObj.abstract = true;
73443
73582
  }
73444
- object[attributeName] = deepMerge(
73445
- filepath,
73446
- fieldObj,
73447
- object[attributeName] || {}
73448
- );
73583
+ object.fields = {
73584
+ ...object.fields,
73585
+ [attributeName]: fieldObj
73586
+ };
73587
+ }
73588
+ }
73589
+ if (Object.keys(object.fields || {}).length > 0 && object.abstractFields && Object.keys(object.abstractFields.fields).length > 0) {
73590
+ for (const [typeName, possibles] of Object.entries(typeMap)) {
73591
+ let overlap = false;
73592
+ for (const possible of possibles) {
73593
+ if (object.abstractFields.fields[typeName]) {
73594
+ object.abstractFields.fields[typeName] = deepMerge(
73595
+ filepath,
73596
+ object.abstractFields.fields[typeName] || {},
73597
+ object.abstractFields.fields[possible]
73598
+ );
73599
+ overlap = true;
73600
+ }
73601
+ }
73602
+ if (overlap) {
73603
+ delete typeMap[typeName];
73604
+ }
73605
+ }
73606
+ for (const [type, options] of Object.entries(typeMap)) {
73607
+ if (options.length > 1) {
73608
+ object.abstractFields.fields[type] = deepMerge(
73609
+ filepath,
73610
+ ...options.map((opt) => object.abstractFields.fields[opt] || {})
73611
+ );
73612
+ delete typeMap[type];
73613
+ }
73614
+ }
73615
+ for (const [type, sel] of Object.entries(object.abstractFields?.fields || {})) {
73616
+ object.abstractFields.fields[type] = deepMerge(filepath, sel || {}, object.fields);
73617
+ }
73618
+ for (const [type, options] of Object.entries(typeMap)) {
73619
+ object.abstractFields.typeMap[type] = options[0];
73620
+ }
73621
+ const usedTypes = Object.values(object.abstractFields.typeMap);
73622
+ for (const type of abstractTypes) {
73623
+ if (!usedTypes.includes(type)) {
73624
+ delete object.abstractFields.fields[type];
73625
+ }
73449
73626
  }
73450
73627
  }
73451
73628
  return object;
@@ -73580,6 +73757,22 @@ function artifactGenerator(stats) {
73580
73757
  selectionSet = matchingFragment.selectionSet;
73581
73758
  }
73582
73759
  const inputs = operations[0]?.variableDefinitions;
73760
+ const mergedSelection = flattenSelections({
73761
+ config: config2,
73762
+ filepath: doc.filename,
73763
+ selections: selectionSet.selections,
73764
+ fragmentDefinitions: doc.document.definitions.filter(
73765
+ (definition) => definition.kind === "FragmentDefinition"
73766
+ ).reduce(
73767
+ (prev, definition) => ({
73768
+ ...prev,
73769
+ [definition.name.value]: definition
73770
+ }),
73771
+ {}
73772
+ ),
73773
+ ignoreMaskDisable: docKind === "HoudiniQuery",
73774
+ applyFragments: docKind !== "HoudiniFragment"
73775
+ });
73583
73776
  const artifact = {
73584
73777
  name: name2,
73585
73778
  kind: docKind,
@@ -73591,7 +73784,7 @@ function artifactGenerator(stats) {
73591
73784
  config: config2,
73592
73785
  filepath: doc.filename,
73593
73786
  rootType,
73594
- selections: selectionSet.selections,
73787
+ selections: mergedSelection,
73595
73788
  operations: operationsByPath(
73596
73789
  config2,
73597
73790
  doc.filename,
@@ -73887,6 +74080,17 @@ function inlineType({
73887
74080
  continue;
73888
74081
  }
73889
74082
  const possibleParents = config2.schema.getPossibleTypes(type).map((t2) => t2.name);
74083
+ const freeSelections = [];
74084
+ const typeSpecificSelections = {};
74085
+ for (const node of selection2.selectionSet.selections) {
74086
+ if (node.kind !== "InlineFragment") {
74087
+ freeSelections.push(node);
74088
+ } else if (node.typeCondition) {
74089
+ typeSpecificSelections[node.typeCondition.name.value] = node.selectionSet.selections;
74090
+ } else {
74091
+ freeSelections.push(...node.selectionSet.selections);
74092
+ }
74093
+ }
73890
74094
  for (const possibleType of config2.schema.getPossibleTypes(fragmentType)) {
73891
74095
  if (!possibleParents.includes(possibleType.name)) {
73892
74096
  continue;
@@ -73894,7 +74098,12 @@ function inlineType({
73894
74098
  if (!inlineFragments[possibleType.name]) {
73895
74099
  inlineFragments[possibleType.name] = [];
73896
74100
  }
73897
- inlineFragments[possibleType.name].push(...selection2.selectionSet.selections);
74101
+ inlineFragments[possibleType.name].push(...freeSelections);
74102
+ if (typeSpecificSelections[possibleType.name]) {
74103
+ inlineFragments[possibleType.name].push(
74104
+ ...typeSpecificSelections[possibleType.name]
74105
+ );
74106
+ }
73898
74107
  }
73899
74108
  } else if (selection2.kind === "InlineFragment" && !selection2.typeCondition) {
73900
74109
  selectedFields.push(...selection2.selectionSet.selections);
@@ -73906,12 +74115,7 @@ function inlineType({
73906
74115
  ...(selectedFields || []).filter(
73907
74116
  (field) => field.kind === "Field"
73908
74117
  ).map((selection2) => {
73909
- const { type: type2, field } = selectionTypeInfo(
73910
- config2.schema,
73911
- filepath,
73912
- rootObj,
73913
- selection2
73914
- );
74118
+ const { field } = selectionTypeInfo(config2.schema, filepath, rootObj, selection2);
73915
74119
  const attributeName = selection2.alias?.value || selection2.name.value;
73916
74120
  let attributeType = inlineType({
73917
74121
  config: config2,
@@ -74110,7 +74314,8 @@ async function typescriptGenerator(config2, docs) {
74110
74314
  config: config2,
74111
74315
  filepath: filename,
74112
74316
  selections: definition.selectionSet.selections,
74113
- fragmentDefinitions
74317
+ fragmentDefinitions,
74318
+ applyFragments: definition.kind === "OperationDefinition"
74114
74319
  });
74115
74320
  if (definition?.kind === "OperationDefinition") {
74116
74321
  await generateOperationTypeDefs(
@@ -74623,14 +74828,12 @@ directive @${config2.paginateDirective}(${config2.paginateNameArg}: String) on F
74623
74828
  """
74624
74829
  @${config2.listPrependDirective} is used to tell the runtime to add the result to the end of the list
74625
74830
  """
74626
- directive @${config2.listPrependDirective}(
74627
- ${config2.listDirectiveParentIDArg}: ID
74628
- ) on FRAGMENT_SPREAD
74831
+ directive @${config2.listPrependDirective} on FRAGMENT_SPREAD
74629
74832
 
74630
74833
  """
74631
74834
  @${config2.listAppendDirective} is used to tell the runtime to add the result to the start of the list
74632
74835
  """
74633
- directive @${config2.listAppendDirective}(${config2.listDirectiveParentIDArg}: ID) on FRAGMENT_SPREAD
74836
+ directive @${config2.listAppendDirective} on FRAGMENT_SPREAD
74634
74837
 
74635
74838
  """
74636
74839
  @${config2.listAllListsDirective} is used to tell the runtime to add the result to all list
@@ -74664,18 +74867,19 @@ directive @${config2.argumentsDirective} on FRAGMENT_DEFINITION
74664
74867
  directive @${config2.cacheDirective}(${config2.cachePolicyArg}: CachePolicy, ${config2.cachePartialArg}: Boolean) on QUERY
74665
74868
 
74666
74869
  """
74667
- @${config2.houdiniDirective} is used to configure houdini's internal behavior
74870
+ @${config2.manualLoadDirective} is used to disable automatic fetch (no load, no auto fetch in component), you will have to do it manually.
74871
+ """
74872
+ directive @${config2.manualLoadDirective} on QUERY
74873
+
74874
+ """
74875
+ @${config2.maskEnableDirective} to enable masking on fragment (overwriting the global conf)
74876
+ """
74877
+ directive @${config2.maskEnableDirective} on FRAGMENT_SPREAD
74878
+
74879
+ """
74880
+ @${config2.maskDisableDirective} to disable masking on fragment (overwriting the global conf)
74668
74881
  """
74669
- directive @${config2.houdiniDirective}(
74670
- """
74671
- Opt-in to an automatic load function (only valid when used at queries)
74672
- """
74673
- load: Boolean! = true
74674
- """
74675
- Mask fragment fields (only valid when used at a fragment spread)
74676
- """
74677
- mask: Boolean! = ${config2.disableMasking ? "false" : "true"}
74678
- ) on QUERY | FRAGMENT_SPREAD
74882
+ directive @${config2.maskDisableDirective} on FRAGMENT_SPREAD
74679
74883
  `;
74680
74884
  let currentSchema = graphql21.printSchema(config2.schema);
74681
74885
  if (!currentSchema.includes(`directive @${config2.listDirective}`)) {
@@ -75168,26 +75372,42 @@ async function typeCheck(config2, docs) {
75168
75372
  ),
75169
75373
  targetField.selectionSet
75170
75374
  );
75171
- const missingIDFields = config2.keyFieldsForType(type.name).filter((fieldName) => !type.getFields()[fieldName]);
75172
- if (missingIDFields.length > 0) {
75173
- if (error) {
75174
- errors.push(
75175
- new HoudiniError({
75176
- filepath: filename,
75177
- message: error
75178
- })
75179
- );
75180
- } else {
75181
- errors.push(
75182
- new HoudiniError({
75183
- filepath: filename,
75184
- message: `@${config2.listDirective} can only be applied to types with the necessary id fields: ${missingIDFields.join(
75185
- ", "
75186
- )}.`
75187
- })
75188
- );
75375
+ let targetTypes = [type];
75376
+ if (graphql25.isUnionType(type)) {
75377
+ targetTypes = config2.schema.getPossibleTypes(type);
75378
+ } else if (graphql25.isInterfaceType(type)) {
75379
+ try {
75380
+ for (const key of config2.keyFieldsForType(type.name)) {
75381
+ if (!type.getFields()[key]) {
75382
+ throw new Error("continue");
75383
+ }
75384
+ }
75385
+ } catch {
75386
+ targetTypes = config2.schema.getPossibleTypes(type);
75387
+ }
75388
+ }
75389
+ for (const targetType of targetTypes) {
75390
+ const missingIDFields = config2.keyFieldsForType(targetType.name).filter((fieldName) => !targetType.getFields()[fieldName]);
75391
+ if (missingIDFields.length > 0) {
75392
+ if (error) {
75393
+ errors.push(
75394
+ new HoudiniError({
75395
+ filepath: filename,
75396
+ message: error
75397
+ })
75398
+ );
75399
+ } else {
75400
+ errors.push(
75401
+ new HoudiniError({
75402
+ filepath: filename,
75403
+ message: `@${config2.listDirective} can only be applied to types with the necessary id fields: ${missingIDFields.join(
75404
+ ", "
75405
+ )}.`
75406
+ })
75407
+ );
75408
+ }
75409
+ return;
75189
75410
  }
75190
- return;
75191
75411
  }
75192
75412
  lists.push(listName);
75193
75413
  listTypes.push(type.name);
@@ -75217,6 +75437,7 @@ async function typeCheck(config2, docs) {
75217
75437
  fragments
75218
75438
  }),
75219
75439
  checkMutationOperation(config2),
75440
+ checkMaskDirective(config2),
75220
75441
  nodeDirectives(config2, [config2.paginateDirective]),
75221
75442
  knownArguments(config2),
75222
75443
  validateFragmentArguments(config2, filepath, fragments),
@@ -75281,10 +75502,14 @@ var validateLists = ({
75281
75502
  ]);
75282
75503
  if (directive) {
75283
75504
  let parentArg = directive.arguments?.find(
75284
- (arg) => arg.name.value === config2.listDirectiveParentIDArg
75505
+ (arg) => arg.name.value === config2.deprecatedlistDirectiveParentIDArg
75285
75506
  );
75286
75507
  if (parentArg) {
75287
- parentIdFound = true;
75508
+ ctx.reportError(
75509
+ new graphql25.GraphQLError(
75510
+ `@${config2.deprecatedlistDirectiveParentIDArg} should be defined only in it's own directive now`
75511
+ )
75512
+ );
75288
75513
  }
75289
75514
  }
75290
75515
  if (parentIdFound) {
@@ -75680,6 +75905,28 @@ function checkMutationOperation(config2) {
75680
75905
  };
75681
75906
  };
75682
75907
  }
75908
+ function checkMaskDirective(config2) {
75909
+ return function(ctx) {
75910
+ return {
75911
+ FragmentSpread(node, _, __, ___, ancestors) {
75912
+ const maskEnableDirective = node.directives?.find(
75913
+ (c) => c.name.value === config2.maskEnableDirective
75914
+ );
75915
+ const maskDisableDirective = node.directives?.find(
75916
+ (c) => c.name.value === config2.maskDisableDirective
75917
+ );
75918
+ if (maskEnableDirective && maskDisableDirective) {
75919
+ ctx.reportError(
75920
+ new graphql25.GraphQLError(
75921
+ `You can't apply both @${config2.maskEnableDirective} and @${config2.maskDisableDirective} at the same time`
75922
+ )
75923
+ );
75924
+ return;
75925
+ }
75926
+ }
75927
+ };
75928
+ };
75929
+ }
75683
75930
  function getAndVerifyNodeInterface(config2) {
75684
75931
  const { schema } = config2;
75685
75932
  const nodeInterface = schema.getType("Node");
@@ -75977,12 +76224,7 @@ async function collectDocuments(config2) {
75977
76224
  }
75978
76225
  async function processJSFile(config2, contents) {
75979
76226
  const documents = [];
75980
- try {
75981
- var program3 = (await parseJS(contents)).script;
75982
- } catch (e2) {
75983
- console.log(contents);
75984
- throw e2;
75985
- }
76227
+ var program3 = (await parseJS(contents)).script;
75986
76228
  await find_graphql(config2, program3, {
75987
76229
  tag({ tagContent }) {
75988
76230
  documents.push(tagContent);
@@ -76282,7 +76524,6 @@ async function init(_path, args) {
76282
76524
  const sourceDir = path_exports.join(targetPath, "src");
76283
76525
  const configPath = path_exports.join(targetPath, "houdini.config.js");
76284
76526
  const houdiniClientPath = typescript ? path_exports.join(sourceDir, "client.ts") : path_exports.join(sourceDir, "client.js");
76285
- const houdiniClientImport = "./src/client";
76286
76527
  console.log("\u{1F6A7} Generating project files...");
76287
76528
  await updatePackageJSON(targetPath);
76288
76529
  if (is_remote_endpoint) {
@@ -76292,8 +76533,7 @@ async function init(_path, args) {
76292
76533
  configPath,
76293
76534
  schemaPath,
76294
76535
  module,
76295
- url: is_remote_endpoint ? url : null,
76296
- houdiniClientImport
76536
+ url: is_remote_endpoint ? url : null
76297
76537
  });
76298
76538
  await fs_exports.writeFile(houdiniClientPath, networkFile(url, typescript));
76299
76539
  await graphqlRCFile(targetPath);
@@ -76350,8 +76590,7 @@ var writeConfigFile = async ({
76350
76590
  configPath,
76351
76591
  schemaPath,
76352
76592
  module,
76353
- url,
76354
- houdiniClientImport
76593
+ url
76355
76594
  }) => {
76356
76595
  const config2 = {};
76357
76596
  if (url !== null) {
@@ -76364,9 +76603,7 @@ var writeConfigFile = async ({
76364
76603
  config2.module = module;
76365
76604
  }
76366
76605
  config2.plugins = {
76367
- "houdini-svelte": {
76368
- client: houdiniClientImport
76369
- }
76606
+ "houdini-svelte": {}
76370
76607
  };
76371
76608
  const configObj = JSON.stringify(config2, null, 4);
76372
76609
  const content_base = `/// <references types="houdini-svelte">
@@ -76540,8 +76777,8 @@ async function updatePackageJSON(targetPath) {
76540
76777
  }
76541
76778
  packageJSON.devDependencies = {
76542
76779
  ...packageJSON.devDependencies,
76543
- houdini: "^0.17.13",
76544
- "houdini-svelte": "^0.17.13",
76780
+ houdini: "^0.18.0",
76781
+ "houdini-svelte": "^0.18.0",
76545
76782
  graphql: "^15.8.0"
76546
76783
  };
76547
76784
  await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));