houdini-svelte 1.2.61 → 1.2.63

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.
@@ -81828,6 +81828,9 @@ var Config = class {
81828
81828
  get listDirective() {
81829
81829
  return "list";
81830
81830
  }
81831
+ get dedupeDirective() {
81832
+ return "dedupe";
81833
+ }
81831
81834
  get optimisticKeyDirective() {
81832
81835
  return "optimisticKey";
81833
81836
  }
@@ -81825,6 +81825,9 @@ var Config = class {
81825
81825
  get listDirective() {
81826
81826
  return "list";
81827
81827
  }
81828
+ get dedupeDirective() {
81829
+ return "dedupe";
81830
+ }
81828
81831
  get optimisticKeyDirective() {
81829
81832
  return "optimisticKey";
81830
81833
  }
@@ -29,13 +29,13 @@ export declare class FragmentStoreCursor<_Data extends GraphQLObject, _Input ext
29
29
  after?: string | undefined;
30
30
  fetch?: typeof fetch | undefined;
31
31
  metadata?: {} | undefined;
32
- } | undefined) => Promise<void>;
32
+ } | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
33
33
  loadPreviousPage: (args?: {
34
34
  last?: number | undefined;
35
35
  before?: string | undefined;
36
36
  fetch?: typeof fetch | undefined;
37
37
  metadata?: {} | undefined;
38
- } | undefined) => Promise<void>;
38
+ } | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
39
39
  };
40
40
  protected storeHandlers(observer: DocumentStore<_Data, _Input>, initialValue: _Data | null, getState: () => _Data | null, getVariables: () => NonNullable<_Input>): CursorHandlers<_Data, _Input>;
41
41
  }
@@ -14,8 +14,8 @@ export declare class QueryStoreCursor<_Data extends GraphQLObject, _Input extend
14
14
  fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
15
15
  fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
16
16
  fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
17
- loadPreviousPage(args?: Parameters<Required<CursorHandlers<_Data, _Input>>['loadPreviousPage']>[0]): Promise<void>;
18
- loadNextPage(args?: Parameters<CursorHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<void>;
17
+ loadPreviousPage(args?: Parameters<Required<CursorHandlers<_Data, _Input>>['loadPreviousPage']>[0]): Promise<ReturnType<CursorHandlers<_Data, _Input>['loadPreviousPage']>>;
18
+ loadNextPage(args?: Parameters<CursorHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<ReturnType<CursorHandlers<_Data, _Input>['loadNextPage']>>;
19
19
  subscribe(run: Subscriber<CursorStoreResult<_Data, _Input>>, invalidate?: ((value?: CursorStoreResult<_Data, _Input> | undefined) => void) | undefined): () => void;
20
20
  }
21
21
  export declare class QueryStoreOffset<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends QueryStore<_Data, _Input> {
@@ -29,13 +29,13 @@ export declare class FragmentStoreCursor<_Data extends GraphQLObject, _Input ext
29
29
  after?: string | undefined;
30
30
  fetch?: typeof fetch | undefined;
31
31
  metadata?: {} | undefined;
32
- } | undefined) => Promise<void>;
32
+ } | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
33
33
  loadPreviousPage: (args?: {
34
34
  last?: number | undefined;
35
35
  before?: string | undefined;
36
36
  fetch?: typeof fetch | undefined;
37
37
  metadata?: {} | undefined;
38
- } | undefined) => Promise<void>;
38
+ } | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
39
39
  };
40
40
  protected storeHandlers(observer: DocumentStore<_Data, _Input>, initialValue: _Data | null, getState: () => _Data | null, getVariables: () => NonNullable<_Input>): CursorHandlers<_Data, _Input>;
41
41
  }
@@ -14,8 +14,8 @@ export declare class QueryStoreCursor<_Data extends GraphQLObject, _Input extend
14
14
  fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
15
15
  fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
16
16
  fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
