houdini-svelte 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.
@@ -149450,18 +149450,14 @@ function flattenSelections({
149450
149450
  filepath,
149451
149451
  selections,
149452
149452
  fragmentDefinitions,
149453
- ignoreMaskDisable,
149454
- keepFragmentSpreadNodes,
149455
- hoistFragments
149453
+ applyFragments
149456
149454
  }) {
149457
149455
  const fields = new FieldCollection({
149458
149456
  config: config22,
149459
149457
  filepath,
149460
149458
  selections,
149461
149459
  fragmentDefinitions,
149462
- ignoreMaskDisable: !!ignoreMaskDisable,
149463
- keepFragmentSpreadNodes: !!keepFragmentSpreadNodes,
149464
- hoistFragments
149460
+ applyFragments: !!applyFragments
149465
149461
  });
149466
149462
  return fields.toSelectionSet();
149467
149463
  }
@@ -149472,18 +149468,14 @@ var FieldCollection = class {
149472
149468
  fields;
149473
149469
  inlineFragments;
149474
149470
  fragmentSpreads;
149475
- ignoreMaskDisable;
149476
- keepFragmentSpreadNodes;
149477
- hoistFragments;
149471
+ applyFragments;
149478
149472
  constructor(args) {
149479
149473
  this.config = args.config;
149480
149474
  this.fragmentDefinitions = args.fragmentDefinitions;
149481
- this.ignoreMaskDisable = args.ignoreMaskDisable;
149482
- this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
149475
+ this.applyFragments = args.applyFragments;
149483
149476
  this.fields = {};
149484
149477
  this.inlineFragments = {};
149485
149478
  this.fragmentSpreads = {};
149486
- this.hoistFragments = !!args.hoistFragments;
149487
149479
  this.filepath = args.filepath;
149488
149480
  for (const selection of args.selections) {
149489
149481
  this.add({ selection });
@@ -149493,21 +149485,18 @@ var FieldCollection = class {
149493
149485
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
149494
149486
  }
149495
149487
  add({ selection, external }) {
149496
- let includeFragments = this.config.defaultFragmentMasking === "disable";
149488
+ let include = this.config.defaultFragmentMasking === "disable";
149497
149489
  const maskEnableDirective = selection.directives?.find(
149498
149490
  ({ name }) => name.value === this.config.maskEnableDirective
149499
149491
  );
149500
149492
  if (maskEnableDirective) {
149501
- includeFragments = false;
149493
+ include = false;
149502
149494
  }
149503
149495
  const maskDisableDirective = selection.directives?.find(
149504
149496
  ({ name }) => name.value === this.config.maskDisableDirective
149505
149497
  );
149506
149498
  if (maskDisableDirective) {
149507
- includeFragments = true;
149508
- }
149509
- if (this.ignoreMaskDisable) {
149510
- includeFragments = true;
149499
+ include = true;
149511
149500
  }
149512
149501
  if (selection.kind === "Field") {
149513
149502
  const key = selection.alias?.value || selection.name.value;
@@ -149523,7 +149512,7 @@ var FieldCollection = class {
149523
149512
  external
149524
149513
  });
149525
149514
  }
149526
- if (!external && includeFragments) {
149515
+ if (this.applyFragments && !external) {
149527
149516
  this.fields[key].selection.fragmentSpreads = {
149528
149517
  ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
149529
149518
  ...this.fields[key].selection.fragmentSpreads
@@ -149537,16 +149526,13 @@ var FieldCollection = class {
149537
149526
  }
149538
149527
  }
149539
149528
  if (selection.kind === "InlineFragment" && selection.typeCondition) {
149540
- this.walkInlineFragment({ selection, external, hoistFragments: this.hoistFragments });
149529
+ this.walkInlineFragment({ selection, external });
149541
149530
  return;
149542
149531
  }
149543
149532
  if (selection.kind === "FragmentSpread") {
149544
- if (this.keepFragmentSpreadNodes && !external) {
149533
+ if (!external || include) {
149545
149534
  this.fragmentSpreads[selection.name.value] = selection;
149546
149535
  }
149547
- if (!includeFragments) {
149548
- return;
149549
- }
149550
149536
  const definition = this.fragmentDefinitions[selection.name.value];
149551
149537
  if (!definition) {
149552
149538
  throw new HoudiniError2({
@@ -149554,23 +149540,25 @@ var FieldCollection = class {
149554
149540
  message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
149555
149541
  });
149556
149542
  }
149557
- this.add({
149558
- selection: {
149559
- kind: "InlineFragment",
149560
- typeCondition: {
149561
- kind: "NamedType",
149562
- name: {
149563
- kind: "Name",
149564
- value: definition.typeCondition.name.value
149543
+ if (this.applyFragments || include) {
149544
+ this.add({
149545
+ selection: {
149546
+ kind: "InlineFragment",
149547
+ typeCondition: {
149548
+ kind: "NamedType",
149549
+ name: {
149550
+ kind: "Name",
149551
+ value: definition.typeCondition.name.value
149552
+ }
149553
+ },
149554
+ selectionSet: {
149555
+ kind: "SelectionSet",
149556
+ selections: [...definition.selectionSet.selections]
149565
149557
  }
149566
149558
  },
149567
- selectionSet: {
149568
- kind: "SelectionSet",
149569
- selections: [...definition.selectionSet.selections]
149570
- }
149571
- },
149572
- external
149573
- });
149559
+ external: !include
149560
+ });
149561
+ }
149574
149562
  }
149575
149563
  }
149576
149564
  collectFragmentSpreads(selections, result = {}) {
@@ -149627,8 +149615,7 @@ var FieldCollection = class {
149627
149615
  }
149628
149616
  walkInlineFragment({
149629
149617
  selection,
149630
- external,
149631
- hoistFragments
149618
+ external
149632
149619
  }) {
149633
149620
  const key = selection.typeCondition.name.value;
149634
149621
  if (!this.inlineFragments[key]) {
@@ -149638,7 +149625,7 @@ var FieldCollection = class {
149638
149625
  };
149639
149626
  }
149640
149627
  for (const subselect of selection.selectionSet.selections || []) {
149641
- if (subselect.kind === "FragmentSpread" && !hoistFragments || subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
149628
+ if (subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
149642
149629
  this.inlineFragments[key].selection.add({
149643
149630
  selection: subselect,
149644
149631
  external
@@ -149647,11 +149634,11 @@ var FieldCollection = class {
149647
149634
  } else if (subselect.kind === "FragmentSpread") {
149648
149635
  this.add({
149649
149636
  selection: subselect,
149650
- external: true
149637
+ external
149651
149638
  });
149652
149639
  continue;
149653
149640
  } else {
149654
- this.walkInlineFragment({ selection: subselect, external, hoistFragments });
149641
+ this.walkInlineFragment({ selection: subselect, external });
149655
149642
  }
149656
149643
  }
149657
149644
  }
@@ -149661,9 +149648,7 @@ var FieldCollection = class {
149661
149648
  fragmentDefinitions: this.fragmentDefinitions,
149662
149649
  selections: [],
149663
149650
  filepath: this.filepath,
149664
- ignoreMaskDisable: this.ignoreMaskDisable,
149665
- keepFragmentSpreadNodes: this.keepFragmentSpreadNodes,
149666
- hoistFragments: this.hoistFragments
149651
+ applyFragments: this.applyFragments
149667
149652
  });
149668
149653
  }
149669
149654
  };
@@ -151539,7 +151524,8 @@ function prepareSelection({
151539
151524
  inConnection,
151540
151525
  typeMap,
151541
151526
  abstractTypes,
151542
- globalLoading
151527
+ globalLoading,
151528
+ includeFragments
151543
151529
  }) {
151544
151530
  let object = {};
151545
151531
  const loadingTypes = [];
@@ -151559,7 +151545,8 @@ function prepareSelection({
151559
151545
  document: document2,
151560
151546
  typeMap,
151561
151547
  abstractTypes,
151562
- globalLoading
151548
+ globalLoading,
151549
+ includeFragments
151563
151550
  }).fields || {}
151564
151551
  );
151565
151552
  } else {
@@ -151607,7 +151594,8 @@ function prepareSelection({
151607
151594
  document: document2,
151608
151595
  typeMap,
151609
151596
  abstractTypes,
151610
- globalLoading
151597
+ globalLoading,
151598
+ includeFragments
151611
151599
  }).fields
151612
151600
  };
151613
151601
  if (field.directives?.find((d) => d.name.value === config22.loadingDirective)) {
@@ -151725,7 +151713,8 @@ function prepareSelection({
151725
151713
  inConnection: connectionState,
151726
151714
  typeMap,
151727
151715
  abstractTypes,
151728
- globalLoading: forceLoading
151716
+ globalLoading: forceLoading,
151717
+ includeFragments
151729
151718
  });
151730
151719
  if (Object.values(fieldObj.selection.fields ?? {}).some((field2) => field2.required)) {
151731
151720
  fieldObj.nullable = true;
@@ -152056,14 +152045,13 @@ function artifactGenerator(stats) {
152056
152045
  document: doc,
152057
152046
  rootType,
152058
152047
  globalLoading,
152048
+ includeFragments: doc.kind !== ArtifactKind2.Fragment,
152059
152049
  selections: flattenSelections({
152060
152050
  config: config22,
152061
152051
  filepath: doc.filename,
152062
152052
  selections: selectionSet.selections,
152063
152053
  fragmentDefinitions,
152064
- ignoreMaskDisable: docKind !== "HoudiniFragment",
152065
- keepFragmentSpreadNodes: true,
152066
- hoistFragments: true
152054
+ applyFragments: doc.kind !== ArtifactKind2.Fragment
152067
152055
  }),
152068
152056
  operations: operationsByPath(
152069
152057
  config22,
@@ -153000,8 +152988,7 @@ async function generateDocumentTypes(config22, docs) {
153000
152988
  config: config22,
153001
152989
  filepath: filename,
153002
152990
  selections: definition.selectionSet.selections,
153003
- fragmentDefinitions,
153004
- keepFragmentSpreadNodes: true
152991
+ fragmentDefinitions
153005
152992
  });
153006
152993
  if (definition?.kind === "OperationDefinition") {
153007
152994
  await generateOperationTypeDefs(
@@ -149437,18 +149437,14 @@ function flattenSelections({
149437
149437
  filepath,
149438
149438
  selections,
149439
149439
  fragmentDefinitions,
149440
- ignoreMaskDisable,
149441
- keepFragmentSpreadNodes,
149442
- hoistFragments
149440
+ applyFragments
149443
149441
  }) {
149444
149442
  const fields = new FieldCollection({
149445
149443
  config: config22,
149446
149444
  filepath,
149447
149445
  selections,
149448
149446
  fragmentDefinitions,
149449
- ignoreMaskDisable: !!ignoreMaskDisable,
149450
- keepFragmentSpreadNodes: !!keepFragmentSpreadNodes,
149451
- hoistFragments
149447
+ applyFragments: !!applyFragments
149452
149448
  });
149453
149449
  return fields.toSelectionSet();
149454
149450
  }
@@ -149459,18 +149455,14 @@ var FieldCollection = class {
149459
149455
  fields;
149460
149456
  inlineFragments;
149461
149457
  fragmentSpreads;
149462
- ignoreMaskDisable;
149463
- keepFragmentSpreadNodes;
149464
- hoistFragments;
149458
+ applyFragments;
149465
149459
  constructor(args) {
149466
149460
  this.config = args.config;
149467
149461
  this.fragmentDefinitions = args.fragmentDefinitions;
149468
- this.ignoreMaskDisable = args.ignoreMaskDisable;
149469
- this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
149462
+ this.applyFragments = args.applyFragments;
149470
149463
  this.fields = {};
149471
149464
  this.inlineFragments = {};
149472
149465
  this.fragmentSpreads = {};
149473
- this.hoistFragments = !!args.hoistFragments;
149474
149466
  this.filepath = args.filepath;
149475
149467
  for (const selection of args.selections) {
149476
149468
  this.add({ selection });
@@ -149480,21 +149472,18 @@ var FieldCollection = class {
149480
149472
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
149481
149473
  }
149482
149474
  add({ selection, external }) {
149483
- let includeFragments = this.config.defaultFragmentMasking === "disable";
149475
+ let include = this.config.defaultFragmentMasking === "disable";
149484
149476
  const maskEnableDirective = selection.directives?.find(
149485
149477
  ({ name }) => name.value === this.config.maskEnableDirective
149486
149478
  );
149487
149479
  if (maskEnableDirective) {
149488
- includeFragments = false;
149480
+ include = false;
149489
149481
  }
149490
149482
  const maskDisableDirective = selection.directives?.find(
149491
149483
  ({ name }) => name.value === this.config.maskDisableDirective
149492
149484
  );
149493
149485
  if (maskDisableDirective) {
149494
- includeFragments = true;
149495
- }
149496
- if (this.ignoreMaskDisable) {
149497
- includeFragments = true;
149486
+ include = true;
149498
149487
  }
149499
149488
  if (selection.kind === "Field") {
149500
149489
  const key = selection.alias?.value || selection.name.value;
@@ -149510,7 +149499,7 @@ var FieldCollection = class {
149510
149499
  external
149511
149500
  });
149512
149501
  }
149513
- if (!external && includeFragments) {
149502
+ if (this.applyFragments && !external) {
149514
149503
  this.fields[key].selection.fragmentSpreads = {
149515
149504
  ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
149516
149505
  ...this.fields[key].selection.fragmentSpreads
@@ -149524,16 +149513,13 @@ var FieldCollection = class {
149524
149513
  }
149525
149514
  }
149526
149515
  if (selection.kind === "InlineFragment" && selection.typeCondition) {
149527
- this.walkInlineFragment({ selection, external, hoistFragments: this.hoistFragments });
149516
+ this.walkInlineFragment({ selection, external });
149528
149517
  return;
149529
149518
  }
149530
149519
  if (selection.kind === "FragmentSpread") {
149531
- if (this.keepFragmentSpreadNodes && !external) {
149520
+ if (!external || include) {
149532
149521
  this.fragmentSpreads[selection.name.value] = selection;
149533
149522
  }
149534
- if (!includeFragments) {
149535
- return;
149536
- }
149537
149523
  const definition = this.fragmentDefinitions[selection.name.value];
149538
149524
  if (!definition) {
149539
149525
  throw new HoudiniError2({
@@ -149541,23 +149527,25 @@ var FieldCollection = class {
149541
149527
  message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
149542
149528
  });
149543
149529
  }
149544
- this.add({
149545
- selection: {
149546
- kind: "InlineFragment",
149547
- typeCondition: {
149548
- kind: "NamedType",
149549
- name: {
149550
- kind: "Name",
149551
- value: definition.typeCondition.name.value
149530
+ if (this.applyFragments || include) {
149531
+ this.add({
149532
+ selection: {
149533
+ kind: "InlineFragment",
149534
+ typeCondition: {
149535
+ kind: "NamedType",
149536
+ name: {
149537
+ kind: "Name",
149538
+ value: definition.typeCondition.name.value
149539
+ }
149540
+ },
149541
+ selectionSet: {
149542
+ kind: "SelectionSet",
149543
+ selections: [...definition.selectionSet.selections]
149552
149544
  }
149553
149545
  },
149554
- selectionSet: {
149555
- kind: "SelectionSet",
149556
- selections: [...definition.selectionSet.selections]
149557
- }
149558
- },
149559
- external
149560
- });
149546
+ external: !include
149547
+ });
149548
+ }
149561
149549
  }
149562
149550
  }
149563
149551
  collectFragmentSpreads(selections, result = {}) {
@@ -149614,8 +149602,7 @@ var FieldCollection = class {
149614
149602
  }
149615
149603
  walkInlineFragment({
149616
149604
  selection,
149617
- external,
149618
- hoistFragments
149605
+ external
149619
149606
  }) {
149620
149607
  const key = selection.typeCondition.name.value;
149621
149608
  if (!this.inlineFragments[key]) {
@@ -149625,7 +149612,7 @@ var FieldCollection = class {
149625
149612
  };
149626
149613
  }
149627
149614
  for (const subselect of selection.selectionSet.selections || []) {
149628
- if (subselect.kind === "FragmentSpread" && !hoistFragments || subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
149615
+ if (subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
149629
149616
  this.inlineFragments[key].selection.add({
149630
149617
  selection: subselect,
149631
149618
  external
@@ -149634,11 +149621,11 @@ var FieldCollection = class {
149634
149621
  } else if (subselect.kind === "FragmentSpread") {
149635
149622
  this.add({
149636
149623
  selection: subselect,
149637
- external: true
149624
+ external
149638
149625
  });
149639
149626
  continue;
149640
149627
  } else {
149641
- this.walkInlineFragment({ selection: subselect, external, hoistFragments });
149628
+ this.walkInlineFragment({ selection: subselect, external });
149642
149629
  }
149643
149630
  }
149644
149631
  }
@@ -149648,9 +149635,7 @@ var FieldCollection = class {
149648
149635
  fragmentDefinitions: this.fragmentDefinitions,
149649
149636
  selections: [],
149650
149637
  filepath: this.filepath,
149651
- ignoreMaskDisable: this.ignoreMaskDisable,
149652
- keepFragmentSpreadNodes: this.keepFragmentSpreadNodes,
149653
- hoistFragments: this.hoistFragments
149638
+ applyFragments: this.applyFragments
149654
149639
  });
149655
149640
  }
149656
149641
  };
@@ -151526,7 +151511,8 @@ function prepareSelection({
151526
151511
  inConnection,
151527
151512
  typeMap,
151528
151513
  abstractTypes,
151529
- globalLoading
151514
+ globalLoading,
151515
+ includeFragments
151530
151516
  }) {
151531
151517
  let object = {};
151532
151518
  const loadingTypes = [];
@@ -151546,7 +151532,8 @@ function prepareSelection({
151546
151532
  document: document2,
151547
151533
  typeMap,
151548
151534
  abstractTypes,
151549
- globalLoading
151535
+ globalLoading,
151536
+ includeFragments
151550
151537
  }).fields || {}
151551
151538
  );
151552
151539
  } else {
@@ -151594,7 +151581,8 @@ function prepareSelection({
151594
151581
  document: document2,
151595
151582
  typeMap,
151596
151583
  abstractTypes,
151597
- globalLoading
151584
+ globalLoading,
151585
+ includeFragments
151598
151586
  }).fields
151599
151587
  };
151600
151588
  if (field.directives?.find((d) => d.name.value === config22.loadingDirective)) {
@@ -151712,7 +151700,8 @@ function prepareSelection({
151712
151700
  inConnection: connectionState,
151713
151701
  typeMap,
151714
151702
  abstractTypes,
151715
- globalLoading: forceLoading
151703
+ globalLoading: forceLoading,
151704
+ includeFragments
151716
151705
  });
151717
151706
  if (Object.values(fieldObj.selection.fields ?? {}).some((field2) => field2.required)) {
151718
151707
  fieldObj.nullable = true;
@@ -152043,14 +152032,13 @@ function artifactGenerator(stats) {
152043
152032
  document: doc,
152044
152033
  rootType,
152045
152034
  globalLoading,
152035
+ includeFragments: doc.kind !== ArtifactKind2.Fragment,
152046
152036
  selections: flattenSelections({
152047
152037
  config: config22,
152048
152038
  filepath: doc.filename,
152049
152039
  selections: selectionSet.selections,
152050
152040
  fragmentDefinitions,
152051
- ignoreMaskDisable: docKind !== "HoudiniFragment",
152052
- keepFragmentSpreadNodes: true,
152053
- hoistFragments: true
152041
+ applyFragments: doc.kind !== ArtifactKind2.Fragment
152054
152042
  }),
152055
152043
  operations: operationsByPath(
152056
152044
  config22,
@@ -152987,8 +152975,7 @@ async function generateDocumentTypes(config22, docs) {
152987
152975
  config: config22,
152988
152976
  filepath: filename,
152989
152977
  selections: definition.selectionSet.selections,
152990
- fragmentDefinitions,
152991
- keepFragmentSpreadNodes: true
152978
+ fragmentDefinitions
152992
152979
  });
152993
152980
  if (definition?.kind === "OperationDefinition") {
152994
152981
  await generateOperationTypeDefs(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-svelte",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "The svelte plugin for houdini",
5
5
  "keywords": [
6
6
  "typescript",
@@ -32,7 +32,7 @@
32
32
  "rollup": "^3.7.4",
33
33
  "svelte": "^3.57.0",
34
34
  "vite": "^4.1.1",
35
- "houdini": "^1.2.1"
35
+ "houdini": "^1.2.2"
36
36
  },
37
37
  "files": [
38
38
  "build"