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
@@ -3350,7 +3350,7 @@ var require_definition = __commonJS({
3350
3350
  exports.assertObjectType = assertObjectType;
3351
3351
  exports.isInterfaceType = isInterfaceType6;
3352
3352
  exports.assertInterfaceType = assertInterfaceType;
3353
- exports.isUnionType = isUnionType6;
3353
+ exports.isUnionType = isUnionType7;
3354
3354
  exports.assertUnionType = assertUnionType;
3355
3355
  exports.isEnumType = isEnumType4;
3356
3356
  exports.assertEnumType = assertEnumType;
@@ -3368,7 +3368,7 @@ var require_definition = __commonJS({
3368
3368
  exports.assertLeafType = assertLeafType;
3369
3369
  exports.isCompositeType = isCompositeType;
3370
3370
  exports.assertCompositeType = assertCompositeType;
3371
- exports.isAbstractType = isAbstractType;
3371
+ exports.isAbstractType = isAbstractType2;
3372
3372
  exports.assertAbstractType = assertAbstractType;
3373
3373
  exports.GraphQLList = GraphQLList2;
3374
3374
  exports.GraphQLNonNull = GraphQLNonNull2;
@@ -3423,7 +3423,7 @@ var require_definition = __commonJS({
3423
3423
  return Constructor;
3424
3424
  }
3425
3425
  function isType(type) {
3426
- return isScalarType6(type) || isObjectType2(type) || isInterfaceType6(type) || isUnionType6(type) || isEnumType4(type) || isInputObjectType(type) || isListType3(type) || isNonNullType6(type);
3426
+ return isScalarType6(type) || isObjectType2(type) || isInterfaceType6(type) || isUnionType7(type) || isEnumType4(type) || isInputObjectType(type) || isListType3(type) || isNonNullType6(type);
3427
3427
  }
3428
3428
  function assertType(type) {
3429
3429
  if (!isType(type)) {
@@ -3458,11 +3458,11 @@ var require_definition = __commonJS({
3458
3458
  }
3459
3459
  return type;
3460
3460
  }
3461
- function isUnionType6(type) {
3461
+ function isUnionType7(type) {
3462
3462
  return (0, _instanceOf.default)(type, GraphQLUnionType);
3463
3463
  }
3464
3464
  function assertUnionType(type) {
3465
- if (!isUnionType6(type)) {
3465
+ if (!isUnionType7(type)) {
3466
3466
  throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Union type."));
3467
3467
  }
3468
3468
  return type;
@@ -3513,7 +3513,7 @@ var require_definition = __commonJS({
3513
3513
  return type;
3514
3514
  }
3515
3515
  function isOutputType(type) {
3516
- return isScalarType6(type) || isObjectType2(type) || isInterfaceType6(type) || isUnionType6(type) || isEnumType4(type) || isWrappingType(type) && isOutputType(type.ofType);
3516
+ return isScalarType6(type) || isObjectType2(type) || isInterfaceType6(type) || isUnionType7(type) || isEnumType4(type) || isWrappingType(type) && isOutputType(type.ofType);
3517
3517
  }
3518
3518
  function assertOutputType(type) {
3519
3519
  if (!isOutputType(type)) {
@@ -3531,7 +3531,7 @@ var require_definition = __commonJS({
3531
3531
  return type;
3532
3532
  }
3533
3533
  function isCompositeType(type) {
3534
- return isObjectType2(type) || isInterfaceType6(type) || isUnionType6(type);
3534
+ return isObjectType2(type) || isInterfaceType6(type) || isUnionType7(type);
3535
3535
  }
3536
3536
  function assertCompositeType(type) {
3537
3537
  if (!isCompositeType(type)) {
@@ -3539,11 +3539,11 @@ var require_definition = __commonJS({
3539
3539
  }
3540
3540
  return type;
3541
3541
  }
3542
- function isAbstractType(type) {
3543
- return isInterfaceType6(type) || isUnionType6(type);
3542
+ function isAbstractType2(type) {
3543
+ return isInterfaceType6(type) || isUnionType7(type);
3544
3544
  }
3545
3545
  function assertAbstractType(type) {
3546
- if (!isAbstractType(type)) {
3546
+ if (!isAbstractType2(type)) {
3547
3547
  throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL abstract type."));
3548
3548
  }
3549
3549
  return type;
@@ -3610,7 +3610,7 @@ var require_definition = __commonJS({
3610
3610
  }
3611
3611
  }
3612
3612
  function isNamedType(type) {
3613
- return isScalarType6(type) || isObjectType2(type) || isInterfaceType6(type) || isUnionType6(type) || isEnumType4(type) || isInputObjectType(type);
3613
+ return isScalarType6(type) || isObjectType2(type) || isInterfaceType6(type) || isUnionType7(type) || isEnumType4(type) || isInputObjectType(type);
3614
3614
  }
3615
3615
  function assertNamedType(type) {
3616
3616
  if (!isNamedType(type)) {
@@ -53463,6 +53463,20 @@ function deepEquals(objA, objB, map = /* @__PURE__ */ new WeakMap()) {
53463
53463
  return true;
53464
53464
  }
53465
53465
 
53466
+ // src/runtime/lib/selection.ts
53467
+ function getFieldsForType(selection2, __typename) {
53468
+ let targetSelection = selection2.fields || {};
53469
+ if (selection2.abstractFields && __typename) {
53470
+ const mappedType = selection2.abstractFields.typeMap[__typename];
53471
+ if (mappedType) {
53472
+ targetSelection = selection2.abstractFields.fields[mappedType];
53473
+ } else if (selection2.abstractFields.fields[__typename]) {
53474
+ targetSelection = selection2.abstractFields.fields[__typename];
53475
+ }
53476
+ }
53477
+ return targetSelection;
53478
+ }
53479
+
53466
53480
  // src/runtime/cache/gc.ts
53467
53481
  var GarbageCollector = class {
53468
53482
  cache;
@@ -53685,23 +53699,32 @@ var List = class {
53685
53699
  let insertData = data;
53686
53700
  if (this.connection) {
53687
53701
  insertSelection = {
53688
- newEntry: {
53689
- keyRaw: this.key,
53690
- type: "Connection",
53691
- fields: {
53692
- edges: {
53693
- keyRaw: "edges",
53694
- type: "ConnectionEdge",
53695
- update: where === "first" ? "prepend" : "append",
53702
+ fields: {
53703
+ newEntry: {
53704
+ keyRaw: this.key,
53705
+ type: "Connection",
53706
+ selection: {
53696
53707
  fields: {
53697
- node: {
53698
- type: listType,
53699
- keyRaw: "node",
53700
- fields: {
53701
- ...selection2,
53702
- __typename: {
53703
- keyRaw: "__typename",
53704
- type: "String"
53708
+ edges: {
53709
+ keyRaw: "edges",
53710
+ type: "ConnectionEdge",
53711
+ update: where === "first" ? "prepend" : "append",
53712
+ selection: {
53713
+ fields: {
53714
+ node: {
53715
+ type: listType,
53716
+ keyRaw: "node",
53717
+ selection: {
53718
+ ...selection2,
53719
+ fields: {
53720
+ ...selection2.fields,
53721
+ __typename: {
53722
+ keyRaw: "__typename",
53723
+ type: "String"
53724
+ }
53725
+ }
53726
+ }
53727
+ }
53705
53728
  }
53706
53729
  }
53707
53730
  }
@@ -53717,15 +53740,20 @@ var List = class {
53717
53740
  };
53718
53741
  } else {
53719
53742
  insertSelection = {
53720
- newEntries: {
53721
- keyRaw: this.key,
53722
- type: listType,
53723
- update: where === "first" ? "prepend" : "append",
53724
- fields: {
53725
- ...selection2,
53726
- __typename: {
53727
- keyRaw: "__typename",
53728
- type: "String"
53743
+ fields: {
53744
+ newEntries: {
53745
+ keyRaw: this.key,
53746
+ type: listType,
53747
+ update: where === "first" ? "prepend" : "append",
53748
+ selection: {
53749
+ ...selection2,
53750
+ fields: {
53751
+ ...selection2.fields,
53752
+ __typename: {
53753
+ keyRaw: "__typename",
53754
+ type: "String"
53755
+ }
53756
+ }
53729
53757
  }
53730
53758
  }
53731
53759
  }
@@ -53785,7 +53813,7 @@ var List = class {
53785
53813
  const subscribers = this.cache._internal_unstable.subscriptions.get(this.recordID, this.key);
53786
53814
  this.cache._internal_unstable.subscriptions.remove(
53787
53815
  targetID,
53788
- this.connection ? this.selection.edges.fields : this.selection,
53816
+ this.connection ? this.selection.fields.edges.selection : this.selection,
53789
53817
  subscribers,
53790
53818
  variables
53791
53819
  );
@@ -54274,18 +54302,20 @@ var InMemorySubscriptions = class {
54274
54302
  variables,
54275
54303
  parentType
54276
54304
  }) {
54277
- for (const fieldSelection of Object.values(selection2)) {
54278
- const { keyRaw, fields, type } = fieldSelection;
54305
+ const __typename = this.cache._internal_unstable.storage.get(parent, "__typename").value;
54306
+ let targetSelection = getFieldsForType(selection2, __typename);
54307
+ for (const fieldSelection of Object.values(targetSelection || {})) {
54308
+ const { keyRaw, selection: innerSelection, type } = fieldSelection;
54279
54309
  const key = evaluateKey(keyRaw, variables);
54280
54310
  this.addFieldSubscription({
54281
54311
  id: parent,
54282
54312
  key,
54283
- selection: fieldSelection,
54313
+ field: fieldSelection,
54284
54314
  spec,
54285
54315
  parentType: parentType || spec.rootType,
54286
54316
  variables
54287
54317
  });
54288
- if (fields) {
54318
+ if (innerSelection) {
54289
54319
  const { value: linkedRecord } = this.cache._internal_unstable.storage.get(
54290
54320
  parent,
54291
54321
  key
@@ -54298,7 +54328,7 @@ var InMemorySubscriptions = class {
54298
54328
  this.add({
54299
54329
  parent: child,
54300
54330
  spec,
54301
- selection: fields,
54331
+ selection: innerSelection,
54302
54332
  variables,
54303
54333
  parentType: type
54304
54334
  });
@@ -54309,7 +54339,7 @@ var InMemorySubscriptions = class {
54309
54339
  addFieldSubscription({
54310
54340
  id,
54311
54341
  key,
54312
- selection: selection2,
54342
+ field,
54313
54343
  spec,
54314
54344
  parentType,
54315
54345
  variables
@@ -54336,8 +54366,8 @@ var InMemorySubscriptions = class {
54336
54366
  const counts = this.referenceCounts[id][key];
54337
54367
  counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
54338
54368
  this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
54339
- const { fields, list, filters } = selection2;
54340
- if (fields && list) {
54369
+ const { selection: selection2, list, filters } = field;
54370
+ if (selection2 && list) {
54341
54371
  this.cache._internal_unstable.lists.add({
54342
54372
  name: list.name,
54343
54373
  connection: list.connection,
@@ -54345,7 +54375,7 @@ var InMemorySubscriptions = class {
54345
54375
  recordType: this.cache._internal_unstable.storage.get(id, "__typename")?.value || parentType,
54346
54376
  listType: list.type,
54347
54377
  key,
54348
- selection: fields,
54378
+ selection: selection2,
54349
54379
  filters: Object.entries(filters || {}).reduce((acc, [key2, { kind, value }]) => {
54350
54380
  return {
54351
54381
  ...acc,
@@ -54362,20 +54392,21 @@ var InMemorySubscriptions = class {
54362
54392
  subscribers,
54363
54393
  parentType
54364
54394
  }) {
54365
- for (const fieldSelection of Object.values(selection2)) {
54366
- const { type: linkedType, keyRaw, fields } = fieldSelection;
54395
+ let targetSelection = getFieldsForType(selection2, parentType);
54396
+ for (const fieldSelection of Object.values(targetSelection)) {
54397
+ const { type: linkedType, keyRaw, selection: innerSelection } = fieldSelection;
54367
54398
  const key = evaluateKey(keyRaw, variables);
54368
54399
  for (const spec of subscribers) {
54369
54400
  this.addFieldSubscription({
54370
54401
  id: parent,
54371
54402
  key,
54372
- selection: fieldSelection,
54403
+ field: fieldSelection,
54373
54404
  spec,
54374
54405
  parentType,
54375
54406
  variables
54376
54407
  });
54377
54408
  }
54378
- if (fields) {
54409
+ if (innerSelection) {
54379
54410
  const { value: link } = this.cache._internal_unstable.storage.get(parent, key);
54380
54411
  const children = !Array.isArray(link) ? [link] : flattenList(link);
54381
54412
  for (const linkedRecord of children) {
@@ -54384,7 +54415,7 @@ var InMemorySubscriptions = class {
54384
54415
  }
54385
54416
  this.addMany({
54386
54417
  parent: linkedRecord,
54387
- selection: fields,
54418
+ selection: innerSelection,
54388
54419
  variables,
54389
54420
  subscribers,
54390
54421
  parentType: linkedType
@@ -54396,22 +54427,20 @@ var InMemorySubscriptions = class {
54396
54427
  get(id, field) {
54397
54428
  return this.subscribers[id]?.[field] || [];
54398
54429
  }
54399
- remove(id, fields, targets, variables, visited = []) {
54430
+ remove(id, selection2, targets, variables, visited = []) {
54400
54431
  visited.push(id);
54401
54432
  const linkedIDs = [];
54402
- for (const selection2 of Object.values(fields)) {
54403
- const key = evaluateKey(selection2.keyRaw, variables);
54433
+ for (const fieldSelection of Object.values(selection2.fields || {})) {
54434
+ const key = evaluateKey(fieldSelection.keyRaw, variables);
54404
54435
  this.removeSubscribers(id, key, targets);
54405
- if (!selection2.fields) {
54436
+ if (!fieldSelection.selection?.fields) {
54406
54437
  continue;
54407
54438
  }
54408
- if (selection2.list) {
54409
- }
54410
54439
  const { value: previousValue } = this.cache._internal_unstable.storage.get(id, key);
54411
54440
  const links = !Array.isArray(previousValue) ? [previousValue] : flattenList(previousValue);
54412
54441
  for (const link of links) {
54413
54442
  if (link !== null) {
54414
- linkedIDs.push([link, selection2.fields]);
54443
+ linkedIDs.push([link, fieldSelection.selection || {}]);
54415
54444
  }
54416
54445
  }
54417
54446
  }
@@ -54589,8 +54618,9 @@ var CacheInternal = class {
54589
54618
  if (this._disabled) {
54590
54619
  return [];
54591
54620
  }
54621
+ let targetSelection = getFieldsForType(selection2, data["__typename"]);
54592
54622
  for (const [field, value] of Object.entries(data)) {
54593
- if (!selection2 || !selection2[field]) {
54623
+ if (!selection2 || !targetSelection[field]) {
54594
54624
  throw new Error(
54595
54625
  "Could not find field listing in selection for " + field + " @ " + JSON.stringify(selection2)
54596
54626
  );
@@ -54598,11 +54628,11 @@ var CacheInternal = class {
54598
54628
  let {
54599
54629
  type: linkedType,
54600
54630
  keyRaw,
54601
- fields,
54631
+ selection: fieldSelection,
54602
54632
  operations,
54603
54633
  abstract: isAbstract,
54604
54634
  update
54605
- } = selection2[field];
54635
+ } = targetSelection[field];
54606
54636
  const key = evaluateKey(keyRaw, variables);
54607
54637
  const currentSubscribers = this.subscriptions.get(parent, key);
54608
54638
  const { value: previousValue, displayLayers } = this.storage.get(parent, key);
@@ -54610,7 +54640,7 @@ var CacheInternal = class {
54610
54640
  if (displayLayer) {
54611
54641
  this.lifetimes.resetLifetime(parent, key);
54612
54642
  }
54613
- if (!fields) {
54643
+ if (!fieldSelection) {
54614
54644
  let newValue = value;
54615
54645
  if (Array.isArray(value) && applyUpdates && update) {
54616
54646
  if (update === "append") {
@@ -54630,7 +54660,7 @@ var CacheInternal = class {
54630
54660
  }
54631
54661
  const previousLinks = flattenList([previousValue]);
54632
54662
  for (const link of previousLinks) {
54633
- this.subscriptions.remove(link, fields, currentSubscribers, variables);
54663
+ this.subscriptions.remove(link, fieldSelection, currentSubscribers, variables);
54634
54664
  }
54635
54665
  layer.writeLink(parent, key, null);
54636
54666
  toNotify.push(...currentSubscribers);
@@ -54656,14 +54686,14 @@ var CacheInternal = class {
54656
54686
  if (previousValue && typeof previousValue === "string") {
54657
54687
  this.subscriptions.remove(
54658
54688
  previousValue,
54659
- fields,
54689
+ fieldSelection,
54660
54690
  currentSubscribers,
54661
54691
  variables
54662
54692
  );
54663
54693
  }
54664
54694
  this.subscriptions.addMany({
54665
54695
  parent: linkedID,
54666
- selection: fields,
54696
+ selection: fieldSelection,
54667
54697
  subscribers: currentSubscribers,
54668
54698
  variables,
54669
54699
  parentType: linkedType
@@ -54673,14 +54703,14 @@ var CacheInternal = class {
54673
54703
  if (linkedID) {
54674
54704
  this.writeSelection({
54675
54705
  root,
54676
- selection: fields,
54706
+ selection: fieldSelection,
54677
54707
  parent: linkedID,
54678
54708
  data: value,
54679
54709
  variables,
54680
54710
  toNotify,
54681
54711
  applyUpdates,
54682
54712
  layer,
54683
- forceNotify: true
54713
+ forceNotify
54684
54714
  });
54685
54715
  }
54686
54716
  } else if (Array.isArray(value) && (typeof previousValue === "undefined" || Array.isArray(previousValue))) {
@@ -54709,7 +54739,7 @@ var CacheInternal = class {
54709
54739
  key,
54710
54740
  linkedType,
54711
54741
  variables,
54712
- fields,
54742
+ fields: fieldSelection,
54713
54743
  layer,
54714
54744
  forceNotify
54715
54745
  });
@@ -54759,7 +54789,7 @@ var CacheInternal = class {
54759
54789
  if (linkedIDs.includes(lostID) || !lostID) {
54760
54790
  continue;
54761
54791
  }
54762
- this.subscriptions.remove(lostID, fields, currentSubscribers, variables);
54792
+ this.subscriptions.remove(lostID, fieldSelection, currentSubscribers, variables);
54763
54793
  }
54764
54794
  if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
54765
54795
  layer.writeLink(parent, key, linkedIDs);
@@ -54770,7 +54800,7 @@ var CacheInternal = class {
54770
54800
  }
54771
54801
  this.subscriptions.addMany({
54772
54802
  parent: id,
54773
- selection: fields,
54803
+ selection: fieldSelection,
54774
54804
  subscribers: currentSubscribers,
54775
54805
  variables,
54776
54806
  parentType: linkedType
@@ -54795,9 +54825,14 @@ var CacheInternal = class {
54795
54825
  }
54796
54826
  const targets = Array.isArray(value) ? value : [value];
54797
54827
  for (const target of targets) {
54798
- if (operation.action === "insert" && target instanceof Object && fields && operation.list) {
54799
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(fields, target, variables, operation.position || "last");
54800
- } else if (operation.action === "remove" && target instanceof Object && fields && operation.list) {
54828
+ if (operation.action === "insert" && target instanceof Object && fieldSelection && operation.list) {
54829
+ this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(
54830
+ fieldSelection,
54831
+ target,
54832
+ variables,
54833
+ operation.position || "last"
54834
+ );
54835
+ } else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
54801
54836
  this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
54802
54837
  } else if (operation.action === "delete" && operation.type) {
54803
54838
  if (typeof target !== "string") {
@@ -54808,8 +54843,13 @@ var CacheInternal = class {
54808
54843
  continue;
54809
54844
  }
54810
54845
  this.cache.delete(targetID);
54811
- } else if (operation.action === "toggle" && target instanceof Object && fields && operation.list) {
54812
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(fields, target, variables, operation.position || "last");
54846
+ } else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
54847
+ this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
54848
+ fieldSelection,
54849
+ target,
54850
+ variables,
54851
+ operation.position || "last"
54852
+ );
54813
54853
  }
54814
54854
  }
54815
54855
  }
@@ -54829,9 +54869,12 @@ var CacheInternal = class {
54829
54869
  let hasData = false;
54830
54870
  let partial = false;
54831
54871
  let cascadeNull = false;
54832
- for (const [attributeName, { type, keyRaw, fields, nullable, list }] of Object.entries(
54833
- selection2
54834
- )) {
54872
+ const typename = this.storage.get(parent, "__typename").value;
54873
+ let targetSelection = getFieldsForType(selection2, typename);
54874
+ for (const [
54875
+ attributeName,
54876
+ { type, keyRaw, selection: fieldSelection, nullable, list }
54877
+ ] of Object.entries(targetSelection)) {
54835
54878
  const key = evaluateKey(keyRaw, variables);
54836
54879
  const { value } = this.storage.get(parent, key);
54837
54880
  let nextStep = stepsFromConnection;
@@ -54854,7 +54897,7 @@ var CacheInternal = class {
54854
54897
  if (typeof value !== "undefined") {
54855
54898
  hasData = true;
54856
54899
  }
54857
- } else if (!fields) {
54900
+ } else if (!fieldSelection) {
54858
54901
  const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
54859
54902
  if (fnUnmarshal) {
54860
54903
  target[attributeName] = fnUnmarshal(value);
@@ -54864,7 +54907,7 @@ var CacheInternal = class {
54864
54907
  hasData = true;
54865
54908
  } else if (Array.isArray(value)) {
54866
54909
  const listValue = this.hydrateNestedList({
54867
- fields,
54910
+ fields: fieldSelection,
54868
54911
  variables,
54869
54912
  linkedList: value,
54870
54913
  stepsFromConnection: nextStep
@@ -54879,7 +54922,7 @@ var CacheInternal = class {
54879
54922
  } else {
54880
54923
  const objectFields = this.getSelection({
54881
54924
  parent: value,
54882
- selection: fields,
54925
+ selection: fieldSelection,
54883
54926
  variables,
54884
54927
  stepsFromConnection: nextStep
54885
54928
  });
@@ -55380,7 +55423,7 @@ var Config = class {
55380
55423
  typeConfig;
55381
55424
  configFile;
55382
55425
  logLevel;
55383
- disableMasking;
55426
+ defaultFragmentMasking = "enable";
55384
55427
  configIsRoute = null;
55385
55428
  routesDir;
55386
55429
  schemaPollInterval;
@@ -55393,6 +55436,11 @@ var Config = class {
55393
55436
  ...configFile
55394
55437
  }) {
55395
55438
  this.configFile = defaultConfigValues(configFile);
55439
+ if (configFile.disableMasking !== void 0) {
55440
+ throw new HoudiniError({
55441
+ message: `"disableMasking" was replaced by "defaultFragmentMasking". Please update your config file.`
55442
+ });
55443
+ }
55396
55444
  let {
55397
55445
  schema,
55398
55446
  schemaPath = "./schema.graphql",
@@ -55409,7 +55457,7 @@ var Config = class {
55409
55457
  defaultKeys,
55410
55458
  types: types12 = {},
55411
55459
  logLevel,
55412
- disableMasking = false,
55460
+ defaultFragmentMasking = "enable",
55413
55461
  schemaPollInterval = 2e3,
55414
55462
  schemaPollHeaders = {},
55415
55463
  projectDir
@@ -55428,7 +55476,11 @@ var Config = class {
55428
55476
  logLevel = LogLevel.Summary;
55429
55477
  }
55430
55478
  this.schemaPath = schemaPath;
55431
- this.apiUrl = apiUrl;
55479
+ if (apiUrl && apiUrl.startsWith("env:")) {
55480
+ this.apiUrl = process.env[apiUrl.slice("env:".length)];
55481
+ } else {
55482
+ this.apiUrl = apiUrl;
55483
+ }
55432
55484
  this.filepath = filepath;
55433
55485
  this.exclude = Array.isArray(exclude) ? exclude : [exclude];
55434
55486
  this.module = module;
@@ -55440,10 +55492,10 @@ var Config = class {
55440
55492
  this.defaultCachePolicy = defaultCachePolicy;
55441
55493
  this.defaultPartial = defaultPartial;
55442
55494
  this.internalListPosition = defaultListPosition === "append" ? "last" : "first";
55443
- this.defaultListTarget == defaultListTarget;
55495
+ this.defaultListTarget = defaultListTarget;
55444
55496
  this.definitionsFolder = definitionsPath;
55445
55497
  this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
55446
- this.disableMasking = disableMasking;
55498
+ this.defaultFragmentMasking = defaultFragmentMasking;
55447
55499
  this.routesDir = join(this.projectRoot, "src", "routes");
55448
55500
  this.schemaPollInterval = schemaPollInterval;
55449
55501
  this.schemaPollHeaders = schemaPollHeaders;
@@ -55637,8 +55689,14 @@ var Config = class {
55637
55689
  pluginDirectory(name2) {
55638
55690
  return houdini_mode.is_testing ? resolve("../../../", name2) : join(this.rootDir, "plugins", name2);
55639
55691
  }
55640
- get houdiniDirective() {
55641
- return "houdini";
55692
+ get manualLoadDirective() {
55693
+ return "manual_load";
55694
+ }
55695
+ get maskEnableDirective() {
55696
+ return "mask_enable";
55697
+ }
55698
+ get maskDisableDirective() {
55699
+ return "mask_disable";
55642
55700
  }
55643
55701
  get listDirective() {
55644
55702
  return "list";
@@ -55650,9 +55708,9 @@ var Config = class {
55650
55708
  return "append";
55651
55709
  }
55652
55710
  get listParentDirective() {
55653
- return this.listDirectiveParentIDArg;
55711
+ return "parentID";
55654
55712
  }
55655
- get listDirectiveParentIDArg() {
55713
+ get deprecatedlistDirectiveParentIDArg() {
55656
55714
  return "parentID";
55657
55715
  }
55658
55716
  get listAllListsDirective() {
@@ -55738,7 +55796,7 @@ var Config = class {
55738
55796
  this.listDirective,
55739
55797
  this.listPrependDirective,
55740
55798
  this.listAppendDirective,
55741
- this.listDirectiveParentIDArg,
55799
+ this.listParentDirective,
55742
55800
  this.listAllListsDirective,
55743
55801
  this.whenDirective,
55744
55802
  this.whenNotDirective,
@@ -55746,7 +55804,9 @@ var Config = class {
55746
55804
  this.withDirective,
55747
55805
  this.paginateDirective,
55748
55806
  this.cacheDirective,
55749
- this.houdiniDirective
55807
+ this.manualLoadDirective,
55808
+ this.maskEnableDirective,
55809
+ this.maskDisableDirective
55750
55810
  ].includes(name2.value) || this.isDeleteDirective(name2.value);
55751
55811
  }
55752
55812
  isListFragment(name2) {
@@ -55983,13 +56043,17 @@ function flattenSelections({
55983
56043
  config: config2,
55984
56044
  filepath,
55985
56045
  selections,
55986
- fragmentDefinitions
56046
+ fragmentDefinitions,
56047
+ applyFragments,
56048
+ ignoreMaskDisable
55987
56049
  }) {
55988
56050
  const fields = new FieldCollection({
55989
56051
  config: config2,
55990
56052
  filepath,
55991
56053
  selections,
55992
- fragmentDefinitions
56054
+ fragmentDefinitions,
56055
+ applyFragments,
56056
+ ignoreMaskDisable: !!ignoreMaskDisable
55993
56057
  });
55994
56058
  return fields.toSelectionSet();
55995
56059
  }
@@ -56000,9 +56064,13 @@ var FieldCollection = class {
56000
56064
  fields;
56001
56065
  inlineFragments;
56002
56066
  fragmentSpreads;
56067
+ applyFragments;
56068
+ ignoreMaskDisable;
56003
56069
  constructor(args) {
56004
56070
  this.config = args.config;
56005
56071
  this.fragmentDefinitions = args.fragmentDefinitions;
56072
+ this.applyFragments = args.applyFragments;
56073
+ this.ignoreMaskDisable = args.ignoreMaskDisable;
56006
56074
  this.fields = {};
56007
56075
  this.inlineFragments = {};
56008
56076
  this.fragmentSpreads = {};
@@ -56031,31 +56099,28 @@ var FieldCollection = class {
56031
56099
  }
56032
56100
  }
56033
56101
  if (selection2.kind === "InlineFragment" && selection2.typeCondition) {
56034
- const key = selection2.typeCondition.name.value;
56035
- if (!this.inlineFragments[key]) {
56036
- this.inlineFragments[key] = {
56037
- astNode: selection2,
56038
- selection: this.empty()
56039
- };
56040
- }
56041
- for (const subselect of selection2.selectionSet?.selections || []) {
56042
- this.inlineFragments[key].selection.add(subselect);
56043
- }
56102
+ this.walkInlineFragment(selection2);
56044
56103
  return;
56045
56104
  }
56046
56105
  if (selection2.kind === "FragmentSpread") {
56047
56106
  this.fragmentSpreads[selection2.name.value] = selection2;
56048
- const houdiniDirective = selection2.directives?.find(
56049
- ({ name: name2 }) => name2.value === this.config.houdiniDirective
56107
+ let includeFragments = this.config.defaultFragmentMasking === "disable";
56108
+ const maskEnableDirective = selection2.directives?.find(
56109
+ ({ name: name2 }) => name2.value === this.config.maskEnableDirective
56050
56110
  );
56051
- const maskArgument = houdiniDirective?.arguments?.find(
56052
- ({ name: name2 }) => name2.value === "mask"
56111
+ if (maskEnableDirective) {
56112
+ includeFragments = false;
56113
+ }
56114
+ const maskDisableDirective = selection2.directives?.find(
56115
+ ({ name: name2 }) => name2.value === this.config.maskDisableDirective
56053
56116
  );
56054
- let includeFragments = this.config.disableMasking;
56055
- if (maskArgument?.value.kind === "BooleanValue") {
56056
- includeFragments = !maskArgument.value.value;
56117
+ if (maskDisableDirective) {
56118
+ includeFragments = true;
56119
+ }
56120
+ if (this.ignoreMaskDisable) {
56121
+ includeFragments = true;
56057
56122
  }
56058
- if (!includeFragments) {
56123
+ if (!includeFragments || !this.applyFragments) {
56059
56124
  return;
56060
56125
  }
56061
56126
  const definition = this.fragmentDefinitions[selection2.name.value];
@@ -56065,9 +56130,20 @@ var FieldCollection = class {
56065
56130
  message: "Could not find referenced fragment definition: " + selection2.name.value
56066
56131
  });
56067
56132
  }
56068
- for (const subselect of definition.selectionSet.selections) {
56069
- this.add(subselect);
56070
- }
56133
+ this.add({
56134
+ kind: "InlineFragment",
56135
+ typeCondition: {
56136
+ kind: "NamedType",
56137
+ name: {
56138
+ kind: "Name",
56139
+ value: definition.typeCondition.name.value
56140
+ }
56141
+ },
56142
+ selectionSet: {
56143
+ kind: "SelectionSet",
56144
+ selections: [...definition.selectionSet.selections]
56145
+ }
56146
+ });
56071
56147
  }
56072
56148
  }
56073
56149
  toSelectionSet() {
@@ -56083,12 +56159,30 @@ var FieldCollection = class {
56083
56159
  })
56084
56160
  ).concat(Object.values(this.fragmentSpreads));
56085
56161
  }
56162
+ walkInlineFragment(selection2) {
56163
+ const key = selection2.typeCondition.name.value;
56164
+ if (!this.inlineFragments[key]) {
56165
+ this.inlineFragments[key] = {
56166
+ astNode: selection2,
56167
+ selection: this.empty()
56168
+ };
56169
+ }
56170
+ for (const subselect of selection2.selectionSet.selections || []) {
56171
+ if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
56172
+ this.inlineFragments[key].selection.add(subselect);
56173
+ continue;
56174
+ }
56175
+ this.walkInlineFragment(subselect);
56176
+ }
56177
+ }
56086
56178
  empty() {
56087
56179
  return new FieldCollection({
56088
56180
  config: this.config,
56089
56181
  fragmentDefinitions: this.fragmentDefinitions,
56090
56182
  selections: [],
56091
- filepath: this.filepath
56183
+ filepath: this.filepath,
56184
+ applyFragments: this.applyFragments,
56185
+ ignoreMaskDisable: this.ignoreMaskDisable
56092
56186
  });
56093
56187
  }
56094
56188
  };
@@ -56443,11 +56537,6 @@ function operationObject({
56443
56537
  const when = internalDirectives.find(({ name: name2 }) => name2.value === "when");
56444
56538
  const when_not = internalDirectives.find(({ name: name2 }) => name2.value === "when_not");
56445
56539
  let parentIDArg = parent?.arguments?.find((argument) => argument.name.value === "value");
56446
- if (!parentIDArg) {
56447
- parentIDArg = (append || prepend)?.arguments?.find(
56448
- ({ name: name2 }) => name2.value === config2.listDirectiveParentIDArg
56449
- );
56450
- }
56451
56540
  if (parentIDArg) {
56452
56541
  if (parentIDArg.value.kind === "StringValue") {
56453
56542
  parentID = parentIDArg.value.value;
@@ -57475,6 +57564,8 @@ function selection({
57475
57564
  markEdges
57476
57565
  }) {
57477
57566
  let object = {};
57567
+ const typeMap = {};
57568
+ const abstractTypes = [];
57478
57569
  for (const field of selections) {
57479
57570
  if (field.kind === "FragmentSpread" && includeFragments) {
57480
57571
  const fragmentDefinition = document.document.definitions.find(
@@ -57501,20 +57592,68 @@ function selection({
57501
57592
  })
57502
57593
  );
57503
57594
  } else if (field.kind === "InlineFragment") {
57504
- object = deepMerge(
57505
- filepath,
57506
- object,
57507
- selection({
57508
- config: config2,
57595
+ if (!field.typeCondition || field.typeCondition.name.value === rootType) {
57596
+ object.fields = deepMerge(
57509
57597
  filepath,
57510
- rootType: field.typeCondition?.name.value || rootType,
57511
- operations,
57512
- selections: field.selectionSet.selections,
57513
- path: path2,
57514
- includeFragments,
57515
- document
57516
- })
57517
- );
57598
+ object.fields || {},
57599
+ selection({
57600
+ config: config2,
57601
+ filepath,
57602
+ rootType: field.typeCondition?.name.value || rootType,
57603
+ operations,
57604
+ selections: field.selectionSet.selections,
57605
+ path: path2,
57606
+ includeFragments,
57607
+ document
57608
+ }).fields || {}
57609
+ );
57610
+ } else {
57611
+ if (!object.abstractFields) {
57612
+ object.abstractFields = {
57613
+ fields: {},
57614
+ typeMap: {}
57615
+ };
57616
+ }
57617
+ const parentType = config2.schema.getType(rootType);
57618
+ const typeConditionName = field.typeCondition.name.value;
57619
+ const typeCondition = config2.schema.getType(typeConditionName);
57620
+ const possibleTypes = [];
57621
+ if (!graphql10.isAbstractType(typeCondition)) {
57622
+ } else if (graphql10.isAbstractType(parentType)) {
57623
+ const possibleParentTypes = config2.schema.getPossibleTypes(parentType).map((type) => type.name);
57624
+ for (const possible of config2.schema.getPossibleTypes(typeCondition)) {
57625
+ if (possibleParentTypes.includes(possible.name)) {
57626
+ possibleTypes.push(possible.name);
57627
+ }
57628
+ }
57629
+ } else {
57630
+ possibleTypes.push(rootType);
57631
+ }
57632
+ if (possibleTypes.length > 0) {
57633
+ for (const type of possibleTypes) {
57634
+ const existing = typeMap[type];
57635
+ if (!existing || !existing.includes(type)) {
57636
+ typeMap[type] = [typeConditionName].concat(existing || []);
57637
+ }
57638
+ if (!abstractTypes.includes(typeConditionName)) {
57639
+ abstractTypes.push(typeConditionName);
57640
+ }
57641
+ }
57642
+ }
57643
+ object.abstractFields.fields = {
57644
+ ...object.abstractFields.fields,
57645
+ [field.typeCondition.name.value]: selection({
57646
+ config: config2,
57647
+ filepath,
57648
+ rootType: field.typeCondition?.name.value || rootType,
57649
+ operations,
57650
+ selections: field.selectionSet.selections,
57651
+ path: path2,
57652
+ includeFragments,
57653
+ document
57654
+ }).fields
57655
+ };
57656
+ }
57518
57657
  } else if (field.kind === "Field") {
57519
57658
  const type = config2.schema.getType(rootType);
57520
57659
  if (!type) {
@@ -57572,7 +57711,7 @@ function selection({
57572
57711
  }
57573
57712
  if (field.selectionSet) {
57574
57713
  const edgesMark = paginated && document.refetch?.method === "cursor" ? document.refetch.update : markEdges;
57575
- fieldObj.fields = selection({
57714
+ fieldObj.selection = selection({
57576
57715
  config: config2,
57577
57716
  filepath,
57578
57717
  rootType: typeName,
@@ -57596,11 +57735,49 @@ function selection({
57596
57735
  if (graphql10.isInterfaceType(fieldType) || graphql10.isUnionType(fieldType)) {
57597
57736
  fieldObj.abstract = true;
57598
57737
  }
57599
- object[attributeName] = deepMerge(
57600
- filepath,
57601
- fieldObj,
57602
- object[attributeName] || {}
57603
- );
57738
+ object.fields = {
57739
+ ...object.fields,
57740
+ [attributeName]: fieldObj
57741
+ };
57742
+ }
57743
+ }
57744
+ if (Object.keys(object.fields || {}).length > 0 && object.abstractFields && Object.keys(object.abstractFields.fields).length > 0) {
57745
+ for (const [typeName, possibles] of Object.entries(typeMap)) {
57746
+ let overlap = false;
57747
+ for (const possible of possibles) {
57748
+ if (object.abstractFields.fields[typeName]) {
57749
+ object.abstractFields.fields[typeName] = deepMerge(
57750
+ filepath,
57751
+ object.abstractFields.fields[typeName] || {},
57752
+ object.abstractFields.fields[possible]
57753
+ );
57754
+ overlap = true;
57755
+ }
57756
+ }
57757
+ if (overlap) {
57758
+ delete typeMap[typeName];
57759
+ }
57760
+ }
57761
+ for (const [type, options] of Object.entries(typeMap)) {
57762
+ if (options.length > 1) {
57763
+ object.abstractFields.fields[type] = deepMerge(
57764
+ filepath,
57765
+ ...options.map((opt) => object.abstractFields.fields[opt] || {})
57766
+ );
57767
+ delete typeMap[type];
57768
+ }
57769
+ }
57770
+ for (const [type, sel] of Object.entries(object.abstractFields?.fields || {})) {
57771
+ object.abstractFields.fields[type] = deepMerge(filepath, sel || {}, object.fields);
57772
+ }
57773
+ for (const [type, options] of Object.entries(typeMap)) {
57774
+ object.abstractFields.typeMap[type] = options[0];
57775
+ }
57776
+ const usedTypes = Object.values(object.abstractFields.typeMap);
57777
+ for (const type of abstractTypes) {
57778
+ if (!usedTypes.includes(type)) {
57779
+ delete object.abstractFields.fields[type];
57780
+ }
57604
57781
  }
57605
57782
  }
57606
57783
  return object;
@@ -57735,6 +57912,22 @@ function artifactGenerator(stats) {
57735
57912
  selectionSet = matchingFragment.selectionSet;
57736
57913
  }
57737
57914
  const inputs = operations[0]?.variableDefinitions;
57915
+ const mergedSelection = flattenSelections({
57916
+ config: config2,
57917
+ filepath: doc.filename,
57918
+ selections: selectionSet.selections,
57919
+ fragmentDefinitions: doc.document.definitions.filter(
57920
+ (definition) => definition.kind === "FragmentDefinition"
57921
+ ).reduce(
57922
+ (prev, definition) => ({
57923
+ ...prev,
57924
+ [definition.name.value]: definition
57925
+ }),
57926
+ {}
57927
+ ),
57928
+ ignoreMaskDisable: docKind === "HoudiniQuery",
57929
+ applyFragments: docKind !== "HoudiniFragment"
57930
+ });
57738
57931
  const artifact = {
57739
57932
  name: name2,
57740
57933
  kind: docKind,
@@ -57746,7 +57939,7 @@ function artifactGenerator(stats) {
57746
57939
  config: config2,
57747
57940
  filepath: doc.filename,
57748
57941
  rootType,
57749
- selections: selectionSet.selections,
57942
+ selections: mergedSelection,
57750
57943
  operations: operationsByPath(
57751
57944
  config2,
57752
57945
  doc.filename,
@@ -58042,6 +58235,17 @@ function inlineType({
58042
58235
  continue;
58043
58236
  }
58044
58237
  const possibleParents = config2.schema.getPossibleTypes(type).map((t) => t.name);
58238
+ const freeSelections = [];
58239
+ const typeSpecificSelections = {};
58240
+ for (const node of selection2.selectionSet.selections) {
58241
+ if (node.kind !== "InlineFragment") {
58242
+ freeSelections.push(node);
58243
+ } else if (node.typeCondition) {
58244
+ typeSpecificSelections[node.typeCondition.name.value] = node.selectionSet.selections;
58245
+ } else {
58246
+ freeSelections.push(...node.selectionSet.selections);
58247
+ }
58248
+ }
58045
58249
  for (const possibleType of config2.schema.getPossibleTypes(fragmentType)) {
58046
58250
  if (!possibleParents.includes(possibleType.name)) {
58047
58251
  continue;
@@ -58049,7 +58253,12 @@ function inlineType({
58049
58253
  if (!inlineFragments[possibleType.name]) {
58050
58254
  inlineFragments[possibleType.name] = [];
58051
58255
  }
58052
- inlineFragments[possibleType.name].push(...selection2.selectionSet.selections);
58256
+ inlineFragments[possibleType.name].push(...freeSelections);
58257
+ if (typeSpecificSelections[possibleType.name]) {
58258
+ inlineFragments[possibleType.name].push(
58259
+ ...typeSpecificSelections[possibleType.name]
58260
+ );
58261
+ }
58053
58262
  }
58054
58263
  } else if (selection2.kind === "InlineFragment" && !selection2.typeCondition) {
58055
58264
  selectedFields.push(...selection2.selectionSet.selections);
@@ -58061,12 +58270,7 @@ function inlineType({
58061
58270
  ...(selectedFields || []).filter(
58062
58271
  (field) => field.kind === "Field"
58063
58272
  ).map((selection2) => {
58064
- const { type: type2, field } = selectionTypeInfo(
58065
- config2.schema,
58066
- filepath,
58067
- rootObj,
58068
- selection2
58069
- );
58273
+ const { field } = selectionTypeInfo(config2.schema, filepath, rootObj, selection2);
58070
58274
  const attributeName = selection2.alias?.value || selection2.name.value;
58071
58275
  let attributeType = inlineType({
58072
58276
  config: config2,
@@ -58265,7 +58469,8 @@ async function typescriptGenerator(config2, docs) {
58265
58469
  config: config2,
58266
58470
  filepath: filename,
58267
58471
  selections: definition.selectionSet.selections,
58268
- fragmentDefinitions
58472
+ fragmentDefinitions,
58473
+ applyFragments: definition.kind === "OperationDefinition"
58269
58474
  });
58270
58475
  if (definition?.kind === "OperationDefinition") {
58271
58476
  await generateOperationTypeDefs(
@@ -58778,14 +58983,12 @@ directive @${config2.paginateDirective}(${config2.paginateNameArg}: String) on F
58778
58983
  """
58779
58984
  @${config2.listPrependDirective} is used to tell the runtime to add the result to the end of the list
58780
58985
  """
58781
- directive @${config2.listPrependDirective}(
58782
- ${config2.listDirectiveParentIDArg}: ID
58783
- ) on FRAGMENT_SPREAD
58986
+ directive @${config2.listPrependDirective} on FRAGMENT_SPREAD
58784
58987
 
58785
58988
  """
58786
58989
  @${config2.listAppendDirective} is used to tell the runtime to add the result to the start of the list
58787
58990
  """
58788
- directive @${config2.listAppendDirective}(${config2.listDirectiveParentIDArg}: ID) on FRAGMENT_SPREAD
58991
+ directive @${config2.listAppendDirective} on FRAGMENT_SPREAD
58789
58992
 
58790
58993
  """
58791
58994
  @${config2.listAllListsDirective} is used to tell the runtime to add the result to all list
@@ -58819,18 +59022,19 @@ directive @${config2.argumentsDirective} on FRAGMENT_DEFINITION
58819
59022
  directive @${config2.cacheDirective}(${config2.cachePolicyArg}: CachePolicy, ${config2.cachePartialArg}: Boolean) on QUERY
58820
59023
 
58821
59024
  """
58822
- @${config2.houdiniDirective} is used to configure houdini's internal behavior
59025
+ @${config2.manualLoadDirective} is used to disable automatic fetch (no load, no auto fetch in component), you will have to do it manually.
58823
59026
  """
58824
- directive @${config2.houdiniDirective}(
58825
- """
58826
- Opt-in to an automatic load function (only valid when used at queries)
58827
- """
58828
- load: Boolean! = true
58829
- """
58830
- Mask fragment fields (only valid when used at a fragment spread)
58831
- """
58832
- mask: Boolean! = ${config2.disableMasking ? "false" : "true"}
58833
- ) on QUERY | FRAGMENT_SPREAD
59027
+ directive @${config2.manualLoadDirective} on QUERY
59028
+
59029
+ """
59030
+ @${config2.maskEnableDirective} to enable masking on fragment (overwriting the global conf)
59031
+ """
59032
+ directive @${config2.maskEnableDirective} on FRAGMENT_SPREAD
59033
+
59034
+ """
59035
+ @${config2.maskDisableDirective} to disable masking on fragment (overwriting the global conf)
59036
+ """
59037
+ directive @${config2.maskDisableDirective} on FRAGMENT_SPREAD
58834
59038
  `;
58835
59039
  let currentSchema = graphql19.printSchema(config2.schema);
58836
59040
  if (!currentSchema.includes(`directive @${config2.listDirective}`)) {
@@ -59323,26 +59527,42 @@ async function typeCheck(config2, docs) {
59323
59527
  ),
59324
59528
  targetField.selectionSet
59325
59529
  );
59326
- const missingIDFields = config2.keyFieldsForType(type.name).filter((fieldName) => !type.getFields()[fieldName]);
59327
- if (missingIDFields.length > 0) {
59328
- if (error) {
59329
- errors.push(
59330
- new HoudiniError({
59331
- filepath: filename,
59332
- message: error
59333
- })
59334
- );
59335
- } else {
59336
- errors.push(
59337
- new HoudiniError({
59338
- filepath: filename,
59339
- message: `@${config2.listDirective} can only be applied to types with the necessary id fields: ${missingIDFields.join(
59340
- ", "
59341
- )}.`
59342
- })
59343
- );
59530
+ let targetTypes = [type];
59531
+ if (graphql23.isUnionType(type)) {
59532
+ targetTypes = config2.schema.getPossibleTypes(type);
59533
+ } else if (graphql23.isInterfaceType(type)) {
59534
+ try {
59535
+ for (const key of config2.keyFieldsForType(type.name)) {
59536
+ if (!type.getFields()[key]) {
59537
+ throw new Error("continue");
59538
+ }
59539
+ }
59540
+ } catch {
59541
+ targetTypes = config2.schema.getPossibleTypes(type);
59542
+ }
59543
+ }
59544
+ for (const targetType of targetTypes) {
59545
+ const missingIDFields = config2.keyFieldsForType(targetType.name).filter((fieldName) => !targetType.getFields()[fieldName]);
59546
+ if (missingIDFields.length > 0) {
59547
+ if (error) {
59548
+ errors.push(
59549
+ new HoudiniError({
59550
+ filepath: filename,
59551
+ message: error
59552
+ })
59553
+ );
59554
+ } else {
59555
+ errors.push(
59556
+ new HoudiniError({
59557
+ filepath: filename,
59558
+ message: `@${config2.listDirective} can only be applied to types with the necessary id fields: ${missingIDFields.join(
59559
+ ", "
59560
+ )}.`
59561
+ })
59562
+ );
59563
+ }
59564
+ return;
59344
59565
  }
59345
- return;
59346
59566
  }
59347
59567
  lists.push(listName);
59348
59568
  listTypes.push(type.name);
@@ -59372,6 +59592,7 @@ async function typeCheck(config2, docs) {
59372
59592
  fragments
59373
59593
  }),
59374
59594
  checkMutationOperation(config2),
59595
+ checkMaskDirective(config2),
59375
59596
  nodeDirectives(config2, [config2.paginateDirective]),
59376
59597
  knownArguments(config2),
59377
59598
  validateFragmentArguments(config2, filepath, fragments),
@@ -59436,10 +59657,14 @@ var validateLists = ({
59436
59657
  ]);
59437
59658
  if (directive) {
59438
59659
  let parentArg = directive.arguments?.find(
59439
- (arg) => arg.name.value === config2.listDirectiveParentIDArg
59660
+ (arg) => arg.name.value === config2.deprecatedlistDirectiveParentIDArg
59440
59661
  );
59441
59662
  if (parentArg) {
59442
- parentIdFound = true;
59663
+ ctx.reportError(
59664
+ new graphql23.GraphQLError(
59665
+ `@${config2.deprecatedlistDirectiveParentIDArg} should be defined only in it's own directive now`
59666
+ )
59667
+ );
59443
59668
  }
59444
59669
  }
59445
59670
  if (parentIdFound) {
@@ -59835,6 +60060,28 @@ function checkMutationOperation(config2) {
59835
60060
  };
59836
60061
  };
59837
60062
  }
60063
+ function checkMaskDirective(config2) {
60064
+ return function(ctx) {
60065
+ return {
60066
+ FragmentSpread(node, _, __, ___, ancestors) {
60067
+ const maskEnableDirective = node.directives?.find(
60068
+ (c) => c.name.value === config2.maskEnableDirective
60069
+ );
60070
+ const maskDisableDirective = node.directives?.find(
60071
+ (c) => c.name.value === config2.maskDisableDirective
60072
+ );
60073
+ if (maskEnableDirective && maskDisableDirective) {
60074
+ ctx.reportError(
60075
+ new graphql23.GraphQLError(
60076
+ `You can't apply both @${config2.maskEnableDirective} and @${config2.maskDisableDirective} at the same time`
60077
+ )
60078
+ );
60079
+ return;
60080
+ }
60081
+ }
60082
+ };
60083
+ };
60084
+ }
59838
60085
  function getAndVerifyNodeInterface(config2) {
59839
60086
  const { schema } = config2;
59840
60087
  const nodeInterface = schema.getType("Node");
@@ -60113,8 +60360,9 @@ function testConfigFile(config2 = {}) {
60113
60360
  scalar Cursor
60114
60361
 
60115
60362
 
60116
- type User implements Node {
60363
+ type User implements Node & Friend & CatOwner {
60117
60364
  id: ID!
60365
+ name: String!
60118
60366
  firstName: String!
60119
60367
  friends: [User!]!
60120
60368
  friendsByCursor(first: Int, after: String, last: Int, before: String, filter: String): UserConnection!
@@ -60129,13 +60377,14 @@ function testConfigFile(config2 = {}) {
60129
60377
  field(filter: String): String
60130
60378
  }
60131
60379
 
60132
- type Ghost implements Friend {
60380
+ type Ghost implements Friend & CatOwner & IsGhost {
60133
60381
  name: String!
60134
60382
  aka: String!
60135
60383
  believers: [User!]!
60136
60384
  friends: [Ghost!]!
60137
60385
  friendsConnection(first: Int, after: String): GhostConnection!
60138
60386
  legends: [Legend!]!
60387
+ cats: [Cat!]!
60139
60388
  }
60140
60389
 
60141
60390
  type Legend {
@@ -60161,6 +60410,9 @@ function testConfigFile(config2 = {}) {
60161
60410
  usersByBackwardsCursor(last: Int, before: String): UserConnection!
60162
60411
  usersByForwardsCursor(first: Int, after: String): UserConnection!
60163
60412
  usersByOffset(offset: Int, limit: Int): [User!]!
60413
+ friendsByCursor(first: Int, after: String, last: Int, before: String): FriendConnection!
60414
+ ghostsByCursor(first: Int, after: String, last: Int, before: String): IsGhostConnection!
60415
+ entitiesByCursor(first: Int, after: String, last: Int, before: String): EntityConnection!
60164
60416
  node(id: ID!): Node
60165
60417
  }
60166
60418
 
@@ -60176,16 +60428,26 @@ function testConfigFile(config2 = {}) {
60176
60428
  node: User
60177
60429
  }
60178
60430
 
60179
- type UserEdgeScalar {
60180
- cursor: Cursor!
60181
- node: User
60182
- }
60183
-
60184
60431
  type UserConnection {
60185
60432
  pageInfo: PageInfo!
60186
60433
  edges: [UserEdge!]!
60187
60434
  }
60188
60435
 
60436
+ type FriendEdge {
60437
+ cursor: String!
60438
+ node: Friend
60439
+ }
60440
+
60441
+ type FriendConnection {
60442
+ pageInfo: PageInfo!
60443
+ edges: [FriendEdge!]!
60444
+ }
60445
+
60446
+ type UserEdgeScalar {
60447
+ cursor: Cursor!
60448
+ node: User
60449
+ }
60450
+
60189
60451
  type UserConnectionScalar {
60190
60452
  pageInfo: PageInfo!
60191
60453
  edges: [UserEdgeScalar!]!
@@ -60201,10 +60463,38 @@ function testConfigFile(config2 = {}) {
60201
60463
  edges: [GhostEdge!]!
60202
60464
  }
60203
60465
 
60466
+ type EntityEdge {
60467
+ cursor: String!
60468
+ node: Entity
60469
+ }
60470
+
60471
+ type EntityConnection {
60472
+ pageInfo: PageInfo!
60473
+ edges: [EntityEdge!]!
60474
+ }
60475
+
60476
+ type IsGhostEdge {
60477
+ cursor: String!
60478
+ node: IsGhost
60479
+ }
60480
+
60481
+ type IsGhostConnection {
60482
+ pageInfo: PageInfo!
60483
+ edges: [IsGhostEdge!]!
60484
+ }
60485
+
60204
60486
  interface Friend {
60205
60487
  name: String!
60206
60488
  }
60207
60489
 
60490
+ interface CatOwner {
60491
+ cats: [Cat!]!
60492
+ }
60493
+
60494
+ interface IsGhost {
60495
+ aka: String!
60496
+ }
60497
+
60208
60498
  union Entity = User | Cat | Ghost
60209
60499
 
60210
60500
  type Mutation {
@@ -60301,13 +60591,13 @@ function pipelineTest(config2, documents, shouldPass, testBody) {
60301
60591
  await runPipeline2(config2, docs);
60302
60592
  } catch (e) {
60303
60593
  if (shouldPass) {
60304
- throw e;
60594
+ console.error(e);
60595
+ throw "pipeline failed when it should have passed";
60305
60596
  }
60306
60597
  error = e;
60307
60598
  }
60308
60599
  if (!shouldPass && error.length === 0) {
60309
- throw "did not fail test";
60310
- return;
60600
+ throw "pipeline shouldn't have passed!";
60311
60601
  }
60312
60602
  if (testBody) {
60313
60603
  testBody(shouldPass ? docs : error);