houdini 1.2.0 → 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.
@@ -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;
@@ -70479,16 +70479,14 @@ function flattenSelections({
70479
70479
  filepath,
70480
70480
  selections,
70481
70481
  fragmentDefinitions,
70482
- ignoreMaskDisable,
70483
- keepFragmentSpreadNodes
70482
+ applyFragments
70484
70483
  }) {
70485
70484
  const fields = new FieldCollection({
70486
70485
  config: config4,
70487
70486
  filepath,
70488
70487
  selections,
70489
70488
  fragmentDefinitions,
70490
- ignoreMaskDisable: !!ignoreMaskDisable,
70491
- keepFragmentSpreadNodes: !!keepFragmentSpreadNodes
70489
+ applyFragments: !!applyFragments
70492
70490
  });
70493
70491
  return fields.toSelectionSet();
70494
70492
  }
@@ -70499,25 +70497,36 @@ var FieldCollection = class {
70499
70497
  fields;
70500
70498
  inlineFragments;
70501
70499
  fragmentSpreads;
70502
- ignoreMaskDisable;
70503
- keepFragmentSpreadNodes;
70500
+ applyFragments;
70504
70501
  constructor(args) {
70505
70502
  this.config = args.config;
70506
70503
  this.fragmentDefinitions = args.fragmentDefinitions;
70507
- this.ignoreMaskDisable = args.ignoreMaskDisable;
70508
- this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
70504
+ this.applyFragments = args.applyFragments;
70509
70505
  this.fields = {};
70510
70506
  this.inlineFragments = {};
70511
70507
  this.fragmentSpreads = {};
70512
70508
  this.filepath = args.filepath;
70513
70509
  for (const selection of args.selections) {
70514
- this.add(selection);
70510
+ this.add({ selection });
70515
70511
  }
70516
70512
  }
70517
70513
  get size() {
70518
70514
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
70519
70515
  }
70520
- add(selection) {
70516
+ add({ selection, external }) {
70517
+ let include = this.config.defaultFragmentMasking === "disable";
70518
+ const maskEnableDirective = selection.directives?.find(
70519
+ ({ name }) => name.value === this.config.maskEnableDirective
70520
+ );
70521
+ if (maskEnableDirective) {
70522
+ include = false;
70523
+ }
70524
+ const maskDisableDirective = selection.directives?.find(
70525
+ ({ name }) => name.value === this.config.maskDisableDirective
70526
+ );
70527
+ if (maskDisableDirective) {
70528
+ include = true;
70529
+ }
70521
70530
  if (selection.kind === "Field") {
70522
70531
  const key = selection.alias?.value || selection.name.value;
70523
70532
  if (!this.fields[key]) {
@@ -70527,46 +70536,32 @@ var FieldCollection = class {
70527
70536
  };
70528
70537
  }
70529
70538
  for (const subselect of selection.selectionSet?.selections || []) {
70530
- this.fields[key].selection.add(subselect);
70539
+ this.fields[key].selection.add({
70540
+ selection: subselect,
70541
+ external
70542
+ });
70543
+ }
70544
+ if (this.applyFragments && !external) {
70545
+ this.fields[key].selection.fragmentSpreads = {
70546
+ ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
70547
+ ...this.fields[key].selection.fragmentSpreads
70548
+ };
70531
70549
  }
70532
- this.fields[key].selection.fragmentSpreads = {
70533
- ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
70534
- ...this.fields[key].selection.fragmentSpreads
70535
- };
70536
70550
  return;
70537
70551
  }
70538
70552
  if (selection.kind === "InlineFragment" && !selection.typeCondition) {
70539
70553
  for (const subselect of selection.selectionSet.selections) {
70540
- this.add(subselect);
70554
+ this.add({ selection: subselect, external });
70541
70555
  }
70542
70556
  }
70543
70557
  if (selection.kind === "InlineFragment" && selection.typeCondition) {
70544
- this.walkInlineFragment(selection);
70558
+ this.walkInlineFragment({ selection, external });
70545
70559
  return;
70546
70560
  }
70547
70561
  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) {
70562
+ if (!external || include) {
70565
70563
  this.fragmentSpreads[selection.name.value] = selection;
70566
70564
  }
70567
- if (!includeFragments) {
70568
- return;
70569
- }
70570
70565
  const definition = this.fragmentDefinitions[selection.name.value];
70571
70566
  if (!definition) {
70572
70567
  throw new HoudiniError({
@@ -70574,20 +70569,25 @@ var FieldCollection = class {
70574
70569
  message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
70575
70570
  });
70576
70571
  }
70577
- this.add({
70578
- kind: "InlineFragment",
70579
- typeCondition: {
70580
- kind: "NamedType",
70581
- name: {
70582
- kind: "Name",
70583
- value: definition.typeCondition.name.value
70584
- }
70585
- },
70586
- selectionSet: {
70587
- kind: "SelectionSet",
70588
- selections: [...definition.selectionSet.selections]
70589
- }
70590
- });
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]
70586
+ }
70587
+ },
70588
+ external: !include
70589
+ });
70590
+ }
70591
70591
  }
