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.
@@ -57690,18 +57690,14 @@ function flattenSelections({
57690
57690
  filepath,
57691
57691
  selections,
57692
57692
  fragmentDefinitions,
57693
- ignoreMaskDisable,
57694
- keepFragmentSpreadNodes,
57695
- hoistFragments
57693
+ applyFragments
57696
57694
  }) {
57697
57695
  const fields = new FieldCollection({
57698
57696
  config: config2,
57699
57697
  filepath,
57700
57698
  selections,
57701
57699
  fragmentDefinitions,
57702
- ignoreMaskDisable: !!ignoreMaskDisable,
57703
- keepFragmentSpreadNodes: !!keepFragmentSpreadNodes,
57704
- hoistFragments
57700
+ applyFragments: !!applyFragments
57705
57701
  });
57706
57702
  return fields.toSelectionSet();
57707
57703
  }
@@ -57712,18 +57708,14 @@ var FieldCollection = class {
57712
57708
  fields;
57713
57709
  inlineFragments;
57714
57710
  fragmentSpreads;
57715
- ignoreMaskDisable;
57716
- keepFragmentSpreadNodes;
57717
- hoistFragments;
57711
+ applyFragments;
57718
57712
  constructor(args) {
57719
57713
  this.config = args.config;
57720
57714
  this.fragmentDefinitions = args.fragmentDefinitions;
57721
- this.ignoreMaskDisable = args.ignoreMaskDisable;
57722
- this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
57715
+ this.applyFragments = args.applyFragments;
57723
57716
  this.fields = {};
57724
57717
  this.inlineFragments = {};
57725
57718
  this.fragmentSpreads = {};
57726
- this.hoistFragments = !!args.hoistFragments;
57727
57719
  this.filepath = args.filepath;
57728
57720
  for (const selection of args.selections) {
57729
57721
  this.add({ selection });
@@ -57733,21 +57725,18 @@ var FieldCollection = class {
57733
57725
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
57734
57726
  }
57735
57727
  add({ selection, external }) {
57736
- let includeFragments = this.config.defaultFragmentMasking === "disable";
57728
+ let include = this.config.defaultFragmentMasking === "disable";
57737
57729
  const maskEnableDirective = selection.directives?.find(
57738
57730
  ({ name }) => name.value === this.config.maskEnableDirective
57739
57731
  );
57740
57732
  if (maskEnableDirective) {
57741
- includeFragments = false;
57733
+ include = false;
57742
57734
  }
57743
57735
  const maskDisableDirective = selection.directives?.find(
57744
57736
  ({ name }) => name.value === this.config.maskDisableDirective
57745
57737
  );
57746
57738
  if (maskDisableDirective) {
57747
- includeFragments = true;
57748
- }
57749
- if (this.ignoreMaskDisable) {
57750
- includeFragments = true;
57739
+ include = true;
57751
57740
  }
57752
57741
  if (selection.kind === "Field") {
57753
57742
  const key = selection.alias?.value || selection.name.value;
@@ -57763,7 +57752,7 @@ var FieldCollection = class {
57763
57752
  external
57764
57753
  });
57765
57754
  }
57766
- if (!external && includeFragments) {
57755
+ if (this.applyFragments && !external) {
57767
57756
  this.fields[key].selection.fragmentSpreads = {
57768
57757
  ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
57769
57758
  ...this.fields[key].selection.fragmentSpreads
@@ -57777,16 +57766,13 @@ var FieldCollection = class {
57777
57766
  }
57778
57767
  }
57779
57768
  if (selection.kind === "InlineFragment" && selection.typeCondition) {
57780
- this.walkInlineFragment({ selection, external, hoistFragments: this.hoistFragments });
57769
+ this.walkInlineFragment({ selection, external });
57781
57770
  return;
57782
57771
  }
57783
57772
  if (selection.kind === "FragmentSpread") {
57784
- if (this.keepFragmentSpreadNodes && !external) {
57773
+ if (!external || include) {
57785
57774
  this.fragmentSpreads[selection.name.value] = selection;
57786
57775
  }
57787
- if (!includeFragments) {
57788
- return;
57789
- }
57790
57776
  const definition = this.fragmentDefinitions[selection.name.value];
57791
57777
  if (!definition) {
57792
57778
  throw new HoudiniError({
@@ -57794,23 +57780,25 @@ var FieldCollection = class {
57794
57780
  message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
57795
57781
  });
57796
57782
  }
57797
- this.add({
57798
- selection: {
57799
- kind: "InlineFragment",
57800
- typeCondition: {
57801
- kind: "NamedType",
57802
- name: {
57803
- kind: "Name",
57804
- value: definition.typeCondition.name.value
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]
57805
57797
  }
57806
57798
  },
57807
- selectionSet: {
57808
- kind: "SelectionSet",
57809
- selections: [...definition.selectionSet.selections]
57810
- }
57811
- },
57812
- external
57813
- });
57799
+ external: !include
57800
+ });
57801
+ }
57814
57802
  }
57815
57803
  }
57816
57804
  collectFragmentSpreads(selections, result = {}) {
@@ -57867,8 +57855,7 @@ var FieldCollection = class {
57867
57855
  }
57868
57856
  walkInlineFragment({
57869
57857
  selection,
57870
- external,
57871
- hoistFragments
57858
+ external
57872
57859
  }) {
57873
57860
  const key = selection.typeCondition.name.value;
57874
57861
  if (!this.inlineFragments[key]) {
@@ -57878,7 +57865,7 @@ var FieldCollection = class {
57878
57865
  };
57879
57866
  }
57880
57867
  for (const subselect of selection.selectionSet.selections || []) {
57881
- if (subselect.kind === "FragmentSpread" && !hoistFragments || subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
57868
+ if (subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
57882
57869
  this.inlineFragments[key].selection.add({
57883
57870
  selection: subselect,
57884
57871
  external
@@ -57887,11 +57874,11 @@ var FieldCollection = class {
57887
57874
  } else if (subselect.kind === "FragmentSpread") {
57888
57875
  this.add({
57889
57876
  selection: subselect,
57890
- external: true
57877
+ external
57891
57878
  });
57892
57879
  continue;
57893
57880
  } else {
57894
- this.walkInlineFragment({ selection: subselect, external, hoistFragments });
57881
+ this.walkInlineFragment({ selection: subselect, external });
57895
57882
  }
57896
57883
  }
57897
57884
  }
@@ -57901,9 +57888,7 @@ var FieldCollection = class {
57901
57888
  fragmentDefinitions: this.fragmentDefinitions,
57902
57889
  selections: [],
57903
57890
  filepath: this.filepath,
57904
- ignoreMaskDisable: this.ignoreMaskDisable,
57905
- keepFragmentSpreadNodes: this.keepFragmentSpreadNodes,
57906
- hoistFragments: this.hoistFragments
57891
+ applyFragments: this.applyFragments
57907
57892
  });
57908
57893
  }
57909
57894
  };
@@ -59823,7 +59808,8 @@ function prepareSelection({
59823
59808
  inConnection,
59824
59809
  typeMap,
59825
59810
  abstractTypes,
59826
- globalLoading
59811
+ globalLoading,
59812
+ includeFragments
59827
59813
  }) {
59828
59814
  let object = {};
59829
59815
  const loadingTypes = [];
@@ -59843,7 +59829,8 @@ function prepareSelection({
59843
59829
  document,
59844
59830
  typeMap,
59845
59831
  abstractTypes,
59846
- globalLoading
59832
+ globalLoading,
59833
+ includeFragments
59847
59834
  }).fields || {}
59848
59835
  );
59849
59836
  } else {
@@ -59891,7 +59878,8 @@ function prepareSelection({
59891
59878
  document,
59892
59879
  typeMap,
59893
59880
  abstractTypes,
59894
- globalLoading
59881
+ globalLoading,
59882
+ includeFragments
59895
59883
  }).fields
59896
59884
  };
59897
59885
  if (field.directives?.find((d) => d.name.value === config2.loadingDirective)) {
@@ -60009,7 +59997,8 @@ function prepareSelection({
60009
59997
  inConnection: connectionState,
60010
59998
  typeMap,
60011
59999
  abstractTypes,
60012
- globalLoading: forceLoading
60000
+ globalLoading: forceLoading,
60001
+ includeFragments
60013
60002
  });
60014
60003
  if (Object.values(fieldObj.selection.fields ?? {}).some((field2) => field2.required)) {
60015
60004
  fieldObj.nullable = true;
@@ -60342,14 +60331,13 @@ function artifactGenerator(stats) {
60342
60331
  document: doc,
60343
60332
  rootType,
60344
60333
  globalLoading,
60334
+ includeFragments: doc.kind !== ArtifactKind.Fragment,
60345
60335
  selections: flattenSelections({
60346
60336
  config: config2,
60347
60337
  filepath: doc.filename,
60348
60338
  selections: selectionSet.selections,
60349
60339
  fragmentDefinitions,
60350
- ignoreMaskDisable: docKind !== "HoudiniFragment",
60351
- keepFragmentSpreadNodes: true,
60352
- hoistFragments: true
60340
+ applyFragments: doc.kind !== ArtifactKind.Fragment
60353
60341
  }),
60354
60342
  operations: operationsByPath(
60355
60343
  config2,
@@ -61314,8 +61302,7 @@ async function generateDocumentTypes(config2, docs) {
61314
61302
  config: config2,
61315
61303
  filepath: filename,
61316
61304
  selections: definition.selectionSet.selections,
61317
- fragmentDefinitions,
61318
- keepFragmentSpreadNodes: true
61305
+ fragmentDefinitions
61319
61306
  });
61320
61307
  if (definition?.kind === "OperationDefinition") {
61321
61308
  await generateOperationTypeDefs(
@@ -57685,18 +57685,14 @@ function flattenSelections({
57685
57685
  filepath,
57686
57686
  selections,
57687
57687
  fragmentDefinitions,
57688
- ignoreMaskDisable,
57689
- keepFragmentSpreadNodes,
57690
- hoistFragments
57688
+ applyFragments
57691
57689
  }) {
57692
57690
  const fields = new FieldCollection({
57693
57691
  config: config2,
57694
57692
  filepath,
57695
57693
  selections,
57696
57694
  fragmentDefinitions,
57697
- ignoreMaskDisable: !!ignoreMaskDisable,
57698
- keepFragmentSpreadNodes: !!keepFragmentSpreadNodes,
57699
- hoistFragments
57695
+ applyFragments: !!applyFragments
57700
57696
  });
57701
57697
  return fields.toSelectionSet();
57702
57698
  }
@@ -57707,18 +57703,14 @@ var FieldCollection = class {
57707
57703
  fields;
57708
57704
  inlineFragments;
57709
57705
  fragmentSpreads;
57710
- ignoreMaskDisable;
57711
- keepFragmentSpreadNodes;
57712
- hoistFragments;
57706
+ applyFragments;
57713
57707
  constructor(args) {
57714
57708
  this.config = args.config;
57715
57709
  this.fragmentDefinitions = args.fragmentDefinitions;
57716
- this.ignoreMaskDisable = args.ignoreMaskDisable;
57717
- this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
57710
+ this.applyFragments = args.applyFragments;
57718
57711
  this.fields = {};
57719
57712
  this.inlineFragments = {};
57720
57713
  this.fragmentSpreads = {};
57721
- this.hoistFragments = !!args.hoistFragments;
57722
57714
  this.filepath = args.filepath;
57723
57715
  for (const selection of args.selections) {
57724
57716
  this.add({ selection });
@@ -57728,21 +57720,18 @@ var FieldCollection = class {
57728
57720
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
57729
57721
  }
57730
57722
  add({ selection, external }) {
57731
- let includeFragments = this.config.defaultFragmentMasking === "disable";
57723
+ let include = this.config.defaultFragmentMasking === "disable";
57732
57724
  const maskEnableDirective = selection.directives?.find(
57733
57725
  ({ name }) => name.value === this.config.maskEnableDirective
57734
57726
  );
57735
57727
  if (maskEnableDirective) {
57736
- includeFragments = false;
57728
+ include = false;
57737
57729
  }
57738
57730
  const maskDisableDirective = selection.directives?.find(
57739
57731
  ({ name }) => name.value === this.config.maskDisableDirective
57740
57732
  );
57741
57733
  if (maskDisableDirective) {
57742
- includeFragments = true;
57743
- }
57744
- if (this.ignoreMaskDisable) {
57745
- includeFragments = true;
57734
+ include = true;
57746
57735
  }
57747
57736
  if (selection.kind === "Field") {
57748
57737
  const key = selection.alias?.value || selection.name.value;
@@ -57758,7 +57747,7 @@ var FieldCollection = class {
57758
57747
  external
57759
57748
  });
57760
57749
  }
57761
- if (!external && includeFragments) {
57750
+ if (this.applyFragments && !external) {
57762
57751
  this.fields[key].selection.fragmentSpreads = {
57763
57752
  ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
57764
57753
  ...this.fields[key].selection.fragmentSpreads
@@ -57772,16 +57761,13 @@ var FieldCollection = class {
57772
57761
  }
57773
57762
  }
57774
57763
  if (selection.kind === "InlineFragment" && selection.typeCondition) {
57775
- this.walkInlineFragment({ selection, external, hoistFragments: this.hoistFragments });
57764
+ this.walkInlineFragment({ selection, external });
57776
57765
  return;
57777
57766
  }
57778
57767
  if (selection.kind === "FragmentSpread") {
57779
- if (this.keepFragmentSpreadNodes && !external) {
57768
+ if (!external || include) {
57780
57769
  this.fragmentSpreads[selection.name.value] = selection;
57781
57770
  }
57782
- if (!includeFragments) {
57783
- return;
57784
- }
57785
57771
  const definition = this.fragmentDefinitions[selection.name.value];
57786
57772
  if (!definition) {
57787
57773
  throw new HoudiniError({
@@ -57789,23 +57775,25 @@ var FieldCollection = class {
57789
57775
  message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
57790
57776
  });
57791
57777
  }
57792
- this.add({
57793
- selection: {
57794
- kind: "InlineFragment",
57795
- typeCondition: {
57796
- kind: "NamedType",
57797
- name: {
57798
- kind: "Name",
57799
- value: definition.typeCondition.name.value
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]
57800
57792
  }
57801
57793
  },
57802
- selectionSet: {
57803
- kind: "SelectionSet",
57804
- selections: [...definition.selectionSet.selections]
57805
- }
57806
- },
57807
- external
57808
- });
57794
+ external: !include
57795
+ });
57796
+ }
57809
57797
  }
57810
57798
  }
57811
57799
  collectFragmentSpreads(selections, result = {}) {
@@ -57862,8 +57850,7 @@ var FieldCollection = class {
57862
57850
  }
57863
57851
  walkInlineFragment({
57864
57852
  selection,
57865
- external,
57866
- hoistFragments
57853
+ external
57867
57854
  }) {
57868
57855
  const key = selection.typeCondition.name.value;
57869
57856
  if (!this.inlineFragments[key]) {
@@ -57873,7 +57860,7 @@ var FieldCollection = class {
57873
57860
  };
57874
57861
  }
57875
57862
  for (const subselect of selection.selectionSet.selections || []) {
57876
- if (subselect.kind === "FragmentSpread" && !hoistFragments || subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
57863
+ if (subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
57877
57864
  this.inlineFragments[key].selection.add({
57878
57865
  selection: subselect,
57879
57866
  external
@@ -57882,11 +57869,11 @@ var FieldCollection = class {
57882
57869
  } else if (subselect.kind === "FragmentSpread") {
57883
57870
  this.add({
57884
57871
  selection: subselect,
57885
- external: true
57872
+ external
57886
57873
  });
57887
57874
  continue;
57888
57875
  } else {
57889
- this.walkInlineFragment({ selection: subselect, external, hoistFragments });
57876
+ this.walkInlineFragment({ selection: subselect, external });
57890
57877
  }
57891
57878
  }
57892
57879
  }
@@ -57896,9 +57883,7 @@ var FieldCollection = class {
57896
57883
  fragmentDefinitions: this.fragmentDefinitions,
57897
57884
  selections: [],
57898
57885
  filepath: this.filepath,
57899
- ignoreMaskDisable: this.ignoreMaskDisable,
57900
- keepFragmentSpreadNodes: this.keepFragmentSpreadNodes,
57901
- hoistFragments: this.hoistFragments
57886
+ applyFragments: this.applyFragments
57902
57887
  });
57903
57888
  }
57904
57889
  };
@@ -59818,7 +59803,8 @@ function prepareSelection({
59818
59803
  inConnection,
59819
59804
  typeMap,
59820
59805
  abstractTypes,
59821
- globalLoading
59806
+ globalLoading,
59807
+ includeFragments
59822
59808
  }) {
59823
59809
  let object = {};
59824
59810
  const loadingTypes = [];
@@ -59838,7 +59824,8 @@ function prepareSelection({
59838
59824
  document,
59839
59825
  typeMap,
59840
59826
  abstractTypes,
59841
- globalLoading
59827
+ globalLoading,
59828
+ includeFragments
59842
59829
  }).fields || {}
59843
59830
  );
59844
59831
  } else {
@@ -59886,7 +59873,8 @@ function prepareSelection({
59886
59873
  document,
59887
59874
  typeMap,
59888
59875
  abstractTypes,
59889
- globalLoading
59876
+ globalLoading,
59877
+ includeFragments
59890
59878
  }).fields
59891
59879
  };
59892
59880
  if (field.directives?.find((d) => d.name.value === config2.loadingDirective)) {
@@ -60004,7 +59992,8 @@ function prepareSelection({
60004
59992
  inConnection: connectionState,
60005
59993
  typeMap,
60006
59994
  abstractTypes,
60007
- globalLoading: forceLoading
59995
+ globalLoading: forceLoading,
59996
+ includeFragments
60008
59997
  });
60009
59998
  if (Object.values(fieldObj.selection.fields ?? {}).some((field2) => field2.required)) {
60010
59999
  fieldObj.nullable = true;
@@ -60337,14 +60326,13 @@ function artifactGenerator(stats) {
60337
60326
  document: doc,
60338
60327
  rootType,
60339
60328
  globalLoading,
60329
+ includeFragments: doc.kind !== ArtifactKind.Fragment,
60340
60330
  selections: flattenSelections({
60341
60331
  config: config2,
60342
60332
  filepath: doc.filename,
60343
60333
  selections: selectionSet.selections,
60344
60334
  fragmentDefinitions,
60345
- ignoreMaskDisable: docKind !== "HoudiniFragment",
60346
- keepFragmentSpreadNodes: true,
60347
- hoistFragments: true
60335
+ applyFragments: doc.kind !== ArtifactKind.Fragment
60348
60336
  }),
60349
60337
  operations: operationsByPath(
60350
60338
  config2,
@@ -61309,8 +61297,7 @@ async function generateDocumentTypes(config2, docs) {
61309
61297
  config: config2,
61310
61298
  filepath: filename,
61311
61299
  selections: definition.selectionSet.selections,
61312
- fragmentDefinitions,
61313
- keepFragmentSpreadNodes: true
61300
+ fragmentDefinitions
61314
61301
  });
61315
61302
  if (definition?.kind === "OperationDefinition") {
61316
61303
  await generateOperationTypeDefs(