houdini-svelte 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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;
@@ -149450,16 +149450,14 @@ function flattenSelections({
149450
149450
  filepath,
149451
149451
  selections,
149452
149452
  fragmentDefinitions,
149453
- ignoreMaskDisable,
149454
- keepFragmentSpreadNodes
149453
+ applyFragments
149455
149454
  }) {
149456
149455
  const fields = new FieldCollection({
149457
149456
  config: config22,
149458
149457
  filepath,
149459
149458
  selections,
149460
149459
  fragmentDefinitions,
149461
- ignoreMaskDisable: !!ignoreMaskDisable,
149462
- keepFragmentSpreadNodes: !!keepFragmentSpreadNodes
149460
+ applyFragments: !!applyFragments
149463
149461
  });
149464
149462
  return fields.toSelectionSet();
149465
149463
  }
@@ -149470,25 +149468,36 @@ var FieldCollection = class {
149470
149468
  fields;
149471
149469
  inlineFragments;
149472
149470
  fragmentSpreads;
149473
- ignoreMaskDisable;
149474
- keepFragmentSpreadNodes;
149471
+ applyFragments;
149475
149472
  constructor(args) {
149476
149473
  this.config = args.config;
149477
149474
  this.fragmentDefinitions = args.fragmentDefinitions;
149478
- this.ignoreMaskDisable = args.ignoreMaskDisable;
149479
- this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
149475
+ this.applyFragments = args.applyFragments;
149480
149476
  this.fields = {};
149481
149477
  this.inlineFragments = {};
149482
149478
  this.fragmentSpreads = {};
149483
149479
  this.filepath = args.filepath;
149484
149480
  for (const selection of args.selections) {
149485
- this.add(selection);
149481
+ this.add({ selection });
149486
149482
  }
149487
149483
  }
149488
149484
  get size() {
149489
149485
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
149490
149486
  }
149491
- add(selection) {
149487
+ add({ selection, external }) {
149488
+ let include = this.config.defaultFragmentMasking === "disable";
149489
+ const maskEnableDirective = selection.directives?.find(
149490
+ ({ name }) => name.value === this.config.maskEnableDirective
149491
+ );
149492
+ if (maskEnableDirective) {
149493
+ include = false;
149494
+ }
149495
+ const maskDisableDirective = selection.directives?.find(
149496
+ ({ name }) => name.value === this.config.maskDisableDirective
149497
+ );
149498
+ if (maskDisableDirective) {
149499
+ include = true;
149500
+ }
149492
149501
  if (selection.kind === "Field") {
149493
149502
  const key = selection.alias?.value || selection.name.value;
149494
149503
  if (!this.fields[key]) {
@@ -149498,46 +149507,32 @@ var FieldCollection = class {
149498
149507
  };
149499
149508
  }
149500
149509
  for (const subselect of selection.selectionSet?.selections || []) {
149501
- this.fields[key].selection.add(subselect);
149510
+ this.fields[key].selection.add({
149511
+ selection: subselect,
149512
+ external
149513
+ });
149514
+ }
149515
+ if (this.applyFragments && !external) {
149516
+ this.fields[key].selection.fragmentSpreads = {
149517
+ ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
149518
+ ...this.fields[key].selection.fragmentSpreads
149519
+ };
149502
149520
  }
149503
- this.fields[key].selection.fragmentSpreads = {
149504
- ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
149505
- ...this.fields[key].selection.fragmentSpreads
149506
- };
149507
149521
  return;
149508
149522
  }
149509
149523
  if (selection.kind === "InlineFragment" && !selection.typeCondition) {
149510
149524
  for (const subselect of selection.selectionSet.selections) {
149511
- this.add(subselect);
149525
+ this.add({ selection: subselect, external });
149512
149526
  }
149513
149527
  }
149514
149528
  if (selection.kind === "InlineFragment" && selection.typeCondition) {
149515
- this.walkInlineFragment(selection);
149529
+ this.walkInlineFragment({ selection, external });
149516
149530
  return;
149517
149531
  }
149518
149532
  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) {
149533
+ if (!external || include) {
149536
149534
  this.fragmentSpreads[selection.name.value] = selection;
149537
149535
  }
149538
- if (!includeFragments) {
149539
- return;
149540
- }
149541
149536
  const definition = this.fragmentDefinitions[selection.name.value];
149542
149537
  if (!definition) {
149543
149538
  throw new HoudiniError2({
@@ -149545,20 +149540,25 @@ var FieldCollection = class {
149545
149540
  message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
149546
149541
  });
149547
149542
  }
149548
- this.add({
149549
- kind: "InlineFragment",
149550
- typeCondition: {
149551
- kind: "NamedType",
149552
- name: {
149553
- kind: "Name",
149554
- value: definition.typeCondition.name.value
149555
- }
149556
- },
149557
- selectionSet: {
149558
- kind: "SelectionSet",
149559
- selections: [...definition.selectionSet.selections]
149560
- }
149561
- });
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]
149557
+ }
149558
+ },
149559
+ external: !include
149560
+ });
149561
+ }
149562
149562
  }