70592
70592
  }
70593
70593
  collectFragmentSpreads(selections, result = {}) {
@@ -70642,7 +70642,10 @@ var FieldCollection = class {
70642
70642
  })
70643
70643
  );
70644
70644
  }
70645
- walkInlineFragment(selection) {
70645
+ walkInlineFragment({
70646
+ selection,
70647
+ external
70648
+ }) {
70646
70649
  const key = selection.typeCondition.name.value;
70647
70650
  if (!this.inlineFragments[key]) {
70648
70651
  this.inlineFragments[key] = {
@@ -70651,11 +70654,21 @@ var FieldCollection = class {
70651
70654
  };
70652
70655
  }
70653
70656
  for (const subselect of selection.selectionSet.selections || []) {
70654
- if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
70655
- this.inlineFragments[key].selection.add(subselect);
70657
+ if (subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
70658
+ this.inlineFragments[key].selection.add({
70659
+ selection: subselect,
70660
+ external
70661
+ });
70662
+ continue;
70663
+ } else if (subselect.kind === "FragmentSpread") {
70664
+ this.add({
70665
+ selection: subselect,
70666
+ external
70667
+ });
70656
70668
  continue;
70669
+ } else {
70670
+ this.walkInlineFragment({ selection: subselect, external });
70657
70671
  }
70658
- this.walkInlineFragment(subselect);
70659
70672
  }
70660
70673
  }
70661
70674
  empty() {
@@ -70664,8 +70677,7 @@ var FieldCollection = class {
70664
70677
  fragmentDefinitions: this.fragmentDefinitions,
70665
70678
  selections: [],
70666
70679
  filepath: this.filepath,
70667
- ignoreMaskDisable: this.ignoreMaskDisable,
70668
- keepFragmentSpreadNodes: this.keepFragmentSpreadNodes
70680
+ applyFragments: this.applyFragments
70669
70681
  });
70670
70682
  }
70671
70683
  };
@@ -72591,7 +72603,8 @@ function prepareSelection({
72591
72603
  inConnection,
72592
72604
  typeMap,
72593
72605
  abstractTypes,
72594
- globalLoading
72606
+ globalLoading,
72607
+ includeFragments
72595
72608
  }) {
72596
72609
  let object = {};
72597
72610
  const loadingTypes = [];
@@ -72611,7 +72624,8 @@ function prepareSelection({
72611
72624
  document,
72612
72625
  typeMap,
72613
72626
  abstractTypes,
72614
- globalLoading
72627
+ globalLoading,
72628
+ includeFragments
72615
72629
  }).fields || {}
72616
72630
  );
72617
72631
  } else {
@@ -72659,7 +72673,8 @@ function prepareSelection({
72659
72673
  document,
72660
72674
  typeMap,
72661
72675
  abstractTypes,
72662
- globalLoading
72676
+ globalLoading,
72677
+ includeFragments
72663
72678
  }).fields
72664
72679
  };