17
- loadPreviousPage(args?: Parameters<Required<CursorHandlers<_Data, _Input>>['loadPreviousPage']>[0]): Promise<void>;
18
- loadNextPage(args?: Parameters<CursorHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<void>;
17
+ loadPreviousPage(args?: Parameters<Required<CursorHandlers<_Data, _Input>>['loadPreviousPage']>[0]): Promise<ReturnType<CursorHandlers<_Data, _Input>['loadPreviousPage']>>;
18
+ loadNextPage(args?: Parameters<CursorHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<ReturnType<CursorHandlers<_Data, _Input>['loadNextPage']>>;
19
19
  subscribe(run: Subscriber<CursorStoreResult<_Data, _Input>>, invalidate?: ((value?: CursorStoreResult<_Data, _Input> | undefined) => void) | undefined): () => void;
20
20
  }
21
21
  export declare class QueryStoreOffset<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends QueryStore<_Data, _Input> {
@@ -67,11 +67,29 @@ class QueryStoreCursor extends import_query.QueryStore {
67
67
  }
68
68
  async loadPreviousPage(args) {
69
69
  const handlers = await this.#handlers();
70
- return await handlers.loadPreviousPage(args);
70
+ try {
71
+ return await handlers.loadPreviousPage(args);
72
+ } catch (e) {
73
+ const err = e;
74
+ if (err.name === "AbortError") {
75
+ return (0, import_store.get)(this.observer);
76
+ } else {
77
+ throw err;
78
+ }
79
+ }
71
80
  }
72
81
  async loadNextPage(args) {
73
82
  const handlers = await this.#handlers();
74
- return await handlers.loadNextPage(args);
83
+ try {
84
+ return await handlers.loadNextPage(args);
85
+ } catch (e) {
86
+ const err = e;
87
+ if (err.name === "AbortError") {
88
+ return (0, import_store.get)(this.observer);
89
+ } else {
90
+ throw err;
91
+ }
92
+ }
75
93
  }
76
94
  subscribe(run, invalidate) {
77
95
  const combined = (0, import_store.derived)([{ subscribe: super.subscribe.bind(this) }], ([$parent]) => {
@@ -29,13 +29,13 @@ export declare class FragmentStoreCursor<_Data extends GraphQLObject, _Input ext
29
29
  after?: string | undefined;
30
30
  fetch?: typeof fetch | undefined;
31
31
  metadata?: {} | undefined;
32
- } | undefined) => Promise<void>;
32
+ } | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
33
33
  loadPreviousPage: (args?: {
34
34
  last?: number | undefined;
35
35
  before?: string | undefined;
36
36
  fetch?: typeof fetch | undefined;
37
37
  metadata?: {} | undefined;
38
- } | undefined) => Promise<void>;
38
+ } | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
39
39
  };
40
40
  protected storeHandlers(observer: DocumentStore<_Data, _Input>, initialValue: _Data | null, getState: () => _Data | null, getVariables: () => NonNullable<_Input>): CursorHandlers<_Data, _Input>;
41
41
  }
@@ -14,8 +14,8 @@ export declare class QueryStoreCursor<_Data extends GraphQLObject, _Input extend
14
14
  fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
15
15
  fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
16
16
  fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