149563
149563
  }
149564
149564
  collectFragmentSpreads(selections, result = {}) {
@@ -149613,7 +149613,10 @@ var FieldCollection = class {
149613
149613
  })
149614
149614
  );
149615
149615
  }
149616
- walkInlineFragment(selection) {
149616
+ walkInlineFragment({
149617
+ selection,
149618
+ external
149619
+ }) {
149617
149620
  const key = selection.typeCondition.name.value;
149618
149621
  if (!this.inlineFragments[key]) {
149619
149622
  this.inlineFragments[key] = {
@@ -149622,11 +149625,21 @@ var FieldCollection = class {
149622
149625
  };
149623
149626
  }
149624
149627
  for (const subselect of selection.selectionSet.selections || []) {
149625
- if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
149626
- this.inlineFragments[key].selection.add(subselect);
149628
+ if (subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
149629
+ this.inlineFragments[key].selection.add({
149630
+ selection: subselect,
149631
+ external
149632
+ });
149627
149633
  continue;
149634
+ } else if (subselect.kind === "FragmentSpread") {
149635
+ this.add({
149636
+ selection: subselect,
149637
+ external
149638
+ });
149639
+ continue;
149640
+ } else {
149641
+ this.walkInlineFragment({ selection: subselect, external });
149628
149642
  }
149629
- this.walkInlineFragment(subselect);
149630
149643
  }
149631
149644
  }
149632
149645
  empty() {
@@ -149635,8 +149648,7 @@ var FieldCollection = class {
149635
149648
  fragmentDefinitions: this.fragmentDefinitions,
149636
149649
  selections: [],
149637
149650
  filepath: this.filepath,
149638
- ignoreMaskDisable: this.ignoreMaskDisable,
149639
- keepFragmentSpreadNodes: this.keepFragmentSpreadNodes
149651
+ applyFragments: this.applyFragments
149640
149652
  });
149641
149653
  }
149642
149654
  };
@@ -151512,7 +151524,8 @@ function prepareSelection({
151512
151524
  inConnection,
151513
151525
  typeMap,
151514
151526
  abstractTypes,
151515
- globalLoading
151527
+ globalLoading,
151528
+ includeFragments
151516
151529
  }) {
151517
151530
  let object = {};
151518
151531
  const loadingTypes = [];
@@ -151532,7 +151545,8 @@ function prepareSelection({
151532
151545
  document: document2,
151533
151546
  typeMap,
151534
151547
  abstractTypes,
151535
- globalLoading
151548
+ globalLoading,
151549
+ includeFragments
151536
151550
  }).fields || {}
151537
151551
  );
151538
151552
  } else {
@@ -151580,7 +151594,8 @@ function prepareSelection({
151580
151594
  document: document2,
151581
151595
  typeMap,
151582
151596
  abstractTypes,
151583
- globalLoading
151597
+ globalLoading,
151598
+ includeFragments
151584
151599
  }).fields
151585
151600
  };