72665
72680
  if (field.directives?.find((d) => d.name.value === config4.loadingDirective)) {
@@ -72777,7 +72792,8 @@ function prepareSelection({
72777
72792
  inConnection: connectionState,
72778
72793
  typeMap,
72779
72794
  abstractTypes,
72780
- globalLoading: forceLoading
72795
+ globalLoading: forceLoading,
72796
+ includeFragments
72781
72797
  });
72782
72798
  if (Object.values(fieldObj.selection.fields ?? {}).some((field2) => field2.required)) {
72783
72799
  fieldObj.nullable = true;
@@ -73110,13 +73126,13 @@ function artifactGenerator(stats) {
73110
73126
  document: doc,
73111
73127
  rootType,
73112
73128
  globalLoading,
73129
+ includeFragments: doc.kind !== ArtifactKind.Fragment,
73113
73130
  selections: flattenSelections({
73114
73131
  config: config4,
73115
73132
  filepath: doc.filename,
73116
73133
  selections: selectionSet.selections,
73117
73134
  fragmentDefinitions,
73118
- ignoreMaskDisable: docKind !== "HoudiniFragment",
73119
- keepFragmentSpreadNodes: true
73135
+ applyFragments: doc.kind !== ArtifactKind.Fragment
73120
73136
  }),
73121
73137
  operations: operationsByPath(
73122
73138
  config4,
@@ -74081,8 +74097,7 @@ async function generateDocumentTypes(config4, docs) {
74081
74097
  config: config4,
74082
74098
  filepath: filename,
74083
74099
  selections: definition.selectionSet.selections,
74084
- fragmentDefinitions,
74085
- keepFragmentSpreadNodes: true
74100
+ fragmentDefinitions
74086
74101
  });
74087
74102
  if (definition?.kind === "OperationDefinition") {
74088
74103
  await generateOperationTypeDefs(
@@ -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;
@@ -70473,16 +70473,14 @@ function flattenSelections({
70473
70473
  filepath,
70474
70474
  selections,
70475
70475
  fragmentDefinitions,
70476
- ignoreMaskDisable,
70477
- keepFragmentSpreadNodes
70476
+ applyFragments
70478
70477
  }) {
70479
70478
  const fields = new FieldCollection({
70480
70479
  config: config4,
70481
70480
  filepath,
70482
70481
  selections,
70483
70482
  fragmentDefinitions,
70484
- ignoreMaskDisable: !!ignoreMaskDisable,
70485
- keepFragmentSpreadNodes: !!keepFragmentSpreadNodes
70483
+ applyFragments: !!applyFragments
70486
70484
  });
70487
70485
  return fields.toSelectionSet();
70488
70486
  }
@@ -70493,25 +70491,36 @@ var FieldCollection = class {
70493
70491
  fields;
70494
70492
  inlineFragments;
70495
70493
  fragmentSpreads;
70496
- ignoreMaskDisable;
70497
- keepFragmentSpreadNodes;
70494
+ applyFragments;
70498
70495
  constructor(args) {
70499
70496
  this.config = args.config;
70500
70497
  this.fragmentDefinitions = args.fragmentDefinitions;
70501
- this.ignoreMaskDisable = args.ignoreMaskDisable;
70502
- this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
70498
+ this.applyFragments = args.applyFragments;
70503
70499
  this.fields = {};
70504
70500
  this.inlineFragments = {};
70505
70501
  this.fragmentSpreads = {};
70506
70502
  this.filepath = args.filepath;
70507
70503
  for (const selection of args.selections) {
70508
- this.add(selection);
70504
+ this.add({ selection });
70509
70505
  }
70510
70506
  }
70511
70507
  get size() {
70512
70508
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
70513
70509
  }
70514
- add(selection) {
70510
+ add({ selection, external }) {
70511
+ let include = this.config.defaultFragmentMasking === "disable";
70512
+ const maskEnableDirective = selection.directives?.find(
70513
+ ({ name }) => name.value === this.config.maskEnableDirective
70514
+ );
70515
+ if (maskEnableDirective) {
70516
+ include = false;
70517
+ }
70518
+ const maskDisableDirective = selection.directives?.find(
70519
+ ({ name }) => name.value === this.config.maskDisableDirective
70520
+ );
70521
+ if (maskDisableDirective) {
70522
+ include = true;
70523
+ }
70515
70524
  if (selection.kind === "Field") {
70516
70525
  const key = selection.alias?.value || selection.name.value;
70517
70526
  if (!this.fields[key]) {
@@ -70521,46 +70530,32 @@ var FieldCollection = class {
70521
70530
  };
70522
70531
  }
70523
70532
  for (const subselect of selection.selectionSet?.selections || []) {
70524
- this.fields[key].selection.add(subselect);
70533
+ this.fields[key].selection.add({
70534
+ selection: subselect,
70535
+ external
70536
+ });
70537
+ }
70538
+ if (this.applyFragments && !external) {
70539
+ this.fields[key].selection.fragmentSpreads = {
70540
+ ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
70541
+ ...this.fields[key].selection.fragmentSpreads
70542
+ };
70525
70543
  }
70526
- this.fields[key].selection.fragmentSpreads = {
70527
- ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
70528
- ...this.fields[key].selection.fragmentSpreads
70529
- };
70530
70544
  return;
70531
70545
  }
70532
70546
  if (selection.kind === "InlineFragment" && !selection.typeCondition) {
70533
70547
  for (const subselect of selection.selectionSet.selections) {
70534
- this.add(subselect);
70548
+ this.add({ selection: subselect, external });
70535
70549
  }
70536
70550
  }
70537
70551
  if (selection.kind === "InlineFragment" && selection.typeCondition) {
70538
- this.walkInlineFragment(selection);
70552
+ this.walkInlineFragment({ selection, external });
70539
70553
  return;
70540
70554
  }
70541
70555
  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) {
70556
+ if (!external || include) {
70559
70557
  this.fragmentSpreads[selection.name.value] = selection;
70560
70558
  }
70561
- if (!includeFragments) {
70562
- return;
70563
- }
70564
70559
  const definition = this.fragmentDefinitions[selection.name.value];
70565
70560
  if (!definition) {
70566
70561
  throw new HoudiniError({
@@ -70568,20 +70563,25 @@ var FieldCollection = class {
70568
70563
  message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
70569
70564
  });
70570
70565
  }
70571
- this.add({
70572
- kind: "InlineFragment",
70573
- typeCondition: {
70574
- kind: "NamedType",
70575
- name: {
70576
- kind: "Name",
70577
- value: definition.typeCondition.name.value
70578
- }
70579
- },
70580
- selectionSet: {
70581
- kind: "SelectionSet",
70582
- selections: [...definition.selectionSet.selections]
70583
- }
70584
- });
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]
70580
+ }
70581
+ },
70582
+ external: !include
70583
+ });
70584
+ }
70585
70585
  }
70586
70586
  }
70587
70587
  collectFragmentSpreads(selections, result = {}) {
@@ -70636,7 +70636,10 @@ var FieldCollection = class {
70636
70636
  })
70637
70637
  );
