houdini 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -70479,18 +70479,14 @@ function flattenSelections({
70479
70479
  filepath,
70480
70480
  selections,
70481
70481
  fragmentDefinitions,
70482
- ignoreMaskDisable,
70483
- keepFragmentSpreadNodes,
70484
- hoistFragments
70482
+ applyFragments
70485
70483
  }) {
70486
70484
  const fields = new FieldCollection({
70487
70485
  config: config4,
70488
70486
  filepath,
70489
70487
  selections,
70490
70488
  fragmentDefinitions,
70491
- ignoreMaskDisable: !!ignoreMaskDisable,
70492
- keepFragmentSpreadNodes: !!keepFragmentSpreadNodes,
70493
- hoistFragments
70489
+ applyFragments: !!applyFragments
70494
70490
  });
70495
70491
  return fields.toSelectionSet();
70496
70492
  }
@@ -70501,18 +70497,14 @@ var FieldCollection = class {
70501
70497
  fields;
70502
70498
  inlineFragments;
70503
70499
  fragmentSpreads;
70504
- ignoreMaskDisable;
70505
- keepFragmentSpreadNodes;
70506
- hoistFragments;
70500
+ applyFragments;
70507
70501
  constructor(args) {
70508
70502
  this.config = args.config;
70509
70503
  this.fragmentDefinitions = args.fragmentDefinitions;
70510
- this.ignoreMaskDisable = args.ignoreMaskDisable;
70511
- this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
70504
+ this.applyFragments = args.applyFragments;
70512
70505
  this.fields = {};
70513
70506
  this.inlineFragments = {};
70514
70507
  this.fragmentSpreads = {};
70515
- this.hoistFragments = !!args.hoistFragments;
70516
70508
  this.filepath = args.filepath;
70517
70509
  for (const selection of args.selections) {
70518
70510
  this.add({ selection });
@@ -70522,21 +70514,18 @@ var FieldCollection = class {
70522
70514
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
70523
70515
  }
70524
70516
  add({ selection, external }) {
70525
- let includeFragments = this.config.defaultFragmentMasking === "disable";
70517
+ let include = this.config.defaultFragmentMasking === "disable";
70526
70518
  const maskEnableDirective = selection.directives?.find(
70527
70519
  ({ name }) => name.value === this.config.maskEnableDirective
70528
70520
  );
70529
70521
  if (maskEnableDirective) {
70530
- includeFragments = false;
70522
+ include = false;
70531
70523
  }
70532
70524
  const maskDisableDirective = selection.directives?.find(
70533
70525
  ({ name }) => name.value === this.config.maskDisableDirective
70534
70526
  );
70535
70527
  if (maskDisableDirective) {
70536
- includeFragments = true;
70537
- }
70538
- if (this.ignoreMaskDisable) {
70539
- includeFragments = true;
70528
+ include = true;
70540
70529
  }
70541
70530
  if (selection.kind === "Field") {
70542
70531
  const key = selection.alias?.value || selection.name.value;
@@ -70552,7 +70541,7 @@ var FieldCollection = class {
70552
70541
  external
70553
70542
  });
70554
70543
  }
70555
- if (!external && includeFragments) {
70544
+ if (this.applyFragments && !external) {
70556
70545
  this.fields[key].selection.fragmentSpreads = {
70557
70546
  ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
70558
70547
  ...this.fields[key].selection.fragmentSpreads
@@ -70566,16 +70555,13 @@ var FieldCollection = class {
70566
70555
  }
70567
70556
  }
70568
70557
  if (selection.kind === "InlineFragment" && selection.typeCondition) {
70569
- this.walkInlineFragment({ selection, external, hoistFragments: this.hoistFragments });
70558
+ this.walkInlineFragment({ selection, external });
70570
70559
  return;
70571
70560
  }
70572
70561
  if (selection.kind === "FragmentSpread") {
70573
- if (this.keepFragmentSpreadNodes && !external) {
70562
+ if (!external || include) {
70574
70563
  this.fragmentSpreads[selection.name.value] = selection;
70575
70564
  }
70576
- if (!includeFragments) {
70577
- return;
70578
- }
70579
70565
  const definition = this.fragmentDefinitions[selection.name.value];
70580
70566
  if (!definition) {
70581
70567
  throw new HoudiniError({
@@ -70583,23 +70569,25 @@ var FieldCollection = class {
70583
70569
  message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
70584
70570
  });
70585
70571
  }
70586
- this.add({
70587
- selection: {
70588
- kind: "InlineFragment",
70589
- typeCondition: {
70590
- kind: "NamedType",
70591
- name: {
70592
- kind: "Name",
70593
- value: definition.typeCondition.name.value
70572
+ if (this.applyFragments || include) {
70573
+ this.add({
70574
+ selection: {
70575
+ kind: "InlineFragment",
70576
+ typeCondition: {
70577
+ kind: "NamedType",
70578
+ name: {
70579
+ kind: "Name",
70580
+ value: definition.typeCondition.name.value
70581
+ }
70582
+ },
70583
+ selectionSet: {
70584
+ kind: "SelectionSet",
70585
+ selections: [...definition.selectionSet.selections]
70594
70586
  }
70595
70587
  },
70596
- selectionSet: {
70597
- kind: "SelectionSet",
70598
- selections: [...definition.selectionSet.selections]
70599
- }
70600
- },
70601
- external
70602
- });
70588
+ external: !include
70589
+ });
70590
+ }
70603
70591
  }
70604
70592
  }
70605
70593
  collectFragmentSpreads(selections, result = {}) {
@@ -70656,8 +70644,7 @@ var FieldCollection = class {
70656
70644
  }
70657
70645
  walkInlineFragment({
70658
70646
  selection,
70659
- external,
70660
- hoistFragments
70647
+ external
70661
70648
  }) {
70662
70649
  const key = selection.typeCondition.name.value;
70663
70650
  if (!this.inlineFragments[key]) {
@@ -70667,7 +70654,7 @@ var FieldCollection = class {
70667
70654
  };
70668
70655
  }
70669
70656
  for (const subselect of selection.selectionSet.selections || []) {
70670
- if (subselect.kind === "FragmentSpread" && !hoistFragments || subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
70657
+ if (subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
70671
70658
  this.inlineFragments[key].selection.add({
70672
70659
  selection: subselect,
70673
70660
  external
@@ -70676,11 +70663,11 @@ var FieldCollection = class {
70676
70663
  } else if (subselect.kind === "FragmentSpread") {
70677
70664
  this.add({
70678
70665
  selection: subselect,
70679
- external: true
70666
+ external
70680
70667
  });
70681
70668
  continue;
70682
70669
  } else {
70683
- this.walkInlineFragment({ selection: subselect, external, hoistFragments });
70670
+ this.walkInlineFragment({ selection: subselect, external });
70684
70671
  }
70685
70672
  }
70686
70673
  }
@@ -70690,9 +70677,7 @@ var FieldCollection = class {
70690
70677
  fragmentDefinitions: this.fragmentDefinitions,
70691
70678
  selections: [],
70692
70679
  filepath: this.filepath,
70693
- ignoreMaskDisable: this.ignoreMaskDisable,
70694
- keepFragmentSpreadNodes: this.keepFragmentSpreadNodes,
70695
- hoistFragments: this.hoistFragments
70680
+ applyFragments: this.applyFragments
70696
70681
  });
70697
70682
  }
70698
70683
  };
@@ -72618,7 +72603,8 @@ function prepareSelection({
72618
72603
  inConnection,
72619
72604
  typeMap,
72620
72605
  abstractTypes,
72621
- globalLoading
72606
+ globalLoading,
72607
+ includeFragments
72622
72608
  }) {
72623
72609
  let object = {};
72624
72610
  const loadingTypes = [];
@@ -72638,7 +72624,8 @@ function prepareSelection({
72638
72624
  document,
72639
72625
  typeMap,
72640
72626
  abstractTypes,
72641
- globalLoading
72627
+ globalLoading,
72628
+ includeFragments
72642
72629
  }).fields || {}
72643
72630
  );
72644
72631
  } else {
@@ -72686,7 +72673,8 @@ function prepareSelection({
72686
72673
  document,
72687
72674
  typeMap,
72688
72675
  abstractTypes,
72689
- globalLoading
72676
+ globalLoading,
72677
+ includeFragments
72690
72678
  }).fields
72691
72679
  };
72692
72680
  if (field.directives?.find((d) => d.name.value === config4.loadingDirective)) {
@@ -72804,7 +72792,8 @@ function prepareSelection({
72804
72792
  inConnection: connectionState,
72805
72793
  typeMap,
72806
72794
  abstractTypes,
72807
- globalLoading: forceLoading
72795
+ globalLoading: forceLoading,
72796
+ includeFragments
72808
72797
  });
72809
72798
  if (Object.values(fieldObj.selection.fields ?? {}).some((field2) => field2.required)) {
72810
72799
  fieldObj.nullable = true;
@@ -73137,14 +73126,13 @@ function artifactGenerator(stats) {
73137
73126
  document: doc,
73138
73127
  rootType,
73139
73128
  globalLoading,
73129
+ includeFragments: doc.kind !== ArtifactKind.Fragment,
73140
73130
  selections: flattenSelections({
73141
73131
  config: config4,
73142
73132
  filepath: doc.filename,
73143
73133
  selections: selectionSet.selections,
73144
73134
  fragmentDefinitions,
73145
- ignoreMaskDisable: docKind !== "HoudiniFragment",
73146
- keepFragmentSpreadNodes: true,
73147
- hoistFragments: true
73135
+ applyFragments: doc.kind !== ArtifactKind.Fragment
73148
73136
  }),
73149
73137
  operations: operationsByPath(
73150
73138
  config4,
@@ -74109,8 +74097,7 @@ async function generateDocumentTypes(config4, docs) {
74109
74097
  config: config4,
74110
74098
  filepath: filename,
74111
74099
  selections: definition.selectionSet.selections,
74112
- fragmentDefinitions,
74113
- keepFragmentSpreadNodes: true
74100
+ fragmentDefinitions
74114
74101
  });
74115
74102
  if (definition?.kind === "OperationDefinition") {
74116
74103
  await generateOperationTypeDefs(
@@ -70473,18 +70473,14 @@ function flattenSelections({
70473
70473
  filepath,
70474
70474
  selections,
70475
70475
  fragmentDefinitions,
70476
- ignoreMaskDisable,
70477
- keepFragmentSpreadNodes,
70478
- hoistFragments
70476
+ applyFragments
70479
70477
  }) {
70480
70478
  const fields = new FieldCollection({
70481
70479
  config: config4,
70482
70480
  filepath,
70483
70481
  selections,
70484
70482
  fragmentDefinitions,
70485
- ignoreMaskDisable: !!ignoreMaskDisable,
70486
- keepFragmentSpreadNodes: !!keepFragmentSpreadNodes,
70487
- hoistFragments
70483
+ applyFragments: !!applyFragments
70488
70484
  });
70489
70485
  return fields.toSelectionSet();
70490
70486
  }
@@ -70495,18 +70491,14 @@ var FieldCollection = class {
70495
70491
  fields;
70496
70492
  inlineFragments;
70497
70493
  fragmentSpreads;
70498
- ignoreMaskDisable;
70499
- keepFragmentSpreadNodes;
70500
- hoistFragments;
70494
+ applyFragments;
70501
70495
  constructor(args) {
70502
70496
  this.config = args.config;
70503
70497
  this.fragmentDefinitions = args.fragmentDefinitions;
70504
- this.ignoreMaskDisable = args.ignoreMaskDisable;
70505
- this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
70498
+ this.applyFragments = args.applyFragments;
70506
70499
  this.fields = {};
70507
70500
  this.inlineFragments = {};
70508
70501
  this.fragmentSpreads = {};
70509
- this.hoistFragments = !!args.hoistFragments;
70510
70502
  this.filepath = args.filepath;
70511
70503
  for (const selection of args.selections) {
70512
70504
  this.add({ selection });
@@ -70516,21 +70508,18 @@ var FieldCollection = class {
70516
70508
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
70517
70509
  }
70518
70510
  add({ selection, external }) {
70519
- let includeFragments = this.config.defaultFragmentMasking === "disable";
70511
+ let include = this.config.defaultFragmentMasking === "disable";
70520
70512
  const maskEnableDirective = selection.directives?.find(
70521
70513
  ({ name }) => name.value === this.config.maskEnableDirective
70522
70514
  );
70523
70515
  if (maskEnableDirective) {
70524
- includeFragments = false;
70516
+ include = false;
70525
70517
  }
70526
70518
  const maskDisableDirective = selection.directives?.find(
70527
70519
  ({ name }) => name.value === this.config.maskDisableDirective
70528
70520
  );
70529
70521
  if (maskDisableDirective) {
70530
- includeFragments = true;
70531
- }
70532
- if (this.ignoreMaskDisable) {
70533
- includeFragments = true;
70522
+ include = true;
70534
70523
  }
70535
70524
  if (selection.kind === "Field") {
70536
70525
  const key = selection.alias?.value || selection.name.value;
@@ -70546,7 +70535,7 @@ var FieldCollection = class {
70546
70535
  external
70547
70536
  });
70548
70537
  }
70549
- if (!external && includeFragments) {
70538
+ if (this.applyFragments && !external) {
70550
70539
  this.fields[key].selection.fragmentSpreads = {
70551
70540
  ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
70552
70541
  ...this.fields[key].selection.fragmentSpreads
@@ -70560,16 +70549,13 @@ var FieldCollection = class {
70560
70549
  }
70561
70550
  }
70562
70551
  if (selection.kind === "InlineFragment" && selection.typeCondition) {
70563
- this.walkInlineFragment({ selection, external, hoistFragments: this.hoistFragments });
70552
+ this.walkInlineFragment({ selection, external });
70564
70553
  return;
70565
70554
  }
70566
70555
  if (selection.kind === "FragmentSpread") {
70567
- if (this.keepFragmentSpreadNodes && !external) {
70556
+ if (!external || include) {
70568
70557
  this.fragmentSpreads[selection.name.value] = selection;
70569
70558
  }
70570
- if (!includeFragments) {
70571
- return;
70572
- }
70573
70559
  const definition = this.fragmentDefinitions[selection.name.value];
70574
70560
  if (!definition) {
70575
70561
  throw new HoudiniError({
@@ -70577,23 +70563,25 @@ var FieldCollection = class {
70577
70563
  message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
70578
70564
  });
70579
70565
  }
70580
- this.add({
70581
- selection: {
70582
- kind: "InlineFragment",
70583
- typeCondition: {
70584
- kind: "NamedType",
70585
- name: {
70586
- kind: "Name",
70587
- value: definition.typeCondition.name.value
70566
+ if (this.applyFragments || include) {
70567
+ this.add({
70568
+ selection: {
70569
+ kind: "InlineFragment",
70570
+ typeCondition: {
70571
+ kind: "NamedType",
70572
+ name: {
70573
+ kind: "Name",
70574
+ value: definition.typeCondition.name.value
70575
+ }
70576
+ },
70577
+ selectionSet: {
70578
+ kind: "SelectionSet",
70579
+ selections: [...definition.selectionSet.selections]
70588
70580
  }
70589
70581
  },
70590
- selectionSet: {
70591
- kind: "SelectionSet",
70592
- selections: [...definition.selectionSet.selections]
70593
- }
70594
- },
70595
- external
70596
- });
70582
+ external: !include
70583
+ });
70584
+ }
70597
70585
  }
70598
70586
  }
70599
70587
  collectFragmentSpreads(selections, result = {}) {
@@ -70650,8 +70638,7 @@ var FieldCollection = class {
70650
70638
  }
70651
70639
  walkInlineFragment({
70652
70640
  selection,
70653
- external,
70654
- hoistFragments
70641
+ external
70655
70642
  }) {
70656
70643
  const key = selection.typeCondition.name.value;
70657
70644
  if (!this.inlineFragments[key]) {
@@ -70661,7 +70648,7 @@ var FieldCollection = class {
70661
70648
  };
70662
70649
  }
70663
70650
  for (const subselect of selection.selectionSet.selections || []) {
70664
- if (subselect.kind === "FragmentSpread" && !hoistFragments || subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
70651
+ if (subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
70665
70652
  this.inlineFragments[key].selection.add({
70666
70653
  selection: subselect,
70667
70654
  external
@@ -70670,11 +70657,11 @@ var FieldCollection = class {
70670
70657
  } else if (subselect.kind === "FragmentSpread") {
70671
70658
  this.add({
70672
70659
  selection: subselect,
70673
- external: true
70660
+ external
70674
70661
  });
70675
70662
  continue;
70676
70663
  } else {
70677
- this.walkInlineFragment({ selection: subselect, external, hoistFragments });
70664
+ this.walkInlineFragment({ selection: subselect, external });
70678
70665
  }
70679
70666
  }
70680
70667
  }
@@ -70684,9 +70671,7 @@ var FieldCollection = class {
70684
70671
  fragmentDefinitions: this.fragmentDefinitions,
70685
70672
  selections: [],
70686
70673
  filepath: this.filepath,
70687
- ignoreMaskDisable: this.ignoreMaskDisable,
70688
- keepFragmentSpreadNodes: this.keepFragmentSpreadNodes,
70689
- hoistFragments: this.hoistFragments
70674
+ applyFragments: this.applyFragments
70690
70675
  });
70691
70676
  }
70692
70677
  };
@@ -72612,7 +72597,8 @@ function prepareSelection({
72612
72597
  inConnection,
72613
72598
  typeMap,
72614
72599
  abstractTypes,
72615
- globalLoading
72600
+ globalLoading,
72601
+ includeFragments
72616
72602
  }) {
72617
72603
  let object = {};
72618
72604
  const loadingTypes = [];
@@ -72632,7 +72618,8 @@ function prepareSelection({
72632
72618
  document,
72633
72619
  typeMap,
72634
72620
  abstractTypes,
72635
- globalLoading
72621
+ globalLoading,
72622
+ includeFragments
72636
72623
  }).fields || {}
72637
72624
  );
72638
72625
  } else {
@@ -72680,7 +72667,8 @@ function prepareSelection({
72680
72667
  document,
72681
72668
  typeMap,
72682
72669
  abstractTypes,
72683
- globalLoading
72670
+ globalLoading,
72671
+ includeFragments
72684
72672
  }).fields
72685
72673
  };
72686
72674
  if (field.directives?.find((d) => d.name.value === config4.loadingDirective)) {
@@ -72798,7 +72786,8 @@ function prepareSelection({
72798
72786
  inConnection: connectionState,
72799
72787
  typeMap,
72800
72788
  abstractTypes,
72801
- globalLoading: forceLoading
72789
+ globalLoading: forceLoading,
72790
+ includeFragments
72802
72791
  });
72803
72792
  if (Object.values(fieldObj.selection.fields ?? {}).some((field2) => field2.required)) {
72804
72793
  fieldObj.nullable = true;
@@ -73131,14 +73120,13 @@ function artifactGenerator(stats) {
73131
73120
  document: doc,
73132
73121
  rootType,
73133
73122
  globalLoading,
73123
+ includeFragments: doc.kind !== ArtifactKind.Fragment,
73134
73124
  selections: flattenSelections({
73135
73125
  config: config4,
73136
73126
  filepath: doc.filename,
73137
73127
  selections: selectionSet.selections,
73138
73128
  fragmentDefinitions,
73139
- ignoreMaskDisable: docKind !== "HoudiniFragment",
73140
- keepFragmentSpreadNodes: true,
73141
- hoistFragments: true
73129
+ applyFragments: doc.kind !== ArtifactKind.Fragment
73142
73130
  }),
73143
73131
  operations: operationsByPath(
73144
73132
  config4,
@@ -74103,8 +74091,7 @@ async function generateDocumentTypes(config4, docs) {
74103
74091
  config: config4,
74104
74092
  filepath: filename,
74105
74093
  selections: definition.selectionSet.selections,
74106
- fragmentDefinitions,
74107
- keepFragmentSpreadNodes: true
74094
+ fragmentDefinitions
74108
74095
  });
74109
74096
  if (definition?.kind === "OperationDefinition") {
74110
74097
  await generateOperationTypeDefs(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",