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.
@@ -57592,7 +57592,7 @@ function deepMerge2(filepath, ...targets) {
57592
57592
  // src/lib/parse.ts
57593
57593
  async function parseJS(str, config2) {
57594
57594
  const defaultConfig = {
57595
- plugins: ["typescript", "importAssertions", "jsx"],
57595
+ plugins: ["typescript", "importAssertions"],
57596
57596
  sourceType: "module"
57597
57597
  };
57598
57598
  return (0, import_parser.parse)(str || "", config2 ? deepMerge2("", defaultConfig, config2) : defaultConfig).program;
@@ -57690,16 +57690,14 @@ function flattenSelections({
57690
57690
  filepath,
57691
57691
  selections,
57692
57692
  fragmentDefinitions,
57693
- ignoreMaskDisable,
57694
- keepFragmentSpreadNodes
57693
+ applyFragments
57695
57694
  }) {
57696
57695
  const fields = new FieldCollection({
57697
57696
  config: config2,
57698
57697
  filepath,
57699
57698
  selections,
57700
57699
  fragmentDefinitions,
57701
- ignoreMaskDisable: !!ignoreMaskDisable,
57702
- keepFragmentSpreadNodes: !!keepFragmentSpreadNodes
57700
+ applyFragments: !!applyFragments
57703
57701
  });
57704
57702
  return fields.toSelectionSet();
57705
57703
  }
@@ -57710,25 +57708,36 @@ var FieldCollection = class {
57710
57708
  fields;
57711
57709
  inlineFragments;
57712
57710
  fragmentSpreads;
57713
- ignoreMaskDisable;
57714
- keepFragmentSpreadNodes;
57711
+ applyFragments;
57715
57712
  constructor(args) {
57716
57713
  this.config = args.config;
57717
57714
  this.fragmentDefinitions = args.fragmentDefinitions;
57718
- this.ignoreMaskDisable = args.ignoreMaskDisable;
57719
- this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
57715
+ this.applyFragments = args.applyFragments;
57720
57716
  this.fields = {};
57721
57717
  this.inlineFragments = {};
57722
57718
  this.fragmentSpreads = {};
57723
57719
  this.filepath = args.filepath;
57724
57720
  for (const selection of args.selections) {
57725
- this.add(selection);
57721
+ this.add({ selection });
57726
57722
  }
57727
57723
  }
57728
57724
  get size() {
57729
57725
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
57730
57726
  }
57731
- add(selection) {
57727
+ add({ selection, external }) {
57728
+ let include = this.config.defaultFragmentMasking === "disable";
57729
+ const maskEnableDirective = selection.directives?.find(
57730
+ ({ name }) => name.value === this.config.maskEnableDirective
57731
+ );
57732
+ if (maskEnableDirective) {
57733
+ include = false;
57734
+ }
57735
+ const maskDisableDirective = selection.directives?.find(
57736
+ ({ name }) => name.value === this.config.maskDisableDirective
57737
+ );
57738
+ if (maskDisableDirective) {
57739
+ include = true;
57740
+ }
57732
57741
  if (selection.kind === "Field") {
57733
57742
  const key = selection.alias?.value || selection.name.value;
57734
57743
  if (!this.fields[key]) {
@@ -57738,46 +57747,32 @@ var FieldCollection = class {
57738
57747
  };
57739
57748
  }
57740
57749
  for (const subselect of selection.selectionSet?.selections || []) {
57741
- this.fields[key].selection.add(subselect);
57750
+ this.fields[key].selection.add({
57751
+ selection: subselect,
57752
+ external
57753
+ });
57754
+ }
57755
+ if (this.applyFragments && !external) {
57756
+ this.fields[key].selection.fragmentSpreads = {
57757
+ ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
57758
+ ...this.fields[key].selection.fragmentSpreads
57759
+ };
57742
57760
  }
57743
- this.fields[key].selection.fragmentSpreads = {
57744
- ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
57745
- ...this.fields[key].selection.fragmentSpreads
57746
- };
57747
57761
  return;
57748
57762
  }
57749
57763
  if (selection.kind === "InlineFragment" && !selection.typeCondition) {
57750
57764
  for (const subselect of selection.selectionSet.selections) {
57751
- this.add(subselect);
57765
+ this.add({ selection: subselect, external });
57752
57766
  }
57753
57767
  }
57754
57768
  if (selection.kind === "InlineFragment" && selection.typeCondition) {
57755
- this.walkInlineFragment(selection);
57769
+ this.walkInlineFragment({ selection, external });
57756
57770
  return;
57757
57771
  }
57758
57772
  if (selection.kind === "FragmentSpread") {
57759
- let includeFragments = this.config.defaultFragmentMasking === "disable";
57760
- const maskEnableDirective = selection.directives?.find(
57761
- ({ name }) => name.value === this.config.maskEnableDirective
57762
- );
57763
- if (maskEnableDirective) {
57764
- includeFragments = false;
57765
- }
57766
- const maskDisableDirective = selection.directives?.find(
57767
- ({ name }) => name.value === this.config.maskDisableDirective
57768
- );
57769
- if (maskDisableDirective) {
57770
- includeFragments = true;
57771
- }
57772
- if (this.ignoreMaskDisable) {
57773
- includeFragments = true;
57774
- }
57775
- if (this.keepFragmentSpreadNodes) {
57773
+ if (!external || include) {
57776
57774
  this.fragmentSpreads[selection.name.value] = selection;
57777
57775
  }
57778
- if (!includeFragments) {
57779
- return;
57780
- }
57781
57776
  const definition = this.fragmentDefinitions[selection.name.value];
57782
57777
  if (!definition) {
57783
57778
  throw new HoudiniError({
@@ -57785,20 +57780,25 @@ var FieldCollection = class {
57785
57780
  message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
57786
57781
  });
57787
57782
  }
57788
- this.add({
57789
- kind: "InlineFragment",
57790
- typeCondition: {
57791
- kind: "NamedType",
57792
- name: {
57793
- kind: "Name",
57794
- value: definition.typeCondition.name.value
57795
- }
57796
- },
57797
- selectionSet: {
57798
- kind: "SelectionSet",
57799
- selections: [...definition.selectionSet.selections]
57800
- }
57801
- });
57783
+ if (this.applyFragments || include) {
57784
+ this.add({
57785
+ selection: {
57786
+ kind: "InlineFragment",
57787
+ typeCondition: {
57788
+ kind: "NamedType",
57789
+ name: {
57790
+ kind: "Name",
57791
+ value: definition.typeCondition.name.value
57792
+ }
57793
+ },
57794
+ selectionSet: {
57795
+ kind: "SelectionSet",
57796
+ selections: [...definition.selectionSet.selections]
57797
+ }
57798
+ },
57799
+ external: !include
57800
+ });
57801
+ }
57802
57802
  }
57803
57803
  }
57804
57804
  collectFragmentSpreads(selections, result = {}) {
@@ -57853,7 +57853,10 @@ var FieldCollection = class {
57853
57853
  })
57854
57854
  );
57855
57855
  }
57856
- walkInlineFragment(selection) {
57856
+ walkInlineFragment({
57857
+ selection,
57858
+ external
57859
+ }) {
57857
57860
  const key = selection.typeCondition.name.value;
57858
57861
  if (!this.inlineFragments[key]) {
57859
57862
  this.inlineFragments[key] = {
@@ -57862,11 +57865,21 @@ var FieldCollection = class {
57862
57865
  };
57863
57866
  }
57864
57867
  for (const subselect of selection.selectionSet.selections || []) {
57865
- if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
57866
- this.inlineFragments[key].selection.add(subselect);
57868
+ if (subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
57869
+ this.inlineFragments[key].selection.add({
57870
+ selection: subselect,
57871
+ external
57872
+ });
57867
57873
  continue;
57874
+ } else if (subselect.kind === "FragmentSpread") {
57875
+ this.add({
57876
+ selection: subselect,
57877
+ external
57878
+ });
57879
+ continue;
57880
+ } else {
57881
+ this.walkInlineFragment({ selection: subselect, external });
57868
57882
  }
57869
- this.walkInlineFragment(subselect);
57870
57883
  }
57871
57884
  }
57872
57885
  empty() {
@@ -57875,8 +57888,7 @@ var FieldCollection = class {
57875
57888
  fragmentDefinitions: this.fragmentDefinitions,
57876
57889
  selections: [],
57877
57890
  filepath: this.filepath,
57878
- ignoreMaskDisable: this.ignoreMaskDisable,
57879
- keepFragmentSpreadNodes: this.keepFragmentSpreadNodes
57891
+ applyFragments: this.applyFragments
57880
57892
  });
57881
57893
  }
57882
57894
  };
@@ -59796,7 +59808,8 @@ function prepareSelection({
59796
59808
  inConnection,
59797
59809
  typeMap,
59798
59810
  abstractTypes,
59799
- globalLoading
59811
+ globalLoading,
59812
+ includeFragments
59800
59813
  }) {
59801
59814
  let object = {};
59802
59815
  const loadingTypes = [];
@@ -59816,7 +59829,8 @@ function prepareSelection({
59816
59829
  document,
59817
59830
  typeMap,
59818
59831
  abstractTypes,
59819
- globalLoading
59832
+ globalLoading,
59833
+ includeFragments
59820
59834
  }).fields || {}
59821
59835
  );
59822
59836
  } else {
@@ -59864,7 +59878,8 @@ function prepareSelection({
59864
59878
  document,
59865
59879
  typeMap,
59866
59880
  abstractTypes,
59867
- globalLoading
59881
+ globalLoading,
59882
+ includeFragments
59868
59883
  }).fields
59869
59884
  };
59870
59885
  if (field.directives?.find((d) => d.name.value === config2.loadingDirective)) {
@@ -59982,7 +59997,8 @@ function prepareSelection({
59982
59997
  inConnection: connectionState,
59983
59998
  typeMap,
59984
59999
  abstractTypes,
59985
- globalLoading: forceLoading
60000
+ globalLoading: forceLoading,
60001
+ includeFragments
59986
60002
  });
59987
60003
  if (Object.values(fieldObj.selection.fields ?? {}).some((field2) => field2.required)) {
59988
60004
  fieldObj.nullable = true;
@@ -60315,13 +60331,13 @@ function artifactGenerator(stats) {
60315
60331
  document: doc,
60316
60332
  rootType,
60317
60333
  globalLoading,
60334
+ includeFragments: doc.kind !== ArtifactKind.Fragment,
60318
60335
  selections: flattenSelections({
60319
60336
  config: config2,
60320
60337
  filepath: doc.filename,
60321
60338
  selections: selectionSet.selections,
60322
60339
  fragmentDefinitions,
60323
- ignoreMaskDisable: docKind !== "HoudiniFragment",
60324
- keepFragmentSpreadNodes: true
60340
+ applyFragments: doc.kind !== ArtifactKind.Fragment
60325
60341
  }),
60326
60342
  operations: operationsByPath(
60327
60343
  config2,
@@ -61286,8 +61302,7 @@ async function generateDocumentTypes(config2, docs) {
61286
61302
  config: config2,
61287
61303
  filepath: filename,
61288
61304
  selections: definition.selectionSet.selections,
61289
- fragmentDefinitions,
61290
- keepFragmentSpreadNodes: true
61305
+ fragmentDefinitions
61291
61306
  });
61292
61307
  if (definition?.kind === "OperationDefinition") {
61293
61308
  await generateOperationTypeDefs(
@@ -63564,6 +63579,8 @@ function testConfigFile({ plugins, ...config2 } = {}) {
63564
63579
  customIdList: [CustomIdType]!
63565
63580
  nodes(ids: [ID!]!): [Node!]!
63566
63581
  monkeys: MonkeyConnection!
63582
+ animals(first: Int, after: String): AnimalConnection
63583
+
63567
63584
  }
63568
63585
 
63569
63586
  input UserFilter {
@@ -57587,7 +57587,7 @@ function deepMerge2(filepath, ...targets) {
57587
57587
  // src/lib/parse.ts
57588
57588
  async function parseJS(str, config2) {
57589
57589
  const defaultConfig = {
57590
- plugins: ["typescript", "importAssertions", "jsx"],
57590
+ plugins: ["typescript", "importAssertions"],
57591
57591
  sourceType: "module"
57592
57592
  };
57593
57593
  return (0, import_parser.parse)(str || "", config2 ? deepMerge2("", defaultConfig, config2) : defaultConfig).program;
@@ -57685,16 +57685,14 @@ function flattenSelections({
57685
57685
  filepath,
57686
57686
  selections,
57687
57687
  fragmentDefinitions,
57688
- ignoreMaskDisable,
57689
- keepFragmentSpreadNodes
57688
+ applyFragments
57690
57689
  }) {
57691
57690
  const fields = new FieldCollection({
57692
57691
  config: config2,
57693
57692
  filepath,
57694
57693
  selections,
57695
57694
  fragmentDefinitions,
57696
- ignoreMaskDisable: !!ignoreMaskDisable,
57697
- keepFragmentSpreadNodes: !!keepFragmentSpreadNodes
57695
+ applyFragments: !!applyFragments
57698
57696
  });
57699
57697
  return fields.toSelectionSet();
57700
57698
  }
@@ -57705,25 +57703,36 @@ var FieldCollection = class {
57705
57703
  fields;
57706
57704
  inlineFragments;
57707
57705
  fragmentSpreads;
57708
- ignoreMaskDisable;
57709
- keepFragmentSpreadNodes;
57706
+ applyFragments;
57710
57707
  constructor(args) {
57711
57708
  this.config = args.config;
57712
57709
  this.fragmentDefinitions = args.fragmentDefinitions;
57713
- this.ignoreMaskDisable = args.ignoreMaskDisable;
57714
- this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
57710
+ this.applyFragments = args.applyFragments;
57715
57711
  this.fields = {};
57716
57712
  this.inlineFragments = {};
57717
57713
  this.fragmentSpreads = {};
57718
57714
  this.filepath = args.filepath;
57719
57715
  for (const selection of args.selections) {
57720
- this.add(selection);
57716
+ this.add({ selection });
57721
57717
  }
57722
57718
  }
57723
57719
  get size() {
57724
57720
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
57725
57721
  }
57726
- add(selection) {
57722
+ add({ selection, external }) {
57723
+ let include = this.config.defaultFragmentMasking === "disable";
57724
+ const maskEnableDirective = selection.directives?.find(
57725
+ ({ name }) => name.value === this.config.maskEnableDirective
57726
+ );
57727
+ if (maskEnableDirective) {
57728
+ include = false;
57729
+ }
57730
+ const maskDisableDirective = selection.directives?.find(
57731
+ ({ name }) => name.value === this.config.maskDisableDirective
57732
+ );
57733
+ if (maskDisableDirective) {
57734
+ include = true;
57735
+ }
57727
57736
  if (selection.kind === "Field") {
57728
57737
  const key = selection.alias?.value || selection.name.value;
57729
57738
  if (!this.fields[key]) {
@@ -57733,46 +57742,32 @@ var FieldCollection = class {
57733
57742
  };
57734
57743
  }
57735
57744
  for (const subselect of selection.selectionSet?.selections || []) {
57736
- this.fields[key].selection.add(subselect);
57745
+ this.fields[key].selection.add({
57746
+ selection: subselect,
57747
+ external
57748
+ });
57749
+ }
57750
+ if (this.applyFragments && !external) {
57751
+ this.fields[key].selection.fragmentSpreads = {
57752
+ ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
57753
+ ...this.fields[key].selection.fragmentSpreads
57754
+ };
57737
57755
  }
57738
- this.fields[key].selection.fragmentSpreads = {
57739
- ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
57740
- ...this.fields[key].selection.fragmentSpreads
57741
- };
57742
57756
  return;
57743
57757
  }
57744
57758
  if (selection.kind === "InlineFragment" && !selection.typeCondition) {
57745
57759
  for (const subselect of selection.selectionSet.selections) {
57746
- this.add(subselect);
57760
+ this.add({ selection: subselect, external });
57747
57761
  }
57748
57762
  }
57749
57763
  if (selection.kind === "InlineFragment" && selection.typeCondition) {
57750
- this.walkInlineFragment(selection);
57764
+ this.walkInlineFragment({ selection, external });
57751
57765
  return;
57752
57766
  }
57753
57767
  if (selection.kind === "FragmentSpread") {
57754
- let includeFragments = this.config.defaultFragmentMasking === "disable";
57755
- const maskEnableDirective = selection.directives?.find(
57756
- ({ name }) => name.value === this.config.maskEnableDirective
57757
- );
57758
- if (maskEnableDirective) {
57759
- includeFragments = false;
57760
- }
57761
- const maskDisableDirective = selection.directives?.find(
57762
- ({ name }) => name.value === this.config.maskDisableDirective
57763
- );
57764
- if (maskDisableDirective) {
57765
- includeFragments = true;
57766
- }
57767
- if (this.ignoreMaskDisable) {
57768
- includeFragments = true;
57769
- }
57770
- if (this.keepFragmentSpreadNodes) {
57768
+ if (!external || include) {
57771
57769
  this.fragmentSpreads[selection.name.value] = selection;
57772
57770
  }
57773
- if (!includeFragments) {
57774
- return;
57775
- }
57776
57771
  const definition = this.fragmentDefinitions[selection.name.value];
57777
57772
  if (!definition) {
57778
57773
  throw new HoudiniError({
@@ -57780,20 +57775,25 @@ var FieldCollection = class {
57780
57775
  message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
57781
57776
  });
57782
57777
  }
57783
- this.add({
57784
- kind: "InlineFragment",
57785
- typeCondition: {
57786
- kind: "NamedType",
57787
- name: {
57788
- kind: "Name",
57789
- value: definition.typeCondition.name.value
57790
- }
57791
- },
57792
- selectionSet: {
57793
- kind: "SelectionSet",
57794
- selections: [...definition.selectionSet.selections]
57795
- }
57796
- });
57778
+ if (this.applyFragments || include) {
57779
+ this.add({
57780
+ selection: {
57781
+ kind: "InlineFragment",
57782
+ typeCondition: {
57783
+ kind: "NamedType",
57784
+ name: {
57785
+ kind: "Name",
57786
+ value: definition.typeCondition.name.value
57787
+ }
57788
+ },
57789
+ selectionSet: {
57790
+ kind: "SelectionSet",
57791
+ selections: [...definition.selectionSet.selections]
57792
+ }
57793
+ },
57794
+ external: !include
57795
+ });
57796
+ }
57797
57797
  }
57798
57798
  }
57799
57799
  collectFragmentSpreads(selections, result = {}) {
@@ -57848,7 +57848,10 @@ var FieldCollection = class {
57848
57848
  })
57849
57849
  );
57850
57850
  }
57851
- walkInlineFragment(selection) {
57851
+ walkInlineFragment({
57852
+ selection,
57853
+ external
57854
+ }) {
57852
57855
  const key = selection.typeCondition.name.value;
57853
57856
  if (!this.inlineFragments[key]) {
57854
57857
  this.inlineFragments[key] = {
@@ -57857,11 +57860,21 @@ var FieldCollection = class {
57857
57860
  };
57858
57861
  }
57859
57862
  for (const subselect of selection.selectionSet.selections || []) {
57860
- if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
57861
- this.inlineFragments[key].selection.add(subselect);
57863
+ if (subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
57864
+ this.inlineFragments[key].selection.add({
57865
+ selection: subselect,
57866
+ external
57867
+ });
57862
57868
  continue;
57869
+ } else if (subselect.kind === "FragmentSpread") {
57870
+ this.add({
57871
+ selection: subselect,
57872
+ external
57873
+ });
57874
+ continue;
57875
+ } else {
57876
+ this.walkInlineFragment({ selection: subselect, external });
57863
57877
  }
57864
- this.walkInlineFragment(subselect);
57865
57878
  }
57866
57879
  }
57867
57880
  empty() {
@@ -57870,8 +57883,7 @@ var FieldCollection = class {
57870
57883
  fragmentDefinitions: this.fragmentDefinitions,
57871
57884
  selections: [],
57872
57885
  filepath: this.filepath,
57873
- ignoreMaskDisable: this.ignoreMaskDisable,
57874
- keepFragmentSpreadNodes: this.keepFragmentSpreadNodes
57886
+ applyFragments: this.applyFragments
57875
57887
  });
57876
57888
  }
57877
57889
  };
@@ -59791,7 +59803,8 @@ function prepareSelection({
59791
59803
  inConnection,
59792
59804
  typeMap,
59793
59805
  abstractTypes,
59794
- globalLoading
59806
+ globalLoading,
59807
+ includeFragments
59795
59808
  }) {
59796
59809
  let object = {};
59797
59810
  const loadingTypes = [];
@@ -59811,7 +59824,8 @@ function prepareSelection({
59811
59824
  document,
59812
59825
  typeMap,
59813
59826
  abstractTypes,
59814
- globalLoading
59827
+ globalLoading,
59828
+ includeFragments
59815
59829
  }).fields || {}
59816
59830
  );
59817
59831
  } else {
@@ -59859,7 +59873,8 @@ function prepareSelection({
59859
59873
  document,
59860
59874
  typeMap,
59861
59875
  abstractTypes,
59862
- globalLoading
59876
+ globalLoading,
59877
+ includeFragments
59863
59878
  }).fields
59864
59879
  };
59865
59880
  if (field.directives?.find((d) => d.name.value === config2.loadingDirective)) {
@@ -59977,7 +59992,8 @@ function prepareSelection({
59977
59992
  inConnection: connectionState,
59978
59993
  typeMap,
59979
59994
  abstractTypes,
59980
- globalLoading: forceLoading
59995
+ globalLoading: forceLoading,
59996
+ includeFragments
59981
59997
  });
59982
59998
  if (Object.values(fieldObj.selection.fields ?? {}).some((field2) => field2.required)) {
59983
59999
  fieldObj.nullable = true;
@@ -60310,13 +60326,13 @@ function artifactGenerator(stats) {
60310
60326
  document: doc,
60311
60327
  rootType,
60312
60328
  globalLoading,
60329
+ includeFragments: doc.kind !== ArtifactKind.Fragment,
60313
60330
  selections: flattenSelections({
60314
60331
  config: config2,
60315
60332
  filepath: doc.filename,
60316
60333
  selections: selectionSet.selections,
60317
60334
  fragmentDefinitions,
60318
- ignoreMaskDisable: docKind !== "HoudiniFragment",
60319
- keepFragmentSpreadNodes: true
60335
+ applyFragments: doc.kind !== ArtifactKind.Fragment
60320
60336
  }),
60321
60337
  operations: operationsByPath(
60322
60338
  config2,
@@ -61281,8 +61297,7 @@ async function generateDocumentTypes(config2, docs) {
61281
61297
  config: config2,
61282
61298
  filepath: filename,
61283
61299
  selections: definition.selectionSet.selections,
61284
- fragmentDefinitions,
61285
- keepFragmentSpreadNodes: true
61300
+ fragmentDefinitions
61286
61301
  });
61287
61302
  if (definition?.kind === "OperationDefinition") {
61288
61303
  await generateOperationTypeDefs(
@@ -63559,6 +63574,8 @@ function testConfigFile({ plugins, ...config2 } = {}) {
63559
63574
  customIdList: [CustomIdType]!
63560
63575
  nodes(ids: [ID!]!): [Node!]!
63561
63576
  monkeys: MonkeyConnection!
63577
+ animals(first: Int, after: String): AnimalConnection
63578
+
63562
63579
  }
63563
63580
 
63564
63581
  input UserFilter {