70638
70638
  }
70639
- walkInlineFragment(selection) {
70639
+ walkInlineFragment({
70640
+ selection,
70641
+ external
70642
+ }) {
70640
70643
  const key = selection.typeCondition.name.value;
70641
70644
  if (!this.inlineFragments[key]) {
70642
70645
  this.inlineFragments[key] = {
@@ -70645,11 +70648,21 @@ var FieldCollection = class {
70645
70648
  };
70646
70649
  }
70647
70650
  for (const subselect of selection.selectionSet.selections || []) {
70648
- if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
70649
- this.inlineFragments[key].selection.add(subselect);
70651
+ if (subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
70652
+ this.inlineFragments[key].selection.add({
70653
+ selection: subselect,
70654
+ external
70655
+ });
70656
+ continue;
70657
+ } else if (subselect.kind === "FragmentSpread") {
70658
+ this.add({
70659
+ selection: subselect,
70660
+ external
70661
+ });
70650
70662
  continue;
70663
+ } else {
70664
+ this.walkInlineFragment({ selection: subselect, external });
70651
70665
  }
70652
- this.walkInlineFragment(subselect);
70653
70666
  }
70654
70667
  }
70655
70668
  empty() {
@@ -70658,8 +70671,7 @@ var FieldCollection = class {
70658
70671
  fragmentDefinitions: this.fragmentDefinitions,
70659
70672
  selections: [],
70660
70673
  filepath: this.filepath,
70661
- ignoreMaskDisable: this.ignoreMaskDisable,
70662
- keepFragmentSpreadNodes: this.keepFragmentSpreadNodes
70674
+ applyFragments: this.applyFragments
70663
70675
  });
70664
70676
  }
70665
70677
  };
