houdini-svelte 1.2.0 → 1.2.1

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.
@@ -92670,7 +92670,7 @@ function deepMerge2(filepath, ...targets) {
92670
92670
  }
92671
92671
  async function parseJS(str, config4) {
92672
92672
  const defaultConfig = {
92673
- plugins: ["typescript", "importAssertions", "jsx"],
92673
+ plugins: ["typescript", "importAssertions"],
92674
92674
  sourceType: "module"
92675
92675
  };
92676
92676
  return (0, import_parser.parse)(str || "", config4 ? deepMerge2("", defaultConfig, config4) : defaultConfig).program;
@@ -92934,7 +92934,7 @@ function artifactData({
92934
92934
  config: config4,
92935
92935
  document: document2
92936
92936
  }) {
92937
- let isManualLoad = true;
92937
+ let isManualLoad = document2.filename.endsWith(".svelte");
92938
92938
  let set_blocking = void 0;
92939
92939
  graphql5.visit(document2.document, {
92940
92940
  Directive(node2, _, __, ___) {
@@ -186452,11 +186452,26 @@ async function fragmentTypedefs(input) {
186452
186452
  )
186453
186453
  )
186454
186454
  ]);
186455
+ const non_exhaustive = AST17.tsTypeLiteral([
186456
+ AST17.tsPropertySignature(
186457
+ AST17.literal("__typename"),
186458
+ AST17.tsTypeAnnotation(
186459
+ AST17.tsLiteralType(AST17.stringLiteral("non-exhaustive; don't match this"))
186460
+ )
186461
+ )
186462
+ ]);
186455
186463
  const initial_value_input = AST17.identifier("initialValue");
186456
- initial_value_input.typeAnnotation = AST17.tsTypeAnnotation(fragment_map);
186464
+ initial_value_input.typeAnnotation = AST17.tsTypeAnnotation(
186465
+ AST17.tsUnionType([fragment_map, non_exhaustive])
186466
+ );
186457
186467
  const initial_value_or_null_input = AST17.identifier("initialValue");
186458
186468
  initial_value_or_null_input.typeAnnotation = AST17.tsTypeAnnotation(
186459
- AST17.tsUnionType([fragment_map, AST17.tsNullKeyword(), AST17.tsUndefinedKeyword()])
186469
+ AST17.tsUnionType([
186470
+ fragment_map,
186471
+ AST17.tsNullKeyword(),
186472
+ AST17.tsUndefinedKeyword(),
186473
+ non_exhaustive
186474
+ ])
186460
186475
  );
186461
186476
  const document_input = AST17.identifier("document");
186462
186477
  document_input.typeAnnotation = AST17.tsTypeAnnotation(
@@ -92661,7 +92661,7 @@ function deepMerge2(filepath, ...targets) {
92661
92661
  }
92662
92662
  async function parseJS(str, config4) {
92663
92663
  const defaultConfig = {
92664
- plugins: ["typescript", "importAssertions", "jsx"],
92664
+ plugins: ["typescript", "importAssertions"],
92665
92665
  sourceType: "module"
92666
92666
  };
92667
92667
  return (0, import_parser.parse)(str || "", config4 ? deepMerge2("", defaultConfig, config4) : defaultConfig).program;
@@ -92925,7 +92925,7 @@ function artifactData({
92925
92925
  config: config4,
92926
92926
  document: document2
92927
92927
  }) {
92928
- let isManualLoad = true;
92928
+ let isManualLoad = document2.filename.endsWith(".svelte");
92929
92929
  let set_blocking = void 0;
92930
92930
  graphql5.visit(document2.document, {
92931
92931
  Directive(node2, _, __, ___) {
@@ -186442,11 +186442,26 @@ async function fragmentTypedefs(input) {
186442
186442
  )
186443
186443
  )
186444
186444
  ]);
186445
+ const non_exhaustive = AST17.tsTypeLiteral([
186446
+ AST17.tsPropertySignature(
186447
+ AST17.literal("__typename"),
186448
+ AST17.tsTypeAnnotation(
186449
+ AST17.tsLiteralType(AST17.stringLiteral("non-exhaustive; don't match this"))
186450
+ )
186451
+ )
186452
+ ]);
186445
186453
  const initial_value_input = AST17.identifier("initialValue");
186446
- initial_value_input.typeAnnotation = AST17.tsTypeAnnotation(fragment_map);
186454
+ initial_value_input.typeAnnotation = AST17.tsTypeAnnotation(
186455
+ AST17.tsUnionType([fragment_map, non_exhaustive])
186456
+ );
186447
186457
  const initial_value_or_null_input = AST17.identifier("initialValue");
186448
186458
  initial_value_or_null_input.typeAnnotation = AST17.tsTypeAnnotation(
186449
- AST17.tsUnionType([fragment_map, AST17.tsNullKeyword(), AST17.tsUndefinedKeyword()])
186459
+ AST17.tsUnionType([
186460
+ fragment_map,
186461
+ AST17.tsNullKeyword(),
186462
+ AST17.tsUndefinedKeyword(),
186463
+ non_exhaustive
186464
+ ])
186450
186465
  );
186451
186466
  const document_input = AST17.identifier("document");
186452
186467
  document_input.typeAnnotation = AST17.tsTypeAnnotation(
@@ -96751,7 +96751,7 @@ function deepMerge2(filepath, ...targets) {
96751
96751
  }
96752
96752
  async function parseJS(str, config4) {
96753
96753
  const defaultConfig = {
96754
- plugins: ["typescript", "importAssertions", "jsx"],
96754
+ plugins: ["typescript", "importAssertions"],
96755
96755
  sourceType: "module"
96756
96756
  };
96757
96757
  return (0, import_parser.parse)(str || "", config4 ? deepMerge2("", defaultConfig, config4) : defaultConfig).program;
@@ -96744,7 +96744,7 @@ function deepMerge2(filepath, ...targets) {
96744
96744
  }
96745
96745
  async function parseJS(str, config4) {
96746
96746
  const defaultConfig = {
96747
- plugins: ["typescript", "importAssertions", "jsx"],
96747
+ plugins: ["typescript", "importAssertions"],
96748
96748
  sourceType: "module"
96749
96749
  };
96750
96750
  return (0, import_parser.parse)(str || "", config4 ? deepMerge2("", defaultConfig, config4) : defaultConfig).program;
@@ -6,9 +6,9 @@ export declare function fragment<_Fragment extends Fragment<any>>(ref: _Fragment
6
6
  data: Readable<_Fragment>;
7
7
  artifact: FragmentArtifact;
8
8
  };
9
- export declare function fragment<_Fragment extends Fragment<any>>(ref: _Fragment | null, fragment: FragmentStore<_Fragment['shape'], {}>): Readable<Exclude<_Fragment['shape'], undefined> | null> & {
9
+ export declare function fragment<_Fragment extends Fragment<any>>(ref: _Fragment | null | undefined, fragment: FragmentStore<_Fragment['shape'], {}>): Readable<Exclude<_Fragment['shape'], undefined> | null> & {
10
10
  data: Readable<_Fragment | null>;
11
11
  artifact: FragmentArtifact;
12
12
  };
13
- export declare function paginatedFragment<_Fragment extends Fragment<any>>(initialValue: _Fragment | null, document: FragmentStore<_Fragment['shape'], {}>): FragmentStorePaginated<_Fragment['shape'], {}>;
13
+ export declare function paginatedFragment<_Fragment extends Fragment<any>>(initialValue: _Fragment | null | undefined, document: FragmentStore<_Fragment['shape'], {}>): FragmentStorePaginated<_Fragment['shape'], {}>;
14
14
  export declare function paginatedFragment<_Fragment extends Fragment<any>>(initialValue: _Fragment, document: FragmentStore<_Fragment['shape'], {}>): FragmentStorePaginated<_Fragment['shape'], {}>;
@@ -5,7 +5,9 @@ export declare class BaseStore<_Data extends GraphQLObject, _Input extends Graph
5
5
  #private;
6
6
  get artifact(): _Artifact;
7
7
  get name(): string;
8
- constructor(params: ObserveParams<_Data, _Artifact>);
8
+ constructor(params: ObserveParams<_Data, _Artifact> & {
9
+ initialize?: boolean;
10
+ });
9
11
  get observer(): DocumentStore<_Data, _Input>;
10
12
  subscribe(...args: Parameters<Readable<QueryResult<_Data, _Input>>['subscribe']>): () => void;
11
13
  setup(init?: boolean): void;
@@ -6,9 +6,9 @@ export declare function fragment<_Fragment extends Fragment<any>>(ref: _Fragment
6
6
  data: Readable<_Fragment>;
7
7
  artifact: FragmentArtifact;
8
8
  };
9
- export declare function fragment<_Fragment extends Fragment<any>>(ref: _Fragment | null, fragment: FragmentStore<_Fragment['shape'], {}>): Readable<Exclude<_Fragment['shape'], undefined> | null> & {
9
+ export declare function fragment<_Fragment extends Fragment<any>>(ref: _Fragment | null | undefined, fragment: FragmentStore<_Fragment['shape'], {}>): Readable<Exclude<_Fragment['shape'], undefined> | null> & {
10
10
  data: Readable<_Fragment | null>;
11
11
  artifact: FragmentArtifact;
12
12
  };
13
- export declare function paginatedFragment<_Fragment extends Fragment<any>>(initialValue: _Fragment | null, document: FragmentStore<_Fragment['shape'], {}>): FragmentStorePaginated<_Fragment['shape'], {}>;
13
+ export declare function paginatedFragment<_Fragment extends Fragment<any>>(initialValue: _Fragment | null | undefined, document: FragmentStore<_Fragment['shape'], {}>): FragmentStorePaginated<_Fragment['shape'], {}>;
14
14
  export declare function paginatedFragment<_Fragment extends Fragment<any>>(initialValue: _Fragment, document: FragmentStore<_Fragment['shape'], {}>): FragmentStorePaginated<_Fragment['shape'], {}>;
@@ -5,7 +5,9 @@ export declare class BaseStore<_Data extends GraphQLObject, _Input extends Graph
5
5
  #private;
6
6
  get artifact(): _Artifact;
7
7
  get name(): string;
8
- constructor(params: ObserveParams<_Data, _Artifact>);
8
+ constructor(params: ObserveParams<_Data, _Artifact> & {
9
+ initialize?: boolean;
10
+ });
9
11
  get observer(): DocumentStore<_Data, _Input>;
10
12
  subscribe(...args: Parameters<Readable<QueryResult<_Data, _Input>>['subscribe']>): () => void;
11
13
  setup(init?: boolean): void;
@@ -36,6 +36,9 @@ class BaseStore {
36
36
  #store;
37
37
  #unsubscribe = null;
38
38
  constructor(params) {
39
+ if (typeof params.initialize === "undefined") {
40
+ params.initialize = true;
41
+ }
39
42
  this.#store = new import_client.DocumentStore({
40
43
  artifact: params.artifact,
41
44
  client: null,
@@ -82,7 +85,7 @@ class BaseStore {
82
85
  this.#unsubscribe = this.observer.subscribe((value) => {
83
86
  this.#store.set(value);
84
87
  });
85
- if (init) {
88
+ if (init && this.#params.initialize) {
86
89
  return this.observer.send({
87
90
  setup: true,
88
91
  variables: (0, import_store.get)(this.observer).variables
@@ -43,7 +43,11 @@ class QueryStore extends import_base.BaseStore {
43
43
  storeName;
44
44
  constructor({ artifact, storeName, variables }) {
45
45
  const fetching = artifact.pluginData["houdini-svelte"]?.isManualLoad !== true;
46
- super({ artifact, fetching });
46
+ super({
47
+ artifact,
48
+ fetching,
49
+ initialize: !artifact.pluginData["houdini-svelte"].isManualLoad
50
+ });
47
51
  this.storeName = storeName;
48
52
  this.variables = variables;
49
53
  }
@@ -6,9 +6,9 @@ export declare function fragment<_Fragment extends Fragment<any>>(ref: _Fragment
6
6
  data: Readable<_Fragment>;
7
7
  artifact: FragmentArtifact;
8
8
  };
9
- export declare function fragment<_Fragment extends Fragment<any>>(ref: _Fragment | null, fragment: FragmentStore<_Fragment['shape'], {}>): Readable<Exclude<_Fragment['shape'], undefined> | null> & {
9
+ export declare function fragment<_Fragment extends Fragment<any>>(ref: _Fragment | null | undefined, fragment: FragmentStore<_Fragment['shape'], {}>): Readable<Exclude<_Fragment['shape'], undefined> | null> & {
10
10
  data: Readable<_Fragment | null>;
11
11
  artifact: FragmentArtifact;
12
12
  };
13
- export declare function paginatedFragment<_Fragment extends Fragment<any>>(initialValue: _Fragment | null, document: FragmentStore<_Fragment['shape'], {}>): FragmentStorePaginated<_Fragment['shape'], {}>;
13
+ export declare function paginatedFragment<_Fragment extends Fragment<any>>(initialValue: _Fragment | null | undefined, document: FragmentStore<_Fragment['shape'], {}>): FragmentStorePaginated<_Fragment['shape'], {}>;
14
14
  export declare function paginatedFragment<_Fragment extends Fragment<any>>(initialValue: _Fragment, document: FragmentStore<_Fragment['shape'], {}>): FragmentStorePaginated<_Fragment['shape'], {}>;
@@ -5,7 +5,9 @@ export declare class BaseStore<_Data extends GraphQLObject, _Input extends Graph
5
5
  #private;
6
6
  get artifact(): _Artifact;
7
7
  get name(): string;
8
- constructor(params: ObserveParams<_Data, _Artifact>);
8
+ constructor(params: ObserveParams<_Data, _Artifact> & {
9
+ initialize?: boolean;
10
+ });
9
11
  get observer(): DocumentStore<_Data, _Input>;
10
12
  subscribe(...args: Parameters<Readable<QueryResult<_Data, _Input>>['subscribe']>): () => void;
11
13
  setup(init?: boolean): void;
@@ -13,6 +13,9 @@ class BaseStore {
13
13
  #store;
14
14
  #unsubscribe = null;
15
15
  constructor(params) {
16
+ if (typeof params.initialize === "undefined") {
17
+ params.initialize = true;
18
+ }
16
19
  this.#store = new DocumentStore({
17
20
  artifact: params.artifact,
18
21
  client: null,
@@ -59,7 +62,7 @@ class BaseStore {
59
62
  this.#unsubscribe = this.observer.subscribe((value) => {
60
63
  this.#store.set(value);
61
64
  });
62
- if (init) {
65
+ if (init && this.#params.initialize) {
63
66
  return this.observer.send({
64
67
  setup: true,
65
68
  variables: get(this.observer).variables
@@ -13,7 +13,11 @@ class QueryStore extends BaseStore {
13
13
  storeName;
14
14
  constructor({ artifact, storeName, variables }) {
15
15
  const fetching = artifact.pluginData["houdini-svelte"]?.isManualLoad !== true;
16
- super({ artifact, fetching });
16
+ super({
17
+ artifact,
18
+ fetching,
19
+ initialize: !artifact.pluginData["houdini-svelte"].isManualLoad
20
+ });
17
21
  this.storeName = storeName;
18
22
  this.variables = variables;
19
23
  }
@@ -92673,7 +92673,7 @@ function deepMerge2(filepath, ...targets) {
92673
92673
  }
92674
92674
  async function parseJS(str, config5) {
92675
92675
  const defaultConfig = {
92676
- plugins: ["typescript", "importAssertions", "jsx"],
92676
+ plugins: ["typescript", "importAssertions"],
92677
92677
  sourceType: "module"
92678
92678
  };
92679
92679
  return (0, import_parser.parse)(str || "", config5 ? deepMerge2("", defaultConfig, config5) : defaultConfig).program;
@@ -149361,7 +149361,7 @@ function deepMerge22(filepath, ...targets) {
149361
149361
  }
149362
149362
  async function parseJS2(str, config22) {
149363
149363
  const defaultConfig = {
149364
- plugins: ["typescript", "importAssertions", "jsx"],
149364
+ plugins: ["typescript", "importAssertions"],
149365
149365
  sourceType: "module"
149366
149366
  };
149367
149367
  return (0, import_parser2.parse)(str || "", config22 ? deepMerge22("", defaultConfig, config22) : defaultConfig).program;
@@ -149451,7 +149451,8 @@ function flattenSelections({
149451
149451
  selections,
149452
149452
  fragmentDefinitions,
149453
149453
  ignoreMaskDisable,
149454
- keepFragmentSpreadNodes
149454
+ keepFragmentSpreadNodes,
149455
+ hoistFragments
149455
149456
  }) {
149456
149457
  const fields = new FieldCollection({
149457
149458
  config: config22,
@@ -149459,7 +149460,8 @@ function flattenSelections({
149459
149460
  selections,
149460
149461
  fragmentDefinitions,
149461
149462
  ignoreMaskDisable: !!ignoreMaskDisable,
149462
- keepFragmentSpreadNodes: !!keepFragmentSpreadNodes
149463
+ keepFragmentSpreadNodes: !!keepFragmentSpreadNodes,
149464
+ hoistFragments
149463
149465
  });
149464
149466
  return fields.toSelectionSet();
149465
149467
  }
@@ -149472,6 +149474,7 @@ var FieldCollection = class {
149472
149474
  fragmentSpreads;
149473
149475
  ignoreMaskDisable;
149474
149476
  keepFragmentSpreadNodes;
149477
+ hoistFragments;
149475
149478
  constructor(args) {
149476
149479
  this.config = args.config;
149477
149480
  this.fragmentDefinitions = args.fragmentDefinitions;
@@ -149480,15 +149483,32 @@ var FieldCollection = class {
149480
149483
  this.fields = {};
149481
149484
  this.inlineFragments = {};
149482
149485
  this.fragmentSpreads = {};
149486
+ this.hoistFragments = !!args.hoistFragments;
149483
149487
  this.filepath = args.filepath;
149484
149488
  for (const selection of args.selections) {
149485
- this.add(selection);
149489
+ this.add({ selection });
149486
149490
  }
149487
149491
  }
149488
149492
  get size() {
149489
149493
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
149490
149494
  }
149491
- add(selection) {
149495
+ add({ selection, external }) {
149496
+ let includeFragments = this.config.defaultFragmentMasking === "disable";
149497
+ const maskEnableDirective = selection.directives?.find(
149498
+ ({ name }) => name.value === this.config.maskEnableDirective
149499
+ );
149500
+ if (maskEnableDirective) {
149501
+ includeFragments = false;
149502
+ }
149503
+ const maskDisableDirective = selection.directives?.find(
149504
+ ({ name }) => name.value === this.config.maskDisableDirective
149505
+ );
149506
+ if (maskDisableDirective) {
149507
+ includeFragments = true;
149508
+ }
149509
+ if (this.ignoreMaskDisable) {
149510
+ includeFragments = true;
149511
+ }
149492
149512
  if (selection.kind === "Field") {
149493
149513
  const key = selection.alias?.value || selection.name.value;
149494
149514
  if (!this.fields[key]) {
@@ -149498,41 +149518,30 @@ var FieldCollection = class {
149498
149518
  };
149499
149519
  }
149500
149520
  for (const subselect of selection.selectionSet?.selections || []) {
149501
- this.fields[key].selection.add(subselect);
149521
+ this.fields[key].selection.add({
149522
+ selection: subselect,
149523
+ external
149524
+ });
149525
+ }
149526
+ if (!external && includeFragments) {
149527
+ this.fields[key].selection.fragmentSpreads = {
149528
+ ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
149529
+ ...this.fields[key].selection.fragmentSpreads
149530
+ };
149502
149531
  }
149503
- this.fields[key].selection.fragmentSpreads = {
149504
- ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
149505
- ...this.fields[key].selection.fragmentSpreads
149506
- };
149507
149532
  return;
149508
149533
  }
149509
149534
  if (selection.kind === "InlineFragment" && !selection.typeCondition) {
149510
149535
  for (const subselect of selection.selectionSet.selections) {
149511
- this.add(subselect);
149536
+ this.add({ selection: subselect, external });
149512
149537
  }
149513
149538
  }
149514
149539
  if (selection.kind === "InlineFragment" && selection.typeCondition) {
149515
- this.walkInlineFragment(selection);
149540
+ this.walkInlineFragment({ selection, external, hoistFragments: this.hoistFragments });
149516
149541
  return;
149517
149542
  }
149518
149543
  if (selection.kind === "FragmentSpread") {
149519
- let includeFragments = this.config.defaultFragmentMasking === "disable";
149520
- const maskEnableDirective = selection.directives?.find(
149521
- ({ name }) => name.value === this.config.maskEnableDirective
149522
- );
149523
- if (maskEnableDirective) {
149524
- includeFragments = false;
149525
- }
149526
- const maskDisableDirective = selection.directives?.find(
149527
- ({ name }) => name.value === this.config.maskDisableDirective
149528
- );
149529
- if (maskDisableDirective) {
149530
- includeFragments = true;
149531
- }
149532
- if (this.ignoreMaskDisable) {
149533
- includeFragments = true;
149534
- }
149535
- if (this.keepFragmentSpreadNodes) {
149544
+ if (this.keepFragmentSpreadNodes && !external) {
149536
149545
  this.fragmentSpreads[selection.name.value] = selection;
149537
149546
  }
149538
149547
  if (!includeFragments) {
@@ -149546,18 +149555,21 @@ var FieldCollection = class {
149546
149555
  });
149547
149556
  }
149548
149557
  this.add({
149549
- kind: "InlineFragment",
149550
- typeCondition: {
149551
- kind: "NamedType",
149552
- name: {
149553
- kind: "Name",
149554
- value: definition.typeCondition.name.value
149558
+ selection: {
149559
+ kind: "InlineFragment",
149560
+ typeCondition: {
149561
+ kind: "NamedType",
149562
+ name: {
149563
+ kind: "Name",
149564
+ value: definition.typeCondition.name.value
149565
+ }
149566
+ },
149567
+ selectionSet: {
149568
+ kind: "SelectionSet",
149569
+ selections: [...definition.selectionSet.selections]
149555
149570
  }
149556
149571
  },
149557
- selectionSet: {
149558
- kind: "SelectionSet",
149559
- selections: [...definition.selectionSet.selections]
149560
- }
149572
+ external
149561
149573
  });
149562
149574
  }
149563
149575
  }
@@ -149613,7 +149625,11 @@ var FieldCollection = class {
149613
149625
  })
149614
149626
  );
149615
149627
  }
149616
- walkInlineFragment(selection) {
149628
+ walkInlineFragment({
149629
+ selection,
149630
+ external,
149631
+ hoistFragments
149632
+ }) {
149617
149633
  const key = selection.typeCondition.name.value;
149618
149634
  if (!this.inlineFragments[key]) {
149619
149635
  this.inlineFragments[key] = {
@@ -149622,11 +149638,21 @@ var FieldCollection = class {
149622
149638
  };
149623
149639
  }
149624
149640
  for (const subselect of selection.selectionSet.selections || []) {
149625
- if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
149626
- this.inlineFragments[key].selection.add(subselect);
149641
+ if (subselect.kind === "FragmentSpread" && !hoistFragments || subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
149642
+ this.inlineFragments[key].selection.add({
149643
+ selection: subselect,
149644
+ external
149645
+ });
149646
+ continue;
149647
+ } else if (subselect.kind === "FragmentSpread") {
149648
+ this.add({
149649
+ selection: subselect,
149650
+ external: true
149651
+ });
149627
149652
  continue;
149653
+ } else {
149654
+ this.walkInlineFragment({ selection: subselect, external, hoistFragments });
149628
149655
  }
149629
- this.walkInlineFragment(subselect);
149630
149656
  }
149631
149657
  }
149632
149658
  empty() {
@@ -149636,7 +149662,8 @@ var FieldCollection = class {
149636
149662
  selections: [],
149637
149663
  filepath: this.filepath,
149638
149664
  ignoreMaskDisable: this.ignoreMaskDisable,
149639
- keepFragmentSpreadNodes: this.keepFragmentSpreadNodes
149665
+ keepFragmentSpreadNodes: this.keepFragmentSpreadNodes,
149666
+ hoistFragments: this.hoistFragments
149640
149667
  });
149641
149668
  }
149642
149669
  };
@@ -152035,7 +152062,8 @@ function artifactGenerator(stats) {
152035
152062
  selections: selectionSet.selections,
152036
152063
  fragmentDefinitions,
152037
152064
  ignoreMaskDisable: docKind !== "HoudiniFragment",
152038
- keepFragmentSpreadNodes: true
152065
+ keepFragmentSpreadNodes: true,
152066
+ hoistFragments: true
152039
152067
  }),
152040
152068
  operations: operationsByPath(
152041
152069
  config22,
@@ -212213,6 +212241,8 @@ function testConfigFile({ plugins, ...config22 } = {}) {
212213
212241
  customIdList: [CustomIdType]!
212214
212242
  nodes(ids: [ID!]!): [Node!]!
212215
212243
  monkeys: MonkeyConnection!
212244
+ animals(first: Int, after: String): AnimalConnection
212245
+
212216
212246
  }
212217
212247
 
212218
212248
  input UserFilter {
@@ -212469,7 +212499,7 @@ function artifactData({
212469
212499
  config: config5,
212470
212500
  document: document2
212471
212501
  }) {
212472
- let isManualLoad = true;
212502
+ let isManualLoad = document2.filename.endsWith(".svelte");
212473
212503
  let set_blocking = void 0;
212474
212504
  graphql29.visit(document2.document, {
212475
212505
  Directive(node2, _, __, ___) {
@@ -305987,11 +306017,26 @@ async function fragmentTypedefs(input) {
305987
306017
  )
305988
306018
  )
305989
306019
  ]);
306020
+ const non_exhaustive = AST18.tsTypeLiteral([
306021
+ AST18.tsPropertySignature(
306022
+ AST18.literal("__typename"),
306023
+ AST18.tsTypeAnnotation(
306024
+ AST18.tsLiteralType(AST18.stringLiteral("non-exhaustive; don't match this"))
306025
+ )
306026
+ )
306027
+ ]);
305990
306028
  const initial_value_input = AST18.identifier("initialValue");
305991
- initial_value_input.typeAnnotation = AST18.tsTypeAnnotation(fragment_map);
306029
+ initial_value_input.typeAnnotation = AST18.tsTypeAnnotation(
306030
+ AST18.tsUnionType([fragment_map, non_exhaustive])
306031
+ );
305992
306032
  const initial_value_or_null_input = AST18.identifier("initialValue");
305993
306033
  initial_value_or_null_input.typeAnnotation = AST18.tsTypeAnnotation(
305994
- AST18.tsUnionType([fragment_map, AST18.tsNullKeyword(), AST18.tsUndefinedKeyword()])
306034
+ AST18.tsUnionType([
306035
+ fragment_map,
306036
+ AST18.tsNullKeyword(),
306037
+ AST18.tsUndefinedKeyword(),
306038
+ non_exhaustive
306039
+ ])
305995
306040
  );
305996
306041
  const document_input = AST18.identifier("document");
305997
306042
  document_input.typeAnnotation = AST18.tsTypeAnnotation(
@@ -92661,7 +92661,7 @@ function deepMerge2(filepath, ...targets) {
92661
92661
  }
92662
92662
  async function parseJS(str, config5) {
92663
92663
  const defaultConfig = {
92664
- plugins: ["typescript", "importAssertions", "jsx"],
92664
+ plugins: ["typescript", "importAssertions"],
92665
92665
  sourceType: "module"
92666
92666
  };
92667
92667
  return (0, import_parser.parse)(str || "", config5 ? deepMerge2("", defaultConfig, config5) : defaultConfig).program;
@@ -149348,7 +149348,7 @@ function deepMerge22(filepath, ...targets) {
149348
149348
  }
149349
149349
  async function parseJS2(str, config22) {
149350
149350
  const defaultConfig = {
149351
- plugins: ["typescript", "importAssertions", "jsx"],
149351
+ plugins: ["typescript", "importAssertions"],
149352
149352
  sourceType: "module"
149353
149353
  };
149354
149354
  return (0, import_parser2.parse)(str || "", config22 ? deepMerge22("", defaultConfig, config22) : defaultConfig).program;
@@ -149438,7 +149438,8 @@ function flattenSelections({
149438
149438
  selections,
149439
149439
  fragmentDefinitions,
149440
149440
  ignoreMaskDisable,
149441
- keepFragmentSpreadNodes
149441
+ keepFragmentSpreadNodes,
149442
+ hoistFragments
149442
149443
  }) {
149443
149444
  const fields = new FieldCollection({
149444
149445
  config: config22,
@@ -149446,7 +149447,8 @@ function flattenSelections({
149446
149447
  selections,
149447
149448
  fragmentDefinitions,
149448
149449
  ignoreMaskDisable: !!ignoreMaskDisable,
149449
- keepFragmentSpreadNodes: !!keepFragmentSpreadNodes
149450
+ keepFragmentSpreadNodes: !!keepFragmentSpreadNodes,
149451
+ hoistFragments
149450
149452
  });
149451
149453
  return fields.toSelectionSet();
149452
149454
  }
@@ -149459,6 +149461,7 @@ var FieldCollection = class {
149459
149461
  fragmentSpreads;
149460
149462
  ignoreMaskDisable;
149461
149463
  keepFragmentSpreadNodes;
149464
+ hoistFragments;
149462
149465
  constructor(args) {
149463
149466
  this.config = args.config;
149464
149467
  this.fragmentDefinitions = args.fragmentDefinitions;
@@ -149467,15 +149470,32 @@ var FieldCollection = class {
149467
149470
  this.fields = {};
149468
149471
  this.inlineFragments = {};
149469
149472
  this.fragmentSpreads = {};
149473
+ this.hoistFragments = !!args.hoistFragments;
149470
149474
  this.filepath = args.filepath;
149471
149475
  for (const selection of args.selections) {
149472
- this.add(selection);
149476
+ this.add({ selection });
149473
149477
  }
149474
149478
  }
149475
149479
  get size() {
149476
149480
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
149477
149481
  }
149478
- add(selection) {
149482
+ add({ selection, external }) {
149483
+ let includeFragments = this.config.defaultFragmentMasking === "disable";
149484
+ const maskEnableDirective = selection.directives?.find(
149485
+ ({ name }) => name.value === this.config.maskEnableDirective
149486
+ );
149487
+ if (maskEnableDirective) {
149488
+ includeFragments = false;
149489
+ }
149490
+ const maskDisableDirective = selection.directives?.find(
149491
+ ({ name }) => name.value === this.config.maskDisableDirective
149492
+ );
149493
+ if (maskDisableDirective) {
149494
+ includeFragments = true;
149495
+ }
149496
+ if (this.ignoreMaskDisable) {
149497
+ includeFragments = true;
149498
+ }
149479
149499
  if (selection.kind === "Field") {
149480
149500
  const key = selection.alias?.value || selection.name.value;
149481
149501
  if (!this.fields[key]) {
@@ -149485,41 +149505,30 @@ var FieldCollection = class {
149485
149505
  };
149486
149506
  }
149487
149507
  for (const subselect of selection.selectionSet?.selections || []) {
149488
- this.fields[key].selection.add(subselect);
149508
+ this.fields[key].selection.add({
149509
+ selection: subselect,
149510
+ external
149511
+ });
149512
+ }
149513
+ if (!external && includeFragments) {
149514
+ this.fields[key].selection.fragmentSpreads = {
149515
+ ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
149516
+ ...this.fields[key].selection.fragmentSpreads
149517
+ };
149489
149518
  }
149490
- this.fields[key].selection.fragmentSpreads = {
149491
- ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
149492
- ...this.fields[key].selection.fragmentSpreads
149493
- };
149494
149519
  return;
149495
149520
  }
149496
149521
  if (selection.kind === "InlineFragment" && !selection.typeCondition) {
149497
149522
  for (const subselect of selection.selectionSet.selections) {
149498
- this.add(subselect);
149523
+ this.add({ selection: subselect, external });
149499
149524
  }
149500
149525
  }
149501
149526
  if (selection.kind === "InlineFragment" && selection.typeCondition) {
149502
- this.walkInlineFragment(selection);
149527
+ this.walkInlineFragment({ selection, external, hoistFragments: this.hoistFragments });
149503
149528
  return;
149504
149529
  }
149505
149530
  if (selection.kind === "FragmentSpread") {
149506
- let includeFragments = this.config.defaultFragmentMasking === "disable";
149507
- const maskEnableDirective = selection.directives?.find(
149508
- ({ name }) => name.value === this.config.maskEnableDirective
149509
- );
149510
- if (maskEnableDirective) {
149511
- includeFragments = false;
149512
- }
149513
- const maskDisableDirective = selection.directives?.find(
149514
- ({ name }) => name.value === this.config.maskDisableDirective
149515
- );
149516
- if (maskDisableDirective) {
149517
- includeFragments = true;
149518
- }
149519
- if (this.ignoreMaskDisable) {
149520
- includeFragments = true;
149521
- }
149522
- if (this.keepFragmentSpreadNodes) {
149531
+ if (this.keepFragmentSpreadNodes && !external) {
149523
149532
  this.fragmentSpreads[selection.name.value] = selection;
149524
149533
  }
149525
149534
  if (!includeFragments) {
@@ -149533,18 +149542,21 @@ var FieldCollection = class {
149533
149542
  });
149534
149543
  }
149535
149544
  this.add({
149536
- kind: "InlineFragment",
149537
- typeCondition: {
149538
- kind: "NamedType",
149539
- name: {
149540
- kind: "Name",
149541
- value: definition.typeCondition.name.value
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]
149542
149557
  }
149543
149558
  },
149544
- selectionSet: {
149545
- kind: "SelectionSet",
149546
- selections: [...definition.selectionSet.selections]
149547
- }
149559
+ external
149548
149560
  });
149549
149561
  }
149550
149562
  }
@@ -149600,7 +149612,11 @@ var FieldCollection = class {
149600
149612
  })
149601
149613
  );
149602
149614
  }
149603
- walkInlineFragment(selection) {
149615
+ walkInlineFragment({
149616
+ selection,
149617
+ external,
149618
+ hoistFragments
149619
+ }) {
149604
149620
  const key = selection.typeCondition.name.value;
149605
149621
  if (!this.inlineFragments[key]) {
149606
149622
  this.inlineFragments[key] = {
@@ -149609,11 +149625,21 @@ var FieldCollection = class {
149609
149625
  };
149610
149626
  }
149611
149627
  for (const subselect of selection.selectionSet.selections || []) {
149612
- if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
149613
- this.inlineFragments[key].selection.add(subselect);
149628
+ if (subselect.kind === "FragmentSpread" && !hoistFragments || subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
149629
+ this.inlineFragments[key].selection.add({
149630
+ selection: subselect,
149631
+ external
149632
+ });
149633
+ continue;
149634
+ } else if (subselect.kind === "FragmentSpread") {
149635
+ this.add({
149636
+ selection: subselect,
149637
+ external: true
149638
+ });
149614
149639
  continue;
149640
+ } else {
149641
+ this.walkInlineFragment({ selection: subselect, external, hoistFragments });
149615
149642
  }
149616
- this.walkInlineFragment(subselect);
149617
149643
  }
149618
149644
  }
149619
149645
  empty() {
@@ -149623,7 +149649,8 @@ var FieldCollection = class {
149623
149649
  selections: [],
149624
149650
  filepath: this.filepath,
149625
149651
  ignoreMaskDisable: this.ignoreMaskDisable,
149626
- keepFragmentSpreadNodes: this.keepFragmentSpreadNodes
149652
+ keepFragmentSpreadNodes: this.keepFragmentSpreadNodes,
149653
+ hoistFragments: this.hoistFragments
149627
149654
  });
149628
149655
  }
149629
149656
  };
@@ -152022,7 +152049,8 @@ function artifactGenerator(stats) {
152022
152049
  selections: selectionSet.selections,
152023
152050
  fragmentDefinitions,
152024
152051
  ignoreMaskDisable: docKind !== "HoudiniFragment",
152025
- keepFragmentSpreadNodes: true
152052
+ keepFragmentSpreadNodes: true,
152053
+ hoistFragments: true
152026
152054
  }),
152027
152055
  operations: operationsByPath(
152028
152056
  config22,
@@ -212199,6 +212227,8 @@ function testConfigFile({ plugins, ...config22 } = {}) {
212199
212227
  customIdList: [CustomIdType]!
212200
212228
  nodes(ids: [ID!]!): [Node!]!
212201
212229
  monkeys: MonkeyConnection!
212230
+ animals(first: Int, after: String): AnimalConnection
212231
+
212202
212232
  }
212203
212233
 
212204
212234
  input UserFilter {
@@ -212455,7 +212485,7 @@ function artifactData({
212455
212485
  config: config5,
212456
212486
  document: document2
212457
212487
  }) {
212458
- let isManualLoad = true;
212488
+ let isManualLoad = document2.filename.endsWith(".svelte");
212459
212489
  let set_blocking = void 0;
212460
212490
  graphql29.visit(document2.document, {
212461
212491
  Directive(node2, _, __, ___) {
@@ -305972,11 +306002,26 @@ async function fragmentTypedefs(input) {
305972
306002
  )
305973
306003
  )
305974
306004
  ]);
306005
+ const non_exhaustive = AST18.tsTypeLiteral([
306006
+ AST18.tsPropertySignature(
306007
+ AST18.literal("__typename"),
306008
+ AST18.tsTypeAnnotation(
306009
+ AST18.tsLiteralType(AST18.stringLiteral("non-exhaustive; don't match this"))
306010
+ )
306011
+ )
306012
+ ]);
305975
306013
  const initial_value_input = AST18.identifier("initialValue");
305976
- initial_value_input.typeAnnotation = AST18.tsTypeAnnotation(fragment_map);
306014
+ initial_value_input.typeAnnotation = AST18.tsTypeAnnotation(
306015
+ AST18.tsUnionType([fragment_map, non_exhaustive])
306016
+ );
305977
306017
  const initial_value_or_null_input = AST18.identifier("initialValue");
305978
306018
  initial_value_or_null_input.typeAnnotation = AST18.tsTypeAnnotation(
305979
- AST18.tsUnionType([fragment_map, AST18.tsNullKeyword(), AST18.tsUndefinedKeyword()])
306019
+ AST18.tsUnionType([
306020
+ fragment_map,
306021
+ AST18.tsNullKeyword(),
306022
+ AST18.tsUndefinedKeyword(),
306023
+ non_exhaustive
306024
+ ])
305980
306025
  );
305981
306026
  const document_input = AST18.identifier("document");
305982
306027
  document_input.typeAnnotation = AST18.tsTypeAnnotation(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-svelte",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
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.0"
35
+ "houdini": "^1.2.1"
36
36
  },
37
37
  "files": [
38
38
  "build"