houdini 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -70197,7 +70197,7 @@ function deepMerge2(filepath, ...targets) {
70197
70197
  // src/lib/parse.ts
70198
70198
  async function parseJS(str, config4) {
70199
70199
  const defaultConfig = {
70200
- plugins: ["typescript", "importAssertions", "jsx"],
70200
+ plugins: ["typescript", "importAssertions"],
70201
70201
  sourceType: "module"
70202
70202
  };
70203
70203
  return (0, import_parser.parse)(str || "", config4 ? deepMerge2("", defaultConfig, config4) : defaultConfig).program;
@@ -70480,7 +70480,8 @@ function flattenSelections({
70480
70480
  selections,
70481
70481
  fragmentDefinitions,
70482
70482
  ignoreMaskDisable,
70483
- keepFragmentSpreadNodes
70483
+ keepFragmentSpreadNodes,
70484
+ hoistFragments
70484
70485
  }) {
70485
70486
  const fields = new FieldCollection({
70486
70487
  config: config4,
@@ -70488,7 +70489,8 @@ function flattenSelections({
70488
70489
  selections,
70489
70490
  fragmentDefinitions,
70490
70491
  ignoreMaskDisable: !!ignoreMaskDisable,
70491
- keepFragmentSpreadNodes: !!keepFragmentSpreadNodes
70492
+ keepFragmentSpreadNodes: !!keepFragmentSpreadNodes,
70493
+ hoistFragments
70492
70494
  });
70493
70495
  return fields.toSelectionSet();
70494
70496
  }
@@ -70501,6 +70503,7 @@ var FieldCollection = class {
70501
70503
  fragmentSpreads;
70502
70504
  ignoreMaskDisable;
70503
70505
  keepFragmentSpreadNodes;
70506
+ hoistFragments;
70504
70507
  constructor(args) {
70505
70508
  this.config = args.config;
70506
70509
  this.fragmentDefinitions = args.fragmentDefinitions;
@@ -70509,15 +70512,32 @@ var FieldCollection = class {
70509
70512
  this.fields = {};
70510
70513
  this.inlineFragments = {};
70511
70514
  this.fragmentSpreads = {};
70515
+ this.hoistFragments = !!args.hoistFragments;
70512
70516
  this.filepath = args.filepath;
70513
70517
  for (const selection of args.selections) {
70514
- this.add(selection);
70518
+ this.add({ selection });
70515
70519
  }
70516
70520
  }
70517
70521
  get size() {
70518
70522
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
70519
70523
  }
70520
- add(selection) {
70524
+ add({ selection, external }) {
70525
+ let includeFragments = this.config.defaultFragmentMasking === "disable";
70526
+ const maskEnableDirective = selection.directives?.find(
70527
+ ({ name }) => name.value === this.config.maskEnableDirective
70528
+ );
70529
+ if (maskEnableDirective) {
70530
+ includeFragments = false;
70531
+ }
70532
+ const maskDisableDirective = selection.directives?.find(
70533
+ ({ name }) => name.value === this.config.maskDisableDirective
70534
+ );
70535
+ if (maskDisableDirective) {
70536
+ includeFragments = true;
70537
+ }
70538
+ if (this.ignoreMaskDisable) {
70539
+ includeFragments = true;
70540
+ }
70521
70541
  if (selection.kind === "Field") {
70522
70542
  const key = selection.alias?.value || selection.name.value;
70523
70543
  if (!this.fields[key]) {
@@ -70527,41 +70547,30 @@ var FieldCollection = class {
70527
70547
  };
70528
70548
  }
70529
70549
  for (const subselect of selection.selectionSet?.selections || []) {
70530
- this.fields[key].selection.add(subselect);
70550
+ this.fields[key].selection.add({
70551
+ selection: subselect,
70552
+ external
70553
+ });
70554
+ }
70555
+ if (!external && includeFragments) {
70556
+ this.fields[key].selection.fragmentSpreads = {
70557
+ ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
70558
+ ...this.fields[key].selection.fragmentSpreads
70559
+ };
70531
70560
  }
70532
- this.fields[key].selection.fragmentSpreads = {
70533
- ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
70534
- ...this.fields[key].selection.fragmentSpreads
70535
- };
70536
70561
  return;
70537
70562
  }
70538
70563
  if (selection.kind === "InlineFragment" && !selection.typeCondition) {
70539
70564
  for (const subselect of selection.selectionSet.selections) {
70540
- this.add(subselect);
70565
+ this.add({ selection: subselect, external });
70541
70566
  }
70542
70567
  }
70543
70568
  if (selection.kind === "InlineFragment" && selection.typeCondition) {
70544
- this.walkInlineFragment(selection);
70569
+ this.walkInlineFragment({ selection, external, hoistFragments: this.hoistFragments });
70545
70570
  return;
70546
70571
  }
70547
70572
  if (selection.kind === "FragmentSpread") {
70548
- let includeFragments = this.config.defaultFragmentMasking === "disable";
70549
- const maskEnableDirective = selection.directives?.find(
70550
- ({ name }) => name.value === this.config.maskEnableDirective
70551
- );
70552
- if (maskEnableDirective) {
70553
- includeFragments = false;
70554
- }
70555
- const maskDisableDirective = selection.directives?.find(
70556
- ({ name }) => name.value === this.config.maskDisableDirective
70557
- );
70558
- if (maskDisableDirective) {
70559
- includeFragments = true;
70560
- }
70561
- if (this.ignoreMaskDisable) {
70562
- includeFragments = true;
70563
- }
70564
- if (this.keepFragmentSpreadNodes) {
70573
+ if (this.keepFragmentSpreadNodes && !external) {
70565
70574
  this.fragmentSpreads[selection.name.value] = selection;
70566
70575
  }
70567
70576
  if (!includeFragments) {
@@ -70575,18 +70584,21 @@ var FieldCollection = class {
70575
70584
  });
70576
70585
  }
70577
70586
  this.add({
70578
- kind: "InlineFragment",
70579
- typeCondition: {
70580
- kind: "NamedType",
70581
- name: {
70582
- kind: "Name",
70583
- value: definition.typeCondition.name.value
70587
+ selection: {
70588
+ kind: "InlineFragment",
70589
+ typeCondition: {
70590
+ kind: "NamedType",
70591
+ name: {
70592
+ kind: "Name",
70593
+ value: definition.typeCondition.name.value
70594
+ }
70595
+ },
70596
+ selectionSet: {
70597
+ kind: "SelectionSet",
70598
+ selections: [...definition.selectionSet.selections]
70584
70599
  }
70585
70600
  },
70586
- selectionSet: {
70587
- kind: "SelectionSet",
70588
- selections: [...definition.selectionSet.selections]
70589
- }
70601
+ external
70590
70602
  });
70591
70603
  }
70592
70604
  }
@@ -70642,7 +70654,11 @@ var FieldCollection = class {
70642
70654
  })
70643
70655
  );
70644
70656
  }
70645
- walkInlineFragment(selection) {
70657
+ walkInlineFragment({
70658
+ selection,
70659
+ external,
70660
+ hoistFragments
70661
+ }) {
70646
70662
  const key = selection.typeCondition.name.value;
70647
70663
  if (!this.inlineFragments[key]) {
70648
70664
  this.inlineFragments[key] = {
@@ -70651,11 +70667,21 @@ var FieldCollection = class {
70651
70667
  };
70652
70668
  }
70653
70669
  for (const subselect of selection.selectionSet.selections || []) {
70654
- if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
70655
- this.inlineFragments[key].selection.add(subselect);
70670
+ if (subselect.kind === "FragmentSpread" && !hoistFragments || subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
70671
+ this.inlineFragments[key].selection.add({
70672
+ selection: subselect,
70673
+ external
70674
+ });
70656
70675
  continue;
70676
+ } else if (subselect.kind === "FragmentSpread") {
70677
+ this.add({
70678
+ selection: subselect,
70679
+ external: true
70680
+ });
70681
+ continue;
70682
+ } else {
70683
+ this.walkInlineFragment({ selection: subselect, external, hoistFragments });
70657
70684
  }
70658
- this.walkInlineFragment(subselect);
70659
70685
  }
70660
70686
  }
70661
70687
  empty() {
@@ -70665,7 +70691,8 @@ var FieldCollection = class {
70665
70691
  selections: [],
70666
70692
  filepath: this.filepath,
70667
70693
  ignoreMaskDisable: this.ignoreMaskDisable,
70668
- keepFragmentSpreadNodes: this.keepFragmentSpreadNodes
70694
+ keepFragmentSpreadNodes: this.keepFragmentSpreadNodes,
70695
+ hoistFragments: this.hoistFragments
70669
70696
  });
70670
70697
  }
70671
70698
  };
@@ -73116,7 +73143,8 @@ function artifactGenerator(stats) {
73116
73143
  selections: selectionSet.selections,
73117
73144
  fragmentDefinitions,
73118
73145
  ignoreMaskDisable: docKind !== "HoudiniFragment",
73119
- keepFragmentSpreadNodes: true
73146
+ keepFragmentSpreadNodes: true,
73147
+ hoistFragments: true
73120
73148
  }),
73121
73149
  operations: operationsByPath(
73122
73150
  config4,
@@ -70191,7 +70191,7 @@ function deepMerge2(filepath, ...targets) {
70191
70191
  // src/lib/parse.ts
70192
70192
  async function parseJS(str, config4) {
70193
70193
  const defaultConfig = {
70194
- plugins: ["typescript", "importAssertions", "jsx"],
70194
+ plugins: ["typescript", "importAssertions"],
70195
70195
  sourceType: "module"
70196
70196
  };
70197
70197
  return (0, import_parser.parse)(str || "", config4 ? deepMerge2("", defaultConfig, config4) : defaultConfig).program;
@@ -70474,7 +70474,8 @@ function flattenSelections({
70474
70474
  selections,
70475
70475
  fragmentDefinitions,
70476
70476
  ignoreMaskDisable,
70477
- keepFragmentSpreadNodes
70477
+ keepFragmentSpreadNodes,
70478
+ hoistFragments
70478
70479
  }) {
70479
70480
  const fields = new FieldCollection({
70480
70481
  config: config4,
@@ -70482,7 +70483,8 @@ function flattenSelections({
70482
70483
  selections,
70483
70484
  fragmentDefinitions,
70484
70485
  ignoreMaskDisable: !!ignoreMaskDisable,
70485
- keepFragmentSpreadNodes: !!keepFragmentSpreadNodes
70486
+ keepFragmentSpreadNodes: !!keepFragmentSpreadNodes,
70487
+ hoistFragments
70486
70488
  });
70487
70489
  return fields.toSelectionSet();
70488
70490
  }
@@ -70495,6 +70497,7 @@ var FieldCollection = class {
70495
70497
  fragmentSpreads;
70496
70498
  ignoreMaskDisable;
70497
70499
  keepFragmentSpreadNodes;
70500
+ hoistFragments;
70498
70501
  constructor(args) {
70499
70502
  this.config = args.config;
70500
70503
  this.fragmentDefinitions = args.fragmentDefinitions;
@@ -70503,15 +70506,32 @@ var FieldCollection = class {
70503
70506
  this.fields = {};
70504
70507
  this.inlineFragments = {};
70505
70508
  this.fragmentSpreads = {};
70509
+ this.hoistFragments = !!args.hoistFragments;
70506
70510
  this.filepath = args.filepath;
70507
70511
  for (const selection of args.selections) {
70508
- this.add(selection);
70512
+ this.add({ selection });
70509
70513
  }
70510
70514
  }
70511
70515
  get size() {
70512
70516
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
70513
70517
  }
70514
- add(selection) {
70518
+ add({ selection, external }) {
70519
+ let includeFragments = this.config.defaultFragmentMasking === "disable";
70520
+ const maskEnableDirective = selection.directives?.find(
70521
+ ({ name }) => name.value === this.config.maskEnableDirective
70522
+ );
70523
+ if (maskEnableDirective) {
70524
+ includeFragments = false;
70525
+ }
70526
+ const maskDisableDirective = selection.directives?.find(
70527
+ ({ name }) => name.value === this.config.maskDisableDirective
70528
+ );
70529
+ if (maskDisableDirective) {
70530
+ includeFragments = true;
70531
+ }
70532
+ if (this.ignoreMaskDisable) {
70533
+ includeFragments = true;
70534
+ }
70515
70535
  if (selection.kind === "Field") {
70516
70536
  const key = selection.alias?.value || selection.name.value;
70517
70537
  if (!this.fields[key]) {
@@ -70521,41 +70541,30 @@ var FieldCollection = class {
70521
70541
  };
70522
70542
  }
70523
70543
  for (const subselect of selection.selectionSet?.selections || []) {
70524
- this.fields[key].selection.add(subselect);
70544
+ this.fields[key].selection.add({
70545
+ selection: subselect,
70546
+ external
70547
+ });
70548
+ }
70549
+ if (!external && includeFragments) {
70550
+ this.fields[key].selection.fragmentSpreads = {
70551
+ ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
70552
+ ...this.fields[key].selection.fragmentSpreads
70553
+ };
70525
70554
  }
70526
- this.fields[key].selection.fragmentSpreads = {
70527
- ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
70528
- ...this.fields[key].selection.fragmentSpreads
70529
- };
70530
70555
  return;
70531
70556
  }
70532
70557
  if (selection.kind === "InlineFragment" && !selection.typeCondition) {
70533
70558
  for (const subselect of selection.selectionSet.selections) {
70534
- this.add(subselect);
70559
+ this.add({ selection: subselect, external });
70535
70560
  }
70536
70561
  }
70537
70562
  if (selection.kind === "InlineFragment" && selection.typeCondition) {
70538
- this.walkInlineFragment(selection);
70563
+ this.walkInlineFragment({ selection, external, hoistFragments: this.hoistFragments });
70539
70564
  return;
70540
70565
  }
70541
70566
  if (selection.kind === "FragmentSpread") {
70542
- let includeFragments = this.config.defaultFragmentMasking === "disable";
70543
- const maskEnableDirective = selection.directives?.find(
70544
- ({ name }) => name.value === this.config.maskEnableDirective
70545
- );
70546
- if (maskEnableDirective) {
70547
- includeFragments = false;
70548
- }
70549
- const maskDisableDirective = selection.directives?.find(
70550
- ({ name }) => name.value === this.config.maskDisableDirective
70551
- );
70552
- if (maskDisableDirective) {
70553
- includeFragments = true;
70554
- }
70555
- if (this.ignoreMaskDisable) {
70556
- includeFragments = true;
70557
- }
70558
- if (this.keepFragmentSpreadNodes) {
70567
+ if (this.keepFragmentSpreadNodes && !external) {
70559
70568
  this.fragmentSpreads[selection.name.value] = selection;
70560
70569
  }
70561
70570
  if (!includeFragments) {
@@ -70569,18 +70578,21 @@ var FieldCollection = class {
70569
70578
  });
70570
70579
  }
70571
70580
  this.add({
70572
- kind: "InlineFragment",
70573
- typeCondition: {
70574
- kind: "NamedType",
70575
- name: {
70576
- kind: "Name",
70577
- value: definition.typeCondition.name.value
70581
+ selection: {
70582
+ kind: "InlineFragment",
70583
+ typeCondition: {
70584
+ kind: "NamedType",
70585
+ name: {
70586
+ kind: "Name",
70587
+ value: definition.typeCondition.name.value
70588
+ }
70589
+ },
70590
+ selectionSet: {
70591
+ kind: "SelectionSet",
70592
+ selections: [...definition.selectionSet.selections]
70578
70593
  }
70579
70594
  },
70580
- selectionSet: {
70581
- kind: "SelectionSet",
70582
- selections: [...definition.selectionSet.selections]
70583
- }
70595
+ external
70584
70596
  });
70585
70597
  }
70586
70598
  }
@@ -70636,7 +70648,11 @@ var FieldCollection = class {
70636
70648
  })
70637
70649
  );
70638
70650
  }
70639
- walkInlineFragment(selection) {
70651
+ walkInlineFragment({
70652
+ selection,
70653
+ external,
70654
+ hoistFragments
70655
+ }) {
70640
70656
  const key = selection.typeCondition.name.value;
70641
70657
  if (!this.inlineFragments[key]) {
70642
70658
  this.inlineFragments[key] = {
@@ -70645,11 +70661,21 @@ var FieldCollection = class {
70645
70661
  };
70646
70662
  }
70647
70663
  for (const subselect of selection.selectionSet.selections || []) {
70648
- if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
70649
- this.inlineFragments[key].selection.add(subselect);
70664
+ if (subselect.kind === "FragmentSpread" && !hoistFragments || subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
70665
+ this.inlineFragments[key].selection.add({
70666
+ selection: subselect,
70667
+ external
70668
+ });
70650
70669
  continue;
70670
+ } else if (subselect.kind === "FragmentSpread") {
70671
+ this.add({
70672
+ selection: subselect,
70673
+ external: true
70674
+ });
70675
+ continue;
70676
+ } else {
70677
+ this.walkInlineFragment({ selection: subselect, external, hoistFragments });
70651
70678
  }
70652
- this.walkInlineFragment(subselect);
70653
70679
  }
70654
70680
  }
70655
70681
  empty() {
@@ -70659,7 +70685,8 @@ var FieldCollection = class {
70659
70685
  selections: [],
70660
70686
  filepath: this.filepath,
70661
70687
  ignoreMaskDisable: this.ignoreMaskDisable,
70662
- keepFragmentSpreadNodes: this.keepFragmentSpreadNodes
70688
+ keepFragmentSpreadNodes: this.keepFragmentSpreadNodes,
70689
+ hoistFragments: this.hoistFragments
70663
70690
  });
70664
70691
  }
70665
70692
  };
@@ -73110,7 +73137,8 @@ function artifactGenerator(stats) {
73110
73137
  selections: selectionSet.selections,
73111
73138
  fragmentDefinitions,
73112
73139
  ignoreMaskDisable: docKind !== "HoudiniFragment",
73113
- keepFragmentSpreadNodes: true
73140
+ keepFragmentSpreadNodes: true,
73141
+ hoistFragments: true
73114
73142
  }),
73115
73143
  operations: operationsByPath(
73116
73144
  config4,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",