@@ -72585,7 +72597,8 @@ function prepareSelection({
72585
72597
  inConnection,
72586
72598
  typeMap,
72587
72599
  abstractTypes,
72588
- globalLoading
72600
+ globalLoading,
72601
+ includeFragments
72589
72602
  }) {
72590
72603
  let object = {};
72591
72604
  const loadingTypes = [];
@@ -72605,7 +72618,8 @@ function prepareSelection({
72605
72618
  document,
72606
72619
  typeMap,
72607
72620
  abstractTypes,
72608
- globalLoading
72621
+ globalLoading,
72622
+ includeFragments
72609
72623
  }).fields || {}
72610
72624
  );
72611
72625
  } else {
@@ -72653,7 +72667,8 @@ function prepareSelection({
72653
72667
  document,
72654
72668
  typeMap,
72655
72669
  abstractTypes,
72656
- globalLoading
72670
+ globalLoading,
72671
+ includeFragments
72657
72672
  }).fields
72658
72673
  };
72659
72674
  if (field.directives?.find((d) => d.name.value === config4.loadingDirective)) {
@@ -72771,7 +72786,8 @@ function prepareSelection({
72771
72786
  inConnection: connectionState,
72772
72787
  typeMap,
72773
72788
  abstractTypes,
72774
- globalLoading: forceLoading
72789
+ globalLoading: forceLoading,
72790
+ includeFragments
72775
72791
  });
72776
72792
  if (Object.values(fieldObj.selection.fields ?? {}).some((field2) => field2.required)) {
72777
72793
  fieldObj.nullable = true;
@@ -73104,13 +73120,13 @@ function artifactGenerator(stats) {
73104
73120
  document: doc,
73105
73121
  rootType,
73106
73122
  globalLoading,
73123
+ includeFragments: doc.kind !== ArtifactKind.Fragment,
73107
73124
  selections: flattenSelections({
73108
73125
  config: config4,
73109
73126
  filepath: doc.filename,
73110
73127
  selections: selectionSet.selections,
73111
73128
  fragmentDefinitions,
73112
- ignoreMaskDisable: docKind !== "HoudiniFragment",
73113
- keepFragmentSpreadNodes: true
73129
+ applyFragments: doc.kind !== ArtifactKind.Fragment
73114
73130
  }),
73115
73131
  operations: operationsByPath(
73116
73132
  config4,
@@ -74075,8 +74091,7 @@ async function generateDocumentTypes(config4, docs) {
74075
74091
  config: config4,
74076
74092
  filepath: filename,
74077
74093
  selections: definition.selectionSet.selections,
74078
- fragmentDefinitions,
74079
- keepFragmentSpreadNodes: true
74094
+ fragmentDefinitions
74080
74095
  });
74081
74096
  if (definition?.kind === "OperationDefinition") {
74082
74097
  await generateOperationTypeDefs(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",