151586
151601
  if (field.directives?.find((d) => d.name.value === config22.loadingDirective)) {
@@ -151698,7 +151713,8 @@ function prepareSelection({
151698
151713
  inConnection: connectionState,
151699
151714
  typeMap,
151700
151715
  abstractTypes,
151701
- globalLoading: forceLoading
151716
+ globalLoading: forceLoading,
151717
+ includeFragments
151702
151718
  });
151703
151719
  if (Object.values(fieldObj.selection.fields ?? {}).some((field2) => field2.required)) {
151704
151720
  fieldObj.nullable = true;
@@ -152029,13 +152045,13 @@ function artifactGenerator(stats) {
152029
152045
  document: doc,
152030
152046
  rootType,
152031
152047
  globalLoading,
152048
+ includeFragments: doc.kind !== ArtifactKind2.Fragment,
152032
152049
  selections: flattenSelections({
152033
152050
  config: config22,
152034
152051
  filepath: doc.filename,
152035
152052
  selections: selectionSet.selections,
152036
152053
  fragmentDefinitions,
152037
- ignoreMaskDisable: docKind !== "HoudiniFragment",
152038
- keepFragmentSpreadNodes: true
152054
+ applyFragments: doc.kind !== ArtifactKind2.Fragment
152039
152055
  }),
152040
152056
  operations: operationsByPath(
152041
152057
  config22,
@@ -152972,8 +152988,7 @@ async function generateDocumentTypes(config22, docs) {
152972
152988
  config: config22,
152973
152989
  filepath: filename,
152974
152990
  selections: definition.selectionSet.selections,
152975
- fragmentDefinitions,
152976
- keepFragmentSpreadNodes: true
152991
+ fragmentDefinitions
152977
152992
  });
152978
152993
  if (definition?.kind === "OperationDefinition") {
152979
152994
  await generateOperationTypeDefs(
@@ -212213,6 +212228,8 @@ function testConfigFile({ plugins, ...config22 } = {}) {
212213
212228
  customIdList: [CustomIdType]!
212214
212229
  nodes(ids: [ID!]!): [Node!]!
212215
212230
  monkeys: MonkeyConnection!
212231
+ animals(first: Int, after: String): AnimalConnection
212232
+
212216
212233
  }
212217
212234
 
212218
212235
  input UserFilter {
@@ -212469,7 +212486,7 @@ function artifactData({
212469
212486
  config: config5,
212470
212487
  document: document2
212471
212488
  }) {
212472
- let isManualLoad = true;
212489
+ let isManualLoad = document2.filename.endsWith(".svelte");
212473
212490
  let set_blocking = void 0;
212474
212491
  graphql29.visit(document2.document, {
212475
212492
  Directive(node2, _, __, ___) {
@@ -305987,11 +306004,26 @@ async function fragmentTypedefs(input) {
305987
306004
  )
305988
306005
  )
305989
306006
  ]);
306007
+ const non_exhaustive = AST18.tsTypeLiteral([
306008
+ AST18.tsPropertySignature(
306009
+ AST18.literal("__typename"),
306010
+ AST18.tsTypeAnnotation(
306011
+ AST18.tsLiteralType(AST18.stringLiteral("non-exhaustive; don't match this"))
306012
+ )
306013
+ )
306014
+ ]);
305990
306015
  const initial_value_input = AST18.identifier("initialValue");
305991
- initial_value_input.typeAnnotation = AST18.tsTypeAnnotation(fragment_map);
306016
+ initial_value_input.typeAnnotation = AST18.tsTypeAnnotation(
306017
+ AST18.tsUnionType([fragment_map, non_exhaustive])
306018
+ );
305992
306019
  const initial_value_or_null_input = AST18.identifier("initialValue");
305993
306020
  initial_value_or_null_input.typeAnnotation = AST18.tsTypeAnnotation(
305994
- AST18.tsUnionType([fragment_map, AST18.tsNullKeyword(), AST18.tsUndefinedKeyword()])
306021
+ AST18.tsUnionType([
306022
+ fragment_map,
306023
+ AST18.tsNullKeyword(),
306024
+ AST18.tsUndefinedKeyword(),
306025
+ non_exhaustive
306026
+ ])
305995
306027
  );
305996
306028
  const document_input = AST18.identifier("document");
305997
306029
  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;
@@ -149437,16 +149437,14 @@ function flattenSelections({
149437
149437
  filepath,
149438
149438
  selections,
149439
149439
  fragmentDefinitions,
149440
- ignoreMaskDisable,
149441
- keepFragmentSpreadNodes
149440
+ applyFragments
149442
149441
  }) {
149443
149442
  const fields = new FieldCollection({
149444
149443
  config: config22,
149445
149444
  filepath,
149446
149445
  selections,
149447
149446
  fragmentDefinitions,
149448
- ignoreMaskDisable: !!ignoreMaskDisable,
149449
- keepFragmentSpreadNodes: !!keepFragmentSpreadNodes
149447
+ applyFragments: !!applyFragments
149450
149448
  });
149451
149449
  return fields.toSelectionSet();
149452
149450
  }
@@ -149457,25 +149455,36 @@ var FieldCollection = class {
149457
149455
  fields;
149458
149456
  inlineFragments;
149459
149457
  fragmentSpreads;
149460
- ignoreMaskDisable;
149461
- keepFragmentSpreadNodes;
149458
+ applyFragments;
149462
149459
  constructor(args) {
149463
149460
  this.config = args.config;
149464
149461
  this.fragmentDefinitions = args.fragmentDefinitions;
149465
- this.ignoreMaskDisable = args.ignoreMaskDisable;
149466
- this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
149462
+ this.applyFragments = args.applyFragments;
149467
149463
  this.fields = {};
149468
149464
  this.inlineFragments = {};
149469
149465
  this.fragmentSpreads = {};
149470
149466
  this.filepath = args.filepath;
149471
149467
  for (const selection of args.selections) {
149472
- this.add(selection);
149468
+ this.add({ selection });
149473
149469
  }
149474
149470
  }
149475
149471
  get size() {
149476
149472
  return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
149477
149473
  }
149478
- add(selection) {
149474
+ add({ selection, external }) {
149475
+ let include = this.config.defaultFragmentMasking === "disable";
149476
+ const maskEnableDirective = selection.directives?.find(
149477
+ ({ name }) => name.value === this.config.maskEnableDirective
149478
+ );
149479
+ if (maskEnableDirective) {
149480
+ include = false;
149481
+ }
149482
+ const maskDisableDirective = selection.directives?.find(
149483
+ ({ name }) => name.value === this.config.maskDisableDirective
149484
+ );
149485
+ if (maskDisableDirective) {
149486
+ include = true;
149487
+ }
149479
149488
  if (selection.kind === "Field") {
149480
149489
  const key = selection.alias?.value || selection.name.value;
149481
149490
  if (!this.fields[key]) {
@@ -149485,46 +149494,32 @@ var FieldCollection = class {
149485
149494
  };
149486
149495
  }
149487
149496
  for (const subselect of selection.selectionSet?.selections || []) {
149488
- this.fields[key].selection.add(subselect);
149497
+ this.fields[key].selection.add({
149498
+ selection: subselect,
149499
+ external
149500
+ });
149501
+ }
149502
+ if (this.applyFragments && !external) {
149503
+ this.fields[key].selection.fragmentSpreads = {
149504
+ ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
149505
+ ...this.fields[key].selection.fragmentSpreads
149506
+ };
149489
149507
  }
149490
- this.fields[key].selection.fragmentSpreads = {
149491
- ...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
149492
- ...this.fields[key].selection.fragmentSpreads
149493
- };
149494
149508
  return;
149495
149509
  }
149496
149510
  if (selection.kind === "InlineFragment" && !selection.typeCondition) {
149497
149511
  for (const subselect of selection.selectionSet.selections) {
149498
- this.add(subselect);
149512
+ this.add({ selection: subselect, external });
149499
149513
  }
149500
149514
  }
149501
149515
  if (selection.kind === "InlineFragment" && selection.typeCondition) {
149502
- this.walkInlineFragment(selection);
149516
+ this.walkInlineFragment({ selection, external });
149503
149517
  return;
149504
149518
  }
149505
149519
  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) {
149520
+ if (!external || include) {
149523
149521
  this.fragmentSpreads[selection.name.value] = selection;
149524
149522
  }
149525
- if (!includeFragments) {
149526
- return;
149527
- }
149528
149523
  const definition = this.fragmentDefinitions[selection.name.value];
149529
149524
  if (!definition) {
149530
149525
  throw new HoudiniError2({
@@ -149532,20 +149527,25 @@ var FieldCollection = class {
149532
149527
  message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
149533
149528
  });
149534
149529
  }
149535
- this.add({
149536
- kind: "InlineFragment",
149537
- typeCondition: {
149538
- kind: "NamedType",
149539
- name: {
149540
- kind: "Name",
149541
- value: definition.typeCondition.name.value
149542
- }
149543
- },
149544
- selectionSet: {
149545
- kind: "SelectionSet",
149546
- selections: [...definition.selectionSet.selections]
149547
- }
149548
- });
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]
149544
+ }
149545
+ },
149546
+ external: !include
149547
+ });
149548
+ }
149549
149549
  }
149550
149550
  }
149551
149551
  collectFragmentSpreads(selections, result = {}) {
@@ -149600,7 +149600,10 @@ var FieldCollection = class {
149600
149600
  })
149601
149601
  );
149602
149602
  }
149603
- walkInlineFragment(selection) {
149603
+ walkInlineFragment({
149604
+ selection,
149605
+ external
149606
+ }) {
149604
149607
  const key = selection.typeCondition.name.value;
149605
149608
  if (!this.inlineFragments[key]) {
149606
149609
  this.inlineFragments[key] = {
@@ -149609,11 +149612,21 @@ var FieldCollection = class {
149609
149612
  };
149610
149613
  }
149611
149614
  for (const subselect of selection.selectionSet.selections || []) {
149612
- if (subselect.kind !== "InlineFragment" || !subselect.typeCondition) {
149613
- this.inlineFragments[key].selection.add(subselect);
149615
+ if (subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
149616
+ this.inlineFragments[key].selection.add({
149617
+ selection: subselect,
149618
+ external
149619
+ });
149614
149620
  continue;
149621
+ } else if (subselect.kind === "FragmentSpread") {
149622
+ this.add({
149623
+ selection: subselect,
149624
+ external
149625
+ });
149626
+ continue;
149627
+ } else {
149628
+ this.walkInlineFragment({ selection: subselect, external });
149615
149629
  }
149616
- this.walkInlineFragment(subselect);
149617
149630
  }
149618
149631
  }
149619
149632
  empty() {
@@ -149622,8 +149635,7 @@ var FieldCollection = class {
149622
149635
  fragmentDefinitions: this.fragmentDefinitions,
149623
149636
  selections: [],
149624
149637
  filepath: this.filepath,
149625
- ignoreMaskDisable: this.ignoreMaskDisable,
149626
- keepFragmentSpreadNodes: this.keepFragmentSpreadNodes
149638
+ applyFragments: this.applyFragments
149627
149639
  });
149628
149640
  }
149629
149641
  };
@@ -151499,7 +151511,8 @@ function prepareSelection({
151499
151511
  inConnection,
151500
151512
  typeMap,
151501
151513
  abstractTypes,
151502
- globalLoading
151514
+ globalLoading,
151515
+ includeFragments
151503
151516
  }) {
151504
151517
  let object = {};
151505
151518
  const loadingTypes = [];
@@ -151519,7 +151532,8 @@ function prepareSelection({
151519
151532
  document: document2,
151520
151533
  typeMap,
151521
151534
  abstractTypes,
151522
- globalLoading
151535
+ globalLoading,
151536
+ includeFragments
151523
151537
  }).fields || {}
151524
151538
  );
151525
151539
  } else {
@@ -151567,7 +151581,8 @@ function prepareSelection({
151567
151581
  document: document2,
151568
151582
  typeMap,
151569
151583
  abstractTypes,
151570
- globalLoading
151584
+ globalLoading,
151585
+ includeFragments
151571
151586
  }).fields
151572
151587
  };
151573
151588
  if (field.directives?.find((d) => d.name.value === config22.loadingDirective)) {
@@ -151685,7 +151700,8 @@ function prepareSelection({
151685
151700
  inConnection: connectionState,
151686
151701
  typeMap,
151687
151702
  abstractTypes,
151688
- globalLoading: forceLoading
151703
+ globalLoading: forceLoading,
151704
+ includeFragments
151689
151705
  });
151690
151706
  if (Object.values(fieldObj.selection.fields ?? {}).some((field2) => field2.required)) {
151691
151707
  fieldObj.nullable = true;
@@ -152016,13 +152032,13 @@ function artifactGenerator(stats) {
152016
152032
  document: doc,
152017
152033
  rootType,
152018
152034
  globalLoading,
152035
+ includeFragments: doc.kind !== ArtifactKind2.Fragment,
152019
152036
  selections: flattenSelections({
152020
152037
  config: config22,
152021
152038
  filepath: doc.filename,
152022
152039
  selections: selectionSet.selections,
152023
152040
  fragmentDefinitions,
152024
- ignoreMaskDisable: docKind !== "HoudiniFragment",
152025
- keepFragmentSpreadNodes: true
152041
+ applyFragments: doc.kind !== ArtifactKind2.Fragment
152026
152042
  }),
152027
152043
  operations: operationsByPath(
152028
152044
  config22,
@@ -152959,8 +152975,7 @@ async function generateDocumentTypes(config22, docs) {
152959
152975
  config: config22,
152960
152976
  filepath: filename,
152961
152977
  selections: definition.selectionSet.selections,
152962
- fragmentDefinitions,
152963
- keepFragmentSpreadNodes: true
152978
+ fragmentDefinitions
152964
152979
  });
152965
152980
  if (definition?.kind === "OperationDefinition") {
152966
152981
  await generateOperationTypeDefs(
@@ -212199,6 +212214,8 @@ function testConfigFile({ plugins, ...config22 } = {}) {
212199
212214
  customIdList: [CustomIdType]!
212200
212215
  nodes(ids: [ID!]!): [Node!]!
212201
212216
  monkeys: MonkeyConnection!
212217
+ animals(first: Int, after: String): AnimalConnection
212218
+
212202
212219
  }
212203
212220
 
212204
212221
  input UserFilter {
@@ -212455,7 +212472,7 @@ function artifactData({
212455
212472
  config: config5,
212456
212473
  document: document2
212457
212474
  }) {
212458
- let isManualLoad = true;
212475
+ let isManualLoad = document2.filename.endsWith(".svelte");
212459
212476
  let set_blocking = void 0;
212460
212477
  graphql29.visit(document2.document, {
212461
212478
  Directive(node2, _, __, ___) {
@@ -305972,11 +305989,26 @@ async function fragmentTypedefs(input) {
305972
305989
  )
305973
305990
  )
305974
305991
  ]);
305992
+ const non_exhaustive = AST18.tsTypeLiteral([
305993
+ AST18.tsPropertySignature(
305994
+ AST18.literal("__typename"),
305995
+ AST18.tsTypeAnnotation(
305996
+ AST18.tsLiteralType(AST18.stringLiteral("non-exhaustive; don't match this"))
305997
+ )
305998
+ )
305999
+ ]);
305975
306000
  const initial_value_input = AST18.identifier("initialValue");
305976
- initial_value_input.typeAnnotation = AST18.tsTypeAnnotation(fragment_map);
306001
+ initial_value_input.typeAnnotation = AST18.tsTypeAnnotation(
306002
+ AST18.tsUnionType([fragment_map, non_exhaustive])
306003
+ );
305977
306004
  const initial_value_or_null_input = AST18.identifier("initialValue");
305978
306005
  initial_value_or_null_input.typeAnnotation = AST18.tsTypeAnnotation(
305979
- AST18.tsUnionType([fragment_map, AST18.tsNullKeyword(), AST18.tsUndefinedKeyword()])
306006
+ AST18.tsUnionType([
306007
+ fragment_map,
306008
+ AST18.tsNullKeyword(),
306009
+ AST18.tsUndefinedKeyword(),
306010
+ non_exhaustive
306011
+ ])
305980
306012
  );
305981
306013
  const document_input = AST18.identifier("document");
305982
306014
  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.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.0"
35
+ "houdini": "^1.2.2"
36
36
  },
37
37
  "files": [
38
38
  "build"