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.
@@ -73672,18 +73672,14 @@ function flattenSelections({
73672
73672
  filepath,
73673
73673
  selections,
73674
73674
  fragmentDefinitions,
73675
- ignoreMaskDisable,
73676
- keepFragmentSpreadNodes,
73677
- hoistFragments
73675
+ applyFragments
73678
73676
  }) {
73679
73677
  const fields = new FieldCollection({
73680
73678
  config: config2,
73681
73679
  filepath,
73682
73680
  selections,
73683
73681
  fragmentDefinitions,
73684
- ignoreMaskDisable: !!ignoreMaskDisable,
73685
- keepFragmentSpreadNodes: !!keepFragmentSpreadNodes,
73686
- hoistFragments
73682
+ applyFragments: !!applyFragments
73687
73683
  });
73688
73684
  return fields.toSelectionSet();
73689
73685
  }
@@ -73694,18 +73690,14 @@ var FieldCollection = class {
73694
73690
  fields;
73695
73691
  inlineFragments;
73696
73692
  fragmentSpreads;
73697
- ignoreMaskDisable;
73698
- keepFragmentSpreadNodes;
73699
- hoistFragments;
73693
+ applyFragments;
73700
73694
  constructor(args) {
73701
73695
  this.config = args.config;
73702
73696
  this.fragmentDefinitions = args.fragmentDefinitions;
73703
- this.ignoreMaskDisable = args.ignoreMaskDisable;
73704
- this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
73697
+ this.applyFragments = args.applyFragments;
73705
73698
  this.fields = {};
73706
73699
  this.inlineFragments = {};
73707
73700
  this.fragmentSpreads = {};
73708
- this.hoistFragments = !!args.hoistFragments;
73709
73701
  this.filepath = args.filepath;
73710
73702
  for (const selection of args.selections) {
73711
73703
  this.add({ selection });
@@ -73715,21 +73707,18 @@ var FieldCollection = class {
73715
73707
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
73716
73708
  }
73717
73709
  add({ selection, external }) {
73718
- let includeFragments = this.config.defaultFragmentMasking === "disable";
73710
+ let include = this.config.defaultFragmentMasking === "disable";
73719
73711
  const maskEnableDirective = selection.directives?.find(
73720
73712
  ({ name }) => name.value === this.config.maskEnableDirective
73721
73713
  );
73722
73714
  if (maskEnableDirective) {
73723
- includeFragments = false;
73715
+ include = false;
73724
73716
  }
73725
73717
  const maskDisableDirective = selection.directives?.find(
73726
73718
  ({ name }) => name.value === this.config.maskDisableDirective
73727
73719
  );
73728
73720
  if (maskDisableDirective) {
73729
- includeFragments = true;
73730
- }
73731
- if (this.ignoreMaskDisable) {
73732
- includeFragments = true;
73721
+ include = true;
73733
73722
  }
73734
73723
  if (selection.kind === "Field") {
73735
73724
  const key = selection.alias?.value || selection.name.value;
@@ -73745,7 +73734,7 @@ var FieldCollection = class {
73745
73734
  external
73746
73735
  });
73747
73736
  }
73748
- if (!external && includeFragments) {
73737
+ if (this.applyFragments && !external) {
73749
73738
  this.fields[key].selection.fragmentSpreads = {
73750
73739
  ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
73751
73740
  ...this.fields[key].selection.fragmentSpreads
@@ -73759,16 +73748,13 @@ var FieldCollection = class {
73759
73748
  }
73760
73749
  }
73761
73750
  if (selection.kind === "InlineFragment" && selection.typeCondition) {
73762
- this.walkInlineFragment({ selection, external, hoistFragments: this.hoistFragments });
73751
+ this.walkInlineFragment({ selection, external });
73763
73752
  return;
73764
73753
  }
73765
73754
  if (selection.kind === "FragmentSpread") {
73766
- if (this.keepFragmentSpreadNodes && !external) {
73755
+ if (!external || include) {
73767
73756
  this.fragmentSpreads[selection.name.value] = selection;
73768
73757
  }
73769
- if (!includeFragments) {
73770
- return;
73771
- }
73772
73758
  const definition = this.fragmentDefinitions[selection.name.value];
73773
73759
  if (!definition) {
73774
73760
  throw new HoudiniError({
@@ -73776,23 +73762,25 @@ var FieldCollection = class {
73776
73762
  message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
73777
73763
  });
73778
73764
  }
73779
- this.add({
73780
- selection: {
73781
- kind: "InlineFragment",
73782
- typeCondition: {
73783
- kind: "NamedType",
73784
- name: {
73785
- kind: "Name",
73786
- value: definition.typeCondition.name.value
73765
+ if (this.applyFragments || include) {
73766
+ this.add({
73767
+ selection: {
73768
+ kind: "InlineFragment",
73769
+ typeCondition: {
73770
+ kind: "NamedType",
73771
+ name: {
73772
+ kind: "Name",
73773
+ value: definition.typeCondition.name.value
73774
+ }
73775
+ },
73776
+ selectionSet: {
73777
+ kind: "SelectionSet",
73778
+ selections: [...definition.selectionSet.selections]
73787
73779
  }
73788
73780
  },
73789
- selectionSet: {
73790
- kind: "SelectionSet",
73791
- selections: [...definition.selectionSet.selections]
73792
- }
73793
- },
73794
- external
73795
- });
73781
+ external: !include
73782
+ });
73783
+ }
73796
73784
  }
73797
73785
  }
73798
73786
  collectFragmentSpreads(selections, result = {}) {
@@ -73849,8 +73837,7 @@ var FieldCollection = class {
73849
73837
  }
73850
73838
  walkInlineFragment({
73851
73839
  selection,
73852
- external,
73853
- hoistFragments
73840
+ external
73854
73841
  }) {
73855
73842
  const key = selection.typeCondition.name.value;
73856
73843
  if (!this.inlineFragments[key]) {
@@ -73860,7 +73847,7 @@ var FieldCollection = class {
73860
73847
  };
73861
73848
  }
73862
73849
  for (const subselect of selection.selectionSet.selections || []) {
73863
- if (subselect.kind === "FragmentSpread" && !hoistFragments || subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
73850
+ if (subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
73864
73851
  this.inlineFragments[key].selection.add({
73865
73852
  selection: subselect,
73866
73853
  external
@@ -73869,11 +73856,11 @@ var FieldCollection = class {
73869
73856
  } else if (subselect.kind === "FragmentSpread") {
73870
73857
  this.add({
73871
73858
  selection: subselect,
73872
- external: true
73859
+ external
73873
73860
  });
73874
73861
  continue;
73875
73862
  } else {
73876
- this.walkInlineFragment({ selection: subselect, external, hoistFragments });
73863
+ this.walkInlineFragment({ selection: subselect, external });
73877
73864
  }
73878
73865
  }
73879
73866
  }
@@ -73883,9 +73870,7 @@ var FieldCollection = class {
73883
73870
  fragmentDefinitions: this.fragmentDefinitions,
73884
73871
  selections: [],
73885
73872
  filepath: this.filepath,
73886
- ignoreMaskDisable: this.ignoreMaskDisable,
73887
- keepFragmentSpreadNodes: this.keepFragmentSpreadNodes,
73888
- hoistFragments: this.hoistFragments
73873
+ applyFragments: this.applyFragments
73889
73874
  });
73890
73875
  }
73891
73876
  };
@@ -75805,7 +75790,8 @@ function prepareSelection({
75805
75790
  inConnection,
75806
75791
  typeMap,
75807
75792
  abstractTypes,
75808
- globalLoading
75793
+ globalLoading,
75794
+ includeFragments
75809
75795
  }) {
75810
75796
  let object = {};
75811
75797
  const loadingTypes = [];
@@ -75825,7 +75811,8 @@ function prepareSelection({
75825
75811
  document,
75826
75812
  typeMap,
75827
75813
  abstractTypes,
75828
- globalLoading
75814
+ globalLoading,
75815
+ includeFragments
75829
75816
  }).fields || {}
75830
75817
  );
75831
75818
  } else {
@@ -75873,7 +75860,8 @@ function prepareSelection({
75873
75860
  document,
75874
75861
  typeMap,
75875
75862
  abstractTypes,
75876
- globalLoading
75863
+ globalLoading,
75864
+ includeFragments
75877
75865
  }).fields
75878
75866
  };
75879
75867
  if (field.directives?.find((d) => d.name.value === config2.loadingDirective)) {
@@ -75991,7 +75979,8 @@ function prepareSelection({
75991
75979
  inConnection: connectionState,
75992
75980
  typeMap,
75993
75981
  abstractTypes,
75994
- globalLoading: forceLoading
75982
+ globalLoading: forceLoading,
75983
+ includeFragments
75995
75984
  });
75996
75985
  if (Object.values(fieldObj.selection.fields ?? {}).some((field2) => field2.required)) {
75997
75986
  fieldObj.nullable = true;
@@ -76324,14 +76313,13 @@ function artifactGenerator(stats) {
76324
76313
  document: doc,
76325
76314
  rootType,
76326
76315
  globalLoading,
76316
+ includeFragments: doc.kind !== ArtifactKind.Fragment,
76327
76317
  selections: flattenSelections({
76328
76318
  config: config2,
76329
76319
  filepath: doc.filename,
76330
76320
  selections: selectionSet.selections,
76331
76321
  fragmentDefinitions,
76332
- ignoreMaskDisable: docKind !== "HoudiniFragment",
76333
- keepFragmentSpreadNodes: true,
76334
- hoistFragments: true
76322
+ applyFragments: doc.kind !== ArtifactKind.Fragment
76335
76323
  }),
76336
76324
  operations: operationsByPath(
76337
76325
  config2,
@@ -77296,8 +77284,7 @@ async function generateDocumentTypes(config2, docs) {
77296
77284
  config: config2,
77297
77285
  filepath: filename,
77298
77286
  selections: definition.selectionSet.selections,
77299
- fragmentDefinitions,
77300
- keepFragmentSpreadNodes: true
77287
+ fragmentDefinitions
77301
77288
  });
77302
77289
  if (definition?.kind === "OperationDefinition") {
77303
77290
  await generateOperationTypeDefs(
@@ -80067,8 +80054,8 @@ async function updatePackageJSON(targetPath) {
80067
80054
  }
80068
80055
  packageJSON.devDependencies = {
80069
80056
  ...packageJSON.devDependencies,
80070
- houdini: "^1.2.1",
80071
- "houdini-svelte": "^1.2.1"
80057
+ houdini: "^1.2.2",
80058
+ "houdini-svelte": "^1.2.2"
80072
80059
  };
80073
80060
  await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
80074
80061
  }
@@ -73677,18 +73677,14 @@ function flattenSelections({
73677
73677
  filepath,
73678
73678
  selections,
73679
73679
  fragmentDefinitions,
73680
- ignoreMaskDisable,
73681
- keepFragmentSpreadNodes,
73682
- hoistFragments
73680
+ applyFragments
73683
73681
  }) {
73684
73682
  const fields = new FieldCollection({
73685
73683
  config: config2,
73686
73684
  filepath,
73687
73685
  selections,
73688
73686
  fragmentDefinitions,
73689
- ignoreMaskDisable: !!ignoreMaskDisable,
73690
- keepFragmentSpreadNodes: !!keepFragmentSpreadNodes,
73691
- hoistFragments
73687
+ applyFragments: !!applyFragments
73692
73688
  });
73693
73689
  return fields.toSelectionSet();
73694
73690
  }
@@ -73699,18 +73695,14 @@ var FieldCollection = class {
73699
73695
  fields;
73700
73696
  inlineFragments;
73701
73697
  fragmentSpreads;
73702
- ignoreMaskDisable;
73703
- keepFragmentSpreadNodes;
73704
- hoistFragments;
73698
+ applyFragments;
73705
73699
  constructor(args) {
73706
73700
  this.config = args.config;
73707
73701
  this.fragmentDefinitions = args.fragmentDefinitions;
73708
- this.ignoreMaskDisable = args.ignoreMaskDisable;
73709
- this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
73702
+ this.applyFragments = args.applyFragments;
73710
73703
  this.fields = {};
73711
73704
  this.inlineFragments = {};
73712
73705
  this.fragmentSpreads = {};
73713
- this.hoistFragments = !!args.hoistFragments;
73714
73706
  this.filepath = args.filepath;
73715
73707
  for (const selection of args.selections) {
73716
73708
  this.add({ selection });
@@ -73720,21 +73712,18 @@ var FieldCollection = class {
73720
73712
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
73721
73713
  }
73722
73714
  add({ selection, external }) {
73723
- let includeFragments = this.config.defaultFragmentMasking === "disable";
73715
+ let include = this.config.defaultFragmentMasking === "disable";
73724
73716
  const maskEnableDirective = selection.directives?.find(
73725
73717
  ({ name }) => name.value === this.config.maskEnableDirective
73726
73718
  );
73727
73719
  if (maskEnableDirective) {
73728
- includeFragments = false;
73720
+ include = false;
73729
73721
  }
73730
73722
  const maskDisableDirective = selection.directives?.find(
73731
73723
  ({ name }) => name.value === this.config.maskDisableDirective
73732
73724
  );
73733
73725
  if (maskDisableDirective) {
73734
- includeFragments = true;
73735
- }
73736
- if (this.ignoreMaskDisable) {
73737
- includeFragments = true;
73726
+ include = true;
73738
73727
  }
73739
73728
  if (selection.kind === "Field") {
73740
73729
  const key = selection.alias?.value || selection.name.value;
@@ -73750,7 +73739,7 @@ var FieldCollection = class {
73750
73739
  external
73751
73740
  });
73752
73741
  }
73753
- if (!external && includeFragments) {
73742
+ if (this.applyFragments && !external) {
73754
73743
  this.fields[key].selection.fragmentSpreads = {
73755
73744
  ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
73756
73745
  ...this.fields[key].selection.fragmentSpreads
@@ -73764,16 +73753,13 @@ var FieldCollection = class {
73764
73753
  }
73765
73754
  }
73766
73755
  if (selection.kind === "InlineFragment" && selection.typeCondition) {
73767
- this.walkInlineFragment({ selection, external, hoistFragments: this.hoistFragments });
73756
+ this.walkInlineFragment({ selection, external });
73768
73757
  return;
73769
73758
  }
73770
73759
  if (selection.kind === "FragmentSpread") {
73771
- if (this.keepFragmentSpreadNodes && !external) {
73760
+ if (!external || include) {
73772
73761
  this.fragmentSpreads[selection.name.value] = selection;
73773
73762
  }
73774
- if (!includeFragments) {
73775
- return;
73776
- }
73777
73763
  const definition = this.fragmentDefinitions[selection.name.value];
73778
73764
  if (!definition) {
73779
73765
  throw new HoudiniError({
@@ -73781,23 +73767,25 @@ var FieldCollection = class {
73781
73767
  message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
73782
73768
  });
73783
73769
  }
73784
- this.add({
73785
- selection: {
73786
- kind: "InlineFragment",
73787
- typeCondition: {
73788
- kind: "NamedType",
73789
- name: {
73790
- kind: "Name",
73791
- value: definition.typeCondition.name.value
73770
+ if (this.applyFragments || include) {
73771
+ this.add({
73772
+ selection: {
73773
+ kind: "InlineFragment",
73774
+ typeCondition: {
73775
+ kind: "NamedType",
73776
+ name: {
73777
+ kind: "Name",
73778
+ value: definition.typeCondition.name.value
73779
+ }
73780
+ },
73781
+ selectionSet: {
73782
+ kind: "SelectionSet",
73783
+ selections: [...definition.selectionSet.selections]
73792
73784
  }
73793
73785
  },
73794
- selectionSet: {
73795
- kind: "SelectionSet",
73796
- selections: [...definition.selectionSet.selections]
73797
- }
73798
- },
73799
- external
73800
- });
73786
+ external: !include
73787
+ });
73788
+ }
73801
73789
  }
73802
73790
  }
73803
73791
  collectFragmentSpreads(selections, result = {}) {
@@ -73854,8 +73842,7 @@ var FieldCollection = class {
73854
73842
  }
73855
73843
  walkInlineFragment({
73856
73844
  selection,
73857
- external,
73858
- hoistFragments
73845
+ external
73859
73846
  }) {
73860
73847
  const key = selection.typeCondition.name.value;
73861
73848
  if (!this.inlineFragments[key]) {
@@ -73865,7 +73852,7 @@ var FieldCollection = class {
73865
73852
  };
73866
73853
  }
73867
73854
  for (const subselect of selection.selectionSet.selections || []) {
73868
- if (subselect.kind === "FragmentSpread" && !hoistFragments || subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
73855
+ if (subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
73869
73856
  this.inlineFragments[key].selection.add({
73870
73857
  selection: subselect,
73871
73858
  external
@@ -73874,11 +73861,11 @@ var FieldCollection = class {
73874
73861
  } else if (subselect.kind === "FragmentSpread") {
73875
73862
  this.add({
73876
73863
  selection: subselect,
73877
- external: true
73864
+ external
73878
73865
  });
73879
73866
  continue;
73880
73867
  } else {
73881
- this.walkInlineFragment({ selection: subselect, external, hoistFragments });
73868
+ this.walkInlineFragment({ selection: subselect, external });
73882
73869
  }
73883
73870
  }
73884
73871
  }
@@ -73888,9 +73875,7 @@ var FieldCollection = class {
73888
73875
  fragmentDefinitions: this.fragmentDefinitions,
73889
73876
  selections: [],
73890
73877
  filepath: this.filepath,
73891
- ignoreMaskDisable: this.ignoreMaskDisable,
73892
- keepFragmentSpreadNodes: this.keepFragmentSpreadNodes,
73893
- hoistFragments: this.hoistFragments
73878
+ applyFragments: this.applyFragments
73894
73879
  });
73895
73880
  }
73896
73881
  };
@@ -75810,7 +75795,8 @@ function prepareSelection({
75810
75795
  inConnection,
75811
75796
  typeMap,
75812
75797
  abstractTypes,
75813
- globalLoading
75798
+ globalLoading,
75799
+ includeFragments
75814
75800
  }) {
75815
75801
  let object = {};
75816
75802
  const loadingTypes = [];
@@ -75830,7 +75816,8 @@ function prepareSelection({
75830
75816
  document,
75831
75817
  typeMap,
75832
75818
  abstractTypes,
75833
- globalLoading
75819
+ globalLoading,
75820
+ includeFragments
75834
75821
  }).fields || {}
75835
75822
  );
75836
75823
  } else {
@@ -75878,7 +75865,8 @@ function prepareSelection({
75878
75865
  document,
75879
75866
  typeMap,
75880
75867
  abstractTypes,
75881
- globalLoading
75868
+ globalLoading,
75869
+ includeFragments
75882
75870
  }).fields
75883
75871
  };
75884
75872
  if (field.directives?.find((d) => d.name.value === config2.loadingDirective)) {
@@ -75996,7 +75984,8 @@ function prepareSelection({
75996
75984
  inConnection: connectionState,
75997
75985
  typeMap,
75998
75986
  abstractTypes,
75999
- globalLoading: forceLoading
75987
+ globalLoading: forceLoading,
75988
+ includeFragments
76000
75989
  });
76001
75990
  if (Object.values(fieldObj.selection.fields ?? {}).some((field2) => field2.required)) {
76002
75991
  fieldObj.nullable = true;
@@ -76329,14 +76318,13 @@ function artifactGenerator(stats) {
76329
76318
  document: doc,
76330
76319
  rootType,
76331
76320
  globalLoading,
76321
+ includeFragments: doc.kind !== ArtifactKind.Fragment,
76332
76322
  selections: flattenSelections({
76333
76323
  config: config2,
76334
76324
  filepath: doc.filename,
76335
76325
  selections: selectionSet.selections,
76336
76326
  fragmentDefinitions,
76337
- ignoreMaskDisable: docKind !== "HoudiniFragment",
76338
- keepFragmentSpreadNodes: true,
76339
- hoistFragments: true
76327
+ applyFragments: doc.kind !== ArtifactKind.Fragment
76340
76328
  }),
76341
76329
  operations: operationsByPath(
76342
76330
  config2,
@@ -77301,8 +77289,7 @@ async function generateDocumentTypes(config2, docs) {
77301
77289
  config: config2,
77302
77290
  filepath: filename,
77303
77291
  selections: definition.selectionSet.selections,
77304
- fragmentDefinitions,
77305
- keepFragmentSpreadNodes: true
77292
+ fragmentDefinitions
77306
77293
  });
77307
77294
  if (definition?.kind === "OperationDefinition") {
77308
77295
  await generateOperationTypeDefs(
@@ -80072,8 +80059,8 @@ async function updatePackageJSON(targetPath) {
80072
80059
  }
80073
80060
  packageJSON.devDependencies = {
80074
80061
  ...packageJSON.devDependencies,
80075
- houdini: "^1.2.1",
80076
- "houdini-svelte": "^1.2.1"
80062
+ houdini: "^1.2.2",
80063
+ "houdini-svelte": "^1.2.2"
80077
80064
  };
80078
80065
  await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
80079
80066
  }
@@ -2,7 +2,7 @@ import * as graphql from 'graphql';
2
2
  import type { Config, Document } from '../../../lib';
3
3
  import { type MutationOperation, type SubscriptionSelection } from '../../../runtime/lib/types';
4
4
  export default function (args: Omit<Parameters<typeof prepareSelection>[0], 'typeMap' | 'abstractTypes'>): SubscriptionSelection;
5
- declare function prepareSelection({ config, filepath, rootType, selections, operations, path, document, inConnection, typeMap, abstractTypes, globalLoading, }: {
5
+ declare function prepareSelection({ config, filepath, rootType, selections, operations, path, document, inConnection, typeMap, abstractTypes, globalLoading, includeFragments, }: {
6
6
  config: Config;
7
7
  filepath: string;
8
8
  rootType: string;
@@ -16,5 +16,6 @@ declare function prepareSelection({ config, filepath, rootType, selections, oper
16
16
  typeMap: Record<string, string[]>;
17
17
  abstractTypes: string[];
18
18
  globalLoading?: boolean;
19
+ includeFragments?: boolean;
19
20
  }): SubscriptionSelection;
20
21
  export {};
@@ -1,13 +1,11 @@
1
1
  import type graphql from 'graphql';
2
2
  import type { Config } from '../../lib';
3
- export declare function flattenSelections({ config, filepath, selections, fragmentDefinitions, ignoreMaskDisable, keepFragmentSpreadNodes, hoistFragments, }: {
3
+ export declare function flattenSelections({ config, filepath, selections, fragmentDefinitions, applyFragments, }: {
4
4
  config: Config;
5
5
  filepath: string;
6
6
  selections: readonly graphql.SelectionNode[];
7
7
  fragmentDefinitions: {
8
8
  [name: string]: graphql.FragmentDefinitionNode;
9
9
  };
10
- ignoreMaskDisable?: boolean;
11
- keepFragmentSpreadNodes?: boolean;
12
- hoistFragments?: boolean;
10
+ applyFragments?: boolean;
13
11
  }): readonly graphql.SelectionNode[];