17
- loadPreviousPage(args?: Parameters<Required<CursorHandlers<_Data, _Input>>['loadPreviousPage']>[0]): Promise<void>;
18
- loadNextPage(args?: Parameters<CursorHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<void>;
17
+ loadPreviousPage(args?: Parameters<Required<CursorHandlers<_Data, _Input>>['loadPreviousPage']>[0]): Promise<ReturnType<CursorHandlers<_Data, _Input>['loadPreviousPage']>>;
18
+ loadNextPage(args?: Parameters<CursorHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<ReturnType<CursorHandlers<_Data, _Input>['loadNextPage']>>;
19
19
  subscribe(run: Subscriber<CursorStoreResult<_Data, _Input>>, invalidate?: ((value?: CursorStoreResult<_Data, _Input> | undefined) => void) | undefined): () => void;
20
20
  }
21
21
  export declare class QueryStoreOffset<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends QueryStore<_Data, _Input> {
@@ -43,11 +43,29 @@ class QueryStoreCursor extends QueryStore {
43
43
  }
44
44
  async loadPreviousPage(args) {
45
45
  const handlers = await this.#handlers();
46
- return await handlers.loadPreviousPage(args);
46
+ try {
47
+ return await handlers.loadPreviousPage(args);
48
+ } catch (e) {
49
+ const err = e;
50
+ if (err.name === "AbortError") {
51
+ return get(this.observer);
52
+ } else {
53
+ throw err;
54
+ }
55
+ }
47
56
  }
48
57
  async loadNextPage(args) {
49
58
  const handlers = await this.#handlers();
50
- return await handlers.loadNextPage(args);
59
+ try {
60
+ return await handlers.loadNextPage(args);
61
+ } catch (e) {
62
+ const err = e;
63
+ if (err.name === "AbortError") {
64
+ return get(this.observer);
65
+ } else {
66
+ throw err;
67
+ }
68
+ }
51
69
  }
52
70
  subscribe(run, invalidate) {
53
71
  const combined = derived([{ subscribe: super.subscribe.bind(this) }], ([$parent]) => {
@@ -136567,7 +136567,17 @@ async function paginate(config2, documents) {
136567
136567
  );
136568
136568
  return {
136569
136569
  ...node2,
136570
- variableDefinitions: finalVariables
136570
+ variableDefinitions: finalVariables,
136571
+ directives: [
136572
+ ...node2.directives || [],
136573
+ {
136574
+ kind: graphql13.Kind.DIRECTIVE,
136575
+ name: {
136576
+ kind: graphql13.Kind.NAME,
136577
+ value: config2.dedupeDirective
136578
+ }
136579
+ }
136580
+ ]
136571
136581
  };
136572
136582
  },
136573
136583
  FragmentDefinition(node2) {
@@ -137881,6 +137891,7 @@ function artifactGenerator(stats) {
137881
137891
  let rootType = "";
137882
137892
  let selectionSet;
137883
137893
  let originalSelectionSet = null;
137894
+ let dedupe;
137884
137895
  const fragmentDefinitions = doc.document.definitions.filter(
137885
137896
  (definition) => definition.kind === "FragmentDefinition"
137886
137897
  ).reduce(
@@ -137905,6 +137916,15 @@ function artifactGenerator(stats) {
137905
137916
  message: "could not find root type for operation: " + operation.operation + ". Maybe you need to re-run the introspection query?"
137906
137917
  });
137907
137918
  }
137919
+ const dedupeDirective = operation.directives?.find(
137920
+ (directive2) => directive2.name.value === config2.dedupeDirective
137921
+ );
137922
+ if (dedupeDirective) {
137923
+ const cancelFirstArg = dedupeDirective.arguments?.find(
137924
+ (arg) => arg.name.value === "cancelFirst"
137925
+ );
137926
+ dedupe = cancelFirstArg && cancelFirstArg.value.kind === "BooleanValue" && cancelFirstArg.value ? "first" : "last";
137927
+ }
137908
137928
  selectionSet = operation.selectionSet;
137909
137929
  if (originalParsed.definitions[0].kind === "OperationDefinition") {
137910
137930
  originalSelectionSet = originalParsed.definitions[0].selectionSet;
@@ -137982,6 +138002,9 @@ function artifactGenerator(stats) {
137982
138002
  };
137983
138003
  const hash_value = hashPluginBaseRaw({ config: config2, document: { ...doc, artifact } });
137984
138004
  artifact.hash = hash_value;
138005
+ if (artifact.kind === "HoudiniQuery" || artifact.kind === "HoudiniMutation" && dedupe) {
138006
+ artifact.dedupe = dedupe;
138007
+ }
137985
138008
  applyMask(
137986
138009
  config2,
137987
138010
  artifact.selection,
@@ -141437,6 +141460,12 @@ directive @${config2.paginateDirective}(${config2.listOrPaginateNameArg}: String
141437
141460
  """
141438
141461
  directive @${config2.listPrependDirective} on FRAGMENT_SPREAD
141439
141462
 
141463
+ """
141464
+ @${config2.dedupeDirective} is used to prevent an operation from running more than once at the same time.
141465
+ If the cancelFirst arg is set to true, the response already in flight will be canceled instead of the second one.
141466
+ """
141467
+ directive @${config2.dedupeDirective}(cancelFirst: Boolean) on QUERY | MUTATION
141468
+
141440
141469
  """
141441
141470
  @${config2.optimisticKeyDirective} is used to identify a field as an optimistic key
141442
141471
  """
@@ -199675,6 +199704,9 @@ var Config = class {
199675
199704
  get listDirective() {
199676
199705
  return "list";
199677
199706
  }
199707
+ get dedupeDirective() {
199708
+ return "dedupe";
199709
+ }
199678
199710
  get optimisticKeyDirective() {
199679
199711
  return "optimisticKey";
199680
199712
  }
@@ -136558,7 +136558,17 @@ async function paginate(config2, documents) {
136558
136558
  );
136559
136559
  return {
136560
136560
  ...node2,
136561
- variableDefinitions: finalVariables
136561
+ variableDefinitions: finalVariables,
136562
+ directives: [
136563
+ ...node2.directives || [],
136564
+ {
136565
+ kind: graphql13.Kind.DIRECTIVE,
136566
+ name: {
136567
+ kind: graphql13.Kind.NAME,
136568
+ value: config2.dedupeDirective
136569
+ }
136570
+ }
136571
+ ]
136562
136572
  };
136563
136573
  },
136564
136574
  FragmentDefinition(node2) {
@@ -137872,6 +137882,7 @@ function artifactGenerator(stats) {
137872
137882
  let rootType = "";
137873
137883
  let selectionSet;
137874
137884
  let originalSelectionSet = null;
137885
+ let dedupe;
137875
137886
  const fragmentDefinitions = doc.document.definitions.filter(
137876
137887
  (definition) => definition.kind === "FragmentDefinition"
137877
137888
  ).reduce(
@@ -137896,6 +137907,15 @@ function artifactGenerator(stats) {
137896
137907
  message: "could not find root type for operation: " + operation.operation + ". Maybe you need to re-run the introspection query?"
137897
137908
  });
137898
137909
  }
137910
+ const dedupeDirective = operation.directives?.find(
137911
+ (directive2) => directive2.name.value === config2.dedupeDirective
137912
+ );
137913
+ if (dedupeDirective) {
137914
+ const cancelFirstArg = dedupeDirective.arguments?.find(
137915
+ (arg) => arg.name.value === "cancelFirst"
137916
+ );
137917
+ dedupe = cancelFirstArg && cancelFirstArg.value.kind === "BooleanValue" && cancelFirstArg.value ? "first" : "last";
137918
+ }
137899
137919
  selectionSet = operation.selectionSet;
137900
137920
  if (originalParsed.definitions[0].kind === "OperationDefinition") {
137901
137921
  originalSelectionSet = originalParsed.definitions[0].selectionSet;
@@ -137973,6 +137993,9 @@ function artifactGenerator(stats) {
137973
137993
  };
137974
137994
  const hash_value = hashPluginBaseRaw({ config: config2, document: { ...doc, artifact } });
137975
137995
  artifact.hash = hash_value;
137996
+ if (artifact.kind === "HoudiniQuery" || artifact.kind === "HoudiniMutation" && dedupe) {
137997
+ artifact.dedupe = dedupe;
137998
+ }
137976
137999
  applyMask(
137977
138000
  config2,
137978
138001
  artifact.selection,
@@ -141428,6 +141451,12 @@ directive @${config2.paginateDirective}(${config2.listOrPaginateNameArg}: String
141428
141451
  """
141429
141452
  directive @${config2.listPrependDirective} on FRAGMENT_SPREAD
141430
141453
 
141454
+ """
141455
+ @${config2.dedupeDirective} is used to prevent an operation from running more than once at the same time.
141456
+ If the cancelFirst arg is set to true, the response already in flight will be canceled instead of the second one.
141457
+ """
141458
+ directive @${config2.dedupeDirective}(cancelFirst: Boolean) on QUERY | MUTATION
141459
+
141431
141460
  """
141432
141461
  @${config2.optimisticKeyDirective} is used to identify a field as an optimistic key
141433
141462
  """
@@ -199665,6 +199694,9 @@ var Config = class {
199665
199694
  get listDirective() {
199666
199695
  return "list";
199667
199696
  }
199697
+ get dedupeDirective() {
199698
+ return "dedupe";
199699
+ }
199668
199700
  get optimisticKeyDirective() {
199669
199701
  return "optimisticKey";
199670
199702
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-svelte",
3
- "version": "1.2.61",
3
+ "version": "1.2.63",
4
4
  "description": "The svelte plugin for houdini",
5
5
  "keywords": [
6
6
  "typescript",
@@ -33,7 +33,7 @@
33
33
  "rollup": "^3.7.4",
34
34
  "svelte": "^3.57.0",
35
35
  "vite": "^4.1.1",
36
- "houdini": "^1.2.61"
36
+ "houdini": "^1.2.63"
37
37
  },
38
38
  "files": [
39
39
  "build"