houdini-svelte 1.0.0-next.3 → 1.0.0-next.4

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.
Files changed (38) hide show
  1. package/build/plugin/index.d.ts +2 -4
  2. package/build/plugin-cjs/index.js +4 -6
  3. package/build/plugin-esm/index.js +4 -6
  4. package/build/preprocess-cjs/index.js +2 -4
  5. package/build/preprocess-esm/index.js +2 -4
  6. package/build/runtime/stores/mutation.d.ts +3 -1
  7. package/build/runtime/stores/pagination/cursor.d.ts +1 -1
  8. package/build/runtime/stores/pagination/fragment.d.ts +3 -31
  9. package/build/runtime/stores/pagination/index.d.ts +2 -2
  10. package/build/runtime/stores/pagination/query.d.ts +5 -13
  11. package/build/runtime/stores/query.d.ts +5 -4
  12. package/build/runtime-cjs/stores/mutation.d.ts +3 -1
  13. package/build/runtime-cjs/stores/mutation.js +9 -3
  14. package/build/runtime-cjs/stores/pagination/cursor.d.ts +1 -1
  15. package/build/runtime-cjs/stores/pagination/cursor.js +58 -27
  16. package/build/runtime-cjs/stores/pagination/fragment.d.ts +3 -31
  17. package/build/runtime-cjs/stores/pagination/fragment.js +15 -39
  18. package/build/runtime-cjs/stores/pagination/index.d.ts +2 -2
  19. package/build/runtime-cjs/stores/pagination/index.js +4 -8
  20. package/build/runtime-cjs/stores/pagination/query.d.ts +5 -13
  21. package/build/runtime-cjs/stores/pagination/query.js +19 -31
  22. package/build/runtime-cjs/stores/query.d.ts +5 -4
  23. package/build/runtime-cjs/stores/query.js +10 -5
  24. package/build/runtime-esm/stores/mutation.d.ts +3 -1
  25. package/build/runtime-esm/stores/mutation.js +9 -3
  26. package/build/runtime-esm/stores/pagination/cursor.d.ts +1 -1
  27. package/build/runtime-esm/stores/pagination/cursor.js +58 -27
  28. package/build/runtime-esm/stores/pagination/fragment.d.ts +3 -31
  29. package/build/runtime-esm/stores/pagination/fragment.js +14 -37
  30. package/build/runtime-esm/stores/pagination/index.d.ts +2 -2
  31. package/build/runtime-esm/stores/pagination/index.js +4 -10
  32. package/build/runtime-esm/stores/pagination/query.d.ts +5 -13
  33. package/build/runtime-esm/stores/pagination/query.js +19 -30
  34. package/build/runtime-esm/stores/query.d.ts +5 -4
  35. package/build/runtime-esm/stores/query.js +6 -1
  36. package/build/test-cjs/index.js +41 -47
  37. package/build/test-esm/index.js +41 -47
  38. package/package.json +2 -2
@@ -38,11 +38,9 @@ export type HoudiniSvelteConfig = {
38
38
  mutation?: string;
39
39
  subscription?: string;
40
40
  fragment?: string;
41
- queryForwardsCursor?: string;
42
- queryBackwardsCursor?: string;
41
+ queryCursor?: string;
43
42
  queryOffset?: string;
44
- fragmentForwardsCursor?: string;
45
- fragmentBackwardsCursor?: string;
43
+ fragmentCursor?: string;
46
44
  fragmentOffset?: string;
47
45
  };
48
46
  };
@@ -181622,11 +181622,9 @@ function plugin_config(config4) {
181622
181622
  mutation: "$houdini/plugins/houdini-svelte/runtime/stores.MutationStore",
181623
181623
  fragment: "$houdini/plugins/houdini-svelte/runtime/stores.FragmentStore",
181624
181624
  subscription: "$houdini/plugins/houdini-svelte/runtime/stores.SubscriptionStore",
181625
- queryForwardsCursor: "$houdini/plugins/houdini-svelte/runtime/stores.QueryStoreForwardCursor",
181626
- queryBackwardsCursor: "$houdini/plugins/houdini-svelte/runtime/stores.QueryStoreBackwardCursor",
181625
+ queryCursor: "$houdini/plugins/houdini-svelte/runtime/stores.QueryStoreCursor",
181627
181626
  queryOffset: "$houdini/plugins/houdini-svelte/runtime/stores.QueryStoreOffset",
181628
- fragmentForwardsCursor: "$houdini/plugins/houdini-svelte/runtime/stores.FragmentStoreForwardCursor",
181629
- fragmentBackwardsCursor: "$houdini/plugins/houdini-svelte/runtime/stores.FragmentStoreBackwardCursor",
181627
+ fragmentCursor: "$houdini/plugins/houdini-svelte/runtime/stores.FragmentStoreCursor",
181630
181628
  fragmentOffset: "$houdini/plugins/houdini-svelte/runtime/stores.FragmentStoreOffset",
181631
181629
  ...cfg?.customStores
181632
181630
  },
@@ -182159,7 +182157,7 @@ async function fragmentStore({ config: config4, plugin_root }, doc) {
182159
182157
  const paginationMethod = doc.refetch?.method;
182160
182158
  let which = "fragment";
182161
182159
  if (paginationMethod === "cursor") {
182162
- which = doc.refetch?.direction === "forward" ? "fragmentForwardsCursor" : "fragmentBackwardsCursor";
182160
+ which = "fragmentCursor";
182163
182161
  } else if (paginationMethod === "offset") {
182164
182162
  which = "fragmentOffset";
182165
182163
  }
@@ -182253,7 +182251,7 @@ async function queryStore({ config: config4, plugin_root }, doc) {
182253
182251
  const paginationMethod = doc.refetch?.paginated && doc.refetch.method;
182254
182252
  let which = "query";
182255
182253
  if (paginationMethod === "cursor") {
182256
- which = doc.refetch?.direction === "forward" ? "queryForwardsCursor" : "queryBackwardsCursor";
182254
+ which = "queryCursor";
182257
182255
  } else if (paginationMethod === "offset") {
182258
182256
  which = "queryOffset";
182259
182257
  }
@@ -181617,11 +181617,9 @@ function plugin_config(config4) {
181617
181617
  mutation: "$houdini/plugins/houdini-svelte/runtime/stores.MutationStore",
181618
181618
  fragment: "$houdini/plugins/houdini-svelte/runtime/stores.FragmentStore",
181619
181619
  subscription: "$houdini/plugins/houdini-svelte/runtime/stores.SubscriptionStore",
181620
- queryForwardsCursor: "$houdini/plugins/houdini-svelte/runtime/stores.QueryStoreForwardCursor",
181621
- queryBackwardsCursor: "$houdini/plugins/houdini-svelte/runtime/stores.QueryStoreBackwardCursor",
181620
+ queryCursor: "$houdini/plugins/houdini-svelte/runtime/stores.QueryStoreCursor",
181622
181621
  queryOffset: "$houdini/plugins/houdini-svelte/runtime/stores.QueryStoreOffset",
181623
- fragmentForwardsCursor: "$houdini/plugins/houdini-svelte/runtime/stores.FragmentStoreForwardCursor",
181624
- fragmentBackwardsCursor: "$houdini/plugins/houdini-svelte/runtime/stores.FragmentStoreBackwardCursor",
181622
+ fragmentCursor: "$houdini/plugins/houdini-svelte/runtime/stores.FragmentStoreCursor",
181625
181623
  fragmentOffset: "$houdini/plugins/houdini-svelte/runtime/stores.FragmentStoreOffset",
181626
181624
  ...cfg?.customStores
181627
181625
  },
@@ -182154,7 +182152,7 @@ async function fragmentStore({ config: config4, plugin_root }, doc) {
182154
182152
  const paginationMethod = doc.refetch?.method;
182155
182153
  let which = "fragment";
182156
182154
  if (paginationMethod === "cursor") {
182157
- which = doc.refetch?.direction === "forward" ? "fragmentForwardsCursor" : "fragmentBackwardsCursor";
182155
+ which = "fragmentCursor";
182158
182156
  } else if (paginationMethod === "offset") {
182159
182157
  which = "fragmentOffset";
182160
182158
  }
@@ -182248,7 +182246,7 @@ async function queryStore({ config: config4, plugin_root }, doc) {
182248
182246
  const paginationMethod = doc.refetch?.paginated && doc.refetch.method;
182249
182247
  let which = "query";
182250
182248
  if (paginationMethod === "cursor") {
182251
- which = doc.refetch?.direction === "forward" ? "queryForwardsCursor" : "queryBackwardsCursor";
182249
+ which = "queryCursor";
182252
182250
  } else if (paginationMethod === "offset") {
182253
182251
  which = "queryOffset";
182254
182252
  }
@@ -185273,11 +185273,9 @@ function plugin_config(config4) {
185273
185273
  mutation: "$houdini/plugins/houdini-svelte/runtime/stores.MutationStore",
185274
185274
  fragment: "$houdini/plugins/houdini-svelte/runtime/stores.FragmentStore",
185275
185275
  subscription: "$houdini/plugins/houdini-svelte/runtime/stores.SubscriptionStore",
185276
- queryForwardsCursor: "$houdini/plugins/houdini-svelte/runtime/stores.QueryStoreForwardCursor",
185277
- queryBackwardsCursor: "$houdini/plugins/houdini-svelte/runtime/stores.QueryStoreBackwardCursor",
185276
+ queryCursor: "$houdini/plugins/houdini-svelte/runtime/stores.QueryStoreCursor",
185278
185277
  queryOffset: "$houdini/plugins/houdini-svelte/runtime/stores.QueryStoreOffset",
185279
- fragmentForwardsCursor: "$houdini/plugins/houdini-svelte/runtime/stores.FragmentStoreForwardCursor",
185280
- fragmentBackwardsCursor: "$houdini/plugins/houdini-svelte/runtime/stores.FragmentStoreBackwardCursor",
185278
+ fragmentCursor: "$houdini/plugins/houdini-svelte/runtime/stores.FragmentStoreCursor",
185281
185279
  fragmentOffset: "$houdini/plugins/houdini-svelte/runtime/stores.FragmentStoreOffset",
185282
185280
  ...cfg?.customStores
185283
185281
  },
@@ -185265,11 +185265,9 @@ function plugin_config(config4) {
185265
185265
  mutation: "$houdini/plugins/houdini-svelte/runtime/stores.MutationStore",
185266
185266
  fragment: "$houdini/plugins/houdini-svelte/runtime/stores.FragmentStore",
185267
185267
  subscription: "$houdini/plugins/houdini-svelte/runtime/stores.SubscriptionStore",
185268
- queryForwardsCursor: "$houdini/plugins/houdini-svelte/runtime/stores.QueryStoreForwardCursor",
185269
- queryBackwardsCursor: "$houdini/plugins/houdini-svelte/runtime/stores.QueryStoreBackwardCursor",
185268
+ queryCursor: "$houdini/plugins/houdini-svelte/runtime/stores.QueryStoreCursor",
185270
185269
  queryOffset: "$houdini/plugins/houdini-svelte/runtime/stores.QueryStoreOffset",
185271
- fragmentForwardsCursor: "$houdini/plugins/houdini-svelte/runtime/stores.FragmentStoreForwardCursor",
185272
- fragmentBackwardsCursor: "$houdini/plugins/houdini-svelte/runtime/stores.FragmentStoreBackwardCursor",
185270
+ fragmentCursor: "$houdini/plugins/houdini-svelte/runtime/stores.FragmentStoreCursor",
185273
185271
  fragmentOffset: "$houdini/plugins/houdini-svelte/runtime/stores.FragmentStoreOffset",
185274
185272
  ...cfg?.customStores
185275
185273
  },
@@ -1,6 +1,7 @@
1
1
  import type { DocumentStore } from '$houdini/runtime/client';
2
2
  import type { MutationArtifact } from '$houdini/runtime/lib/types';
3
3
  import type { GraphQLObject } from '$houdini/runtime/lib/types';
4
+ import type { RequestEvent } from '@sveltejs/kit';
4
5
  export declare class MutationStore<_Data extends GraphQLObject, _Input extends {}, _Optimistic extends GraphQLObject> {
5
6
  artifact: MutationArtifact;
6
7
  kind: "HoudiniMutation";
@@ -8,9 +9,10 @@ export declare class MutationStore<_Data extends GraphQLObject, _Input extends {
8
9
  constructor({ artifact }: {
9
10
  artifact: MutationArtifact;
10
11
  });
11
- mutate(variables: _Input, { metadata, fetch, ...mutationConfig }?: {
12
+ mutate(variables: _Input, { metadata, fetch, event, ...mutationConfig }?: {
12
13
  metadata?: App.Metadata;
13
14
  fetch?: typeof globalThis.fetch;
15
+ event?: RequestEvent;
14
16
  } & MutationConfig<_Data, _Input, _Optimistic>): Promise<_Data>;
15
17
  subscribe(...args: Parameters<DocumentStore<_Data, _Input>['subscribe']>): import("$houdini/runtime/lib").Unsubscriber;
16
18
  }
@@ -9,7 +9,7 @@ export declare function cursorHandlers<_Data extends GraphQLObject, _Input exten
9
9
  storeName: string;
10
10
  observer: DocumentStore<_Data, _Input>;
11
11
  fetch: FetchFn<_Data, _Input>;
12
- fetchUpdate: FetchFn<_Data, _Input>;
12
+ fetchUpdate: (arg: Parameters<FetchFn<_Data, _Input>>[0], updates: string[]) => ReturnType<FetchFn<_Data, _Input>>;
13
13
  }): CursorHandlers<_Data, _Input>;
14
14
  export type CursorHandlers<_Data extends GraphQLObject, _Input> = {
15
15
  loadNextPage: (args?: {
@@ -3,7 +3,7 @@ import type { FragmentArtifact, GraphQLObject, HoudiniFetchContext, QueryArtifac
3
3
  import type { Readable, Subscriber } from 'svelte/store';
4
4
  import type { StoreConfig } from '../query';
5
5
  import type { CursorHandlers } from './cursor';
6
- import type { PageInfo } from './pageInfo';
6
+ import { type PageInfo } from './pageInfo';
7
7
  type FragmentStoreConfig<_Data extends GraphQLObject, _Input> = StoreConfig<_Data, _Input, FragmentArtifact> & {
8
8
  paginationArtifact: QueryArtifact;
9
9
  };
@@ -15,7 +15,7 @@ declare class BasePaginatedFragmentStore<_Data extends GraphQLObject, _Input> {
15
15
  constructor(config: FragmentStoreConfig<_Data, _Input>);
16
16
  protected queryVariables(store: Readable<FragmentPaginatedResult<_Data, unknown>>): _Input;
17
17
  }
18
- declare class FragmentStoreCursor<_Data extends GraphQLObject, _Input extends Record<string, any>> extends BasePaginatedFragmentStore<_Data, _Input> {
18
+ export declare class FragmentStoreCursor<_Data extends GraphQLObject, _Input extends Record<string, any>> extends BasePaginatedFragmentStore<_Data, _Input> {
19
19
  get(initialValue: _Data | null): {
20
20
  kind: import("$houdini/runtime/lib/types").ArtifactKind;
21
21
  data: Readable<_Data | null>;
@@ -27,48 +27,20 @@ declare class FragmentStoreCursor<_Data extends GraphQLObject, _Input extends Re
27
27
  fetching: Readable<boolean>;
28
28
  fetch: (args?: import("../query").QueryStoreFetchParams<_Data, _Input> | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
29
29
  pageInfo: import("svelte/store").Writable<PageInfo>;
30
- };
31
- protected storeHandlers(observer: DocumentStore<_Data, _Input>): CursorHandlers<_Data, _Input>;
32
- }
33
- export declare class FragmentStoreForwardCursor<_Data extends GraphQLObject, _Input extends Record<string, any>> extends FragmentStoreCursor<_Data, _Input> {
34
- get(initialValue: _Data | null): {
35
30
  loadNextPage: (args?: {
36
31
  first?: number | undefined;
37
32
  after?: string | undefined;
38
33
  fetch?: typeof fetch | undefined;
39
34
  metadata: {};
40
35
  } | undefined) => Promise<void>;
41
- kind: import("$houdini/runtime/lib/types").ArtifactKind;
42
- data: Readable<_Data | null>;
43
- subscribe: (run: Subscriber<FragmentPaginatedResult<_Data, {
44
- pageInfo: PageInfo;
45
- }>>, invalidate?: ((value?: FragmentPaginatedResult<_Data, {
46
- pageInfo: PageInfo;
47
- }> | undefined) => void) | undefined) => () => void;
48
- fetching: Readable<boolean>;
49
- fetch: (args?: import("../query").QueryStoreFetchParams<_Data, _Input> | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
50
- pageInfo: import("svelte/store").Writable<PageInfo>;
51
- };
52
- }
53
- export declare class FragmentStoreBackwardCursor<_Data extends GraphQLObject, _Input extends Record<string, any>> extends FragmentStoreCursor<_Data, _Input> {
54
- get(initialValue: _Data | null): {
55
36
  loadPreviousPage: (args?: {
56
37
  last?: number | undefined;
57
38
  before?: string | undefined;
58
39
  fetch?: typeof fetch | undefined;
59
40
  metadata?: {} | undefined;
60
41
  } | undefined) => Promise<void>;
61
- kind: import("$houdini/runtime/lib/types").ArtifactKind;
62
- data: Readable<_Data | null>;
63
- subscribe: (run: Subscriber<FragmentPaginatedResult<_Data, {
64
- pageInfo: PageInfo;
65
- }>>, invalidate?: ((value?: FragmentPaginatedResult<_Data, {
66
- pageInfo: PageInfo;
67
- }> | undefined) => void) | undefined) => () => void;
68
- fetching: Readable<boolean>;
69
- fetch: (args?: import("../query").QueryStoreFetchParams<_Data, _Input> | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
70
- pageInfo: import("svelte/store").Writable<PageInfo>;
71
42
  };
43
+ protected storeHandlers(observer: DocumentStore<_Data, _Input>): CursorHandlers<_Data, _Input>;
72
44
  }
73
45
  export declare class FragmentStoreOffset<_Data extends GraphQLObject, _Input extends Record<string, any>> extends BasePaginatedFragmentStore<_Data, _Input> {
74
46
  get(initialValue: _Data | null): {
@@ -1,2 +1,2 @@
1
- export { FragmentStoreBackwardCursor, FragmentStoreForwardCursor, FragmentStoreOffset, } from './fragment';
2
- export { QueryStoreBackwardCursor, QueryStoreForwardCursor, QueryStoreOffset } from './query';
1
+ export { FragmentStoreCursor, FragmentStoreOffset } from './fragment';
2
+ export { QueryStoreCursor, QueryStoreOffset } from './query';
@@ -4,28 +4,21 @@ import type { ClientFetchParams, LoadEventFetchParams, QueryStoreFetchParams, Re
4
4
  import { QueryStore } from '../query';
5
5
  import type { CursorHandlers } from './cursor';
6
6
  import type { OffsetHandlers } from './offset';
7
- import type { PageInfo } from './pageInfo';
7
+ import { type PageInfo } from './pageInfo';
8
8
  export type CursorStoreResult<_Data extends GraphQLObject, _Input extends {}> = QueryResult<_Data, _Input> & {
9
9
  pageInfo: PageInfo;
10
10
  };
11
- declare class CursorPaginatedStore<_Data extends GraphQLObject, _Input extends {}> extends QueryStore<_Data, _Input> {
11
+ export declare class QueryStoreCursor<_Data extends GraphQLObject, _Input extends {}> extends QueryStore<_Data, _Input> {
12
+ #private;
12
13
  paginated: boolean;
13
- protected handlers: CursorHandlers<_Data, _Input>;
14
14
  constructor(config: StoreConfig<_Data, _Input, QueryArtifact>);
15
15
  fetch(params?: RequestEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
16
16
  fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
17
17
  fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
18
18
  fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
19
- extraFields(): {
20
- pageInfo: PageInfo;
21
- };
22
- subscribe(run: Subscriber<CursorStoreResult<_Data, _Input>>, invalidate?: ((value?: CursorStoreResult<_Data, _Input> | undefined) => void) | undefined): () => void;
23
- }
24
- export declare class QueryStoreForwardCursor<_Data extends GraphQLObject, _Input extends {}> extends CursorPaginatedStore<_Data, _Input> {
25
- loadNextPage(args?: Parameters<CursorHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<void>;
26
- }
27
- export declare class QueryStoreBackwardCursor<_Data extends GraphQLObject, _Input extends {}> extends CursorPaginatedStore<_Data, _Input> {
28
19
  loadPreviousPage(args?: Parameters<Required<CursorHandlers<_Data, _Input>>['loadPreviousPage']>[0]): Promise<void>;
20
+ loadNextPage(args?: Parameters<CursorHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<void>;
21
+ subscribe(run: Subscriber<CursorStoreResult<_Data, _Input>>, invalidate?: ((value?: CursorStoreResult<_Data, _Input> | undefined) => void) | undefined): () => void;
29
22
  }
30
23
  export declare class QueryStoreOffset<_Data extends GraphQLObject, _Input extends {}> extends QueryStore<_Data, _Input> {
31
24
  paginated: boolean;
@@ -37,4 +30,3 @@ export declare class QueryStoreOffset<_Data extends GraphQLObject, _Input extend
37
30
  fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
38
31
  fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
39
32
  }
40
- export {};
@@ -1,6 +1,7 @@
1
1
  import type { DocumentStore } from '$houdini/runtime/client';
2
2
  import type { FetchContext } from '$houdini/runtime/client/plugins/fetch';
3
- import type { QueryArtifact, GraphQLObject, HoudiniFetchContext, QueryResult } from '$houdini/runtime/lib/types';
3
+ import type { QueryArtifact, MutationArtifact, GraphQLObject, HoudiniFetchContext, QueryResult } from '$houdini/runtime/lib/types';
4
+ import { ArtifactKind } from '$houdini/runtime/lib/types';
4
5
  import { CachePolicy } from '$houdini/runtime/lib/types';
5
6
  import type { LoadEvent, RequestEvent } from '@sveltejs/kit';
6
7
  import type { Readable } from 'svelte/store';
@@ -8,7 +9,7 @@ import type { PluginArtifactData } from '../../plugin/artifactData';
8
9
  export declare class QueryStore<_Data extends GraphQLObject, _Input extends {}> {
9
10
  artifact: QueryArtifact;
10
11
  variables: boolean;
11
- kind: import("$houdini/runtime/lib/types").ArtifactKind;
12
+ kind: ArtifactKind;
12
13
  protected observer: DocumentStore<_Data, _Input>;
13
14
  protected loadPending: boolean;
14
15
  protected subscriberCount: number;
@@ -33,9 +34,9 @@ export type StoreConfig<_Data extends GraphQLObject, _Input, _Artifact> = {
33
34
  storeName: string;
34
35
  variables: boolean;
35
36
  };
36
- export declare function fetchParams<_Data extends GraphQLObject, _Input>(artifact: QueryArtifact, storeName: string, params?: QueryStoreFetchParams<_Data, _Input>): Promise<{
37
+ export declare function fetchParams<_Data extends GraphQLObject, _Input>(artifact: QueryArtifact | MutationArtifact, storeName: string, params?: QueryStoreFetchParams<_Data, _Input>): Promise<{
37
38
  context: FetchContext;
38
- policy: CachePolicy;
39
+ policy: CachePolicy | undefined;
39
40
  params: QueryStoreFetchParams<_Data, _Input>;
40
41
  }>;
41
42
  type FetchGlobalParams<_Data extends GraphQLObject, _Input> = {
@@ -1,6 +1,7 @@
1
1
  import type { DocumentStore } from '$houdini/runtime/client';
2
2
  import type { MutationArtifact } from '$houdini/runtime/lib/types';
3
3
  import type { GraphQLObject } from '$houdini/runtime/lib/types';
4
+ import type { RequestEvent } from '@sveltejs/kit';
4
5
  export declare class MutationStore<_Data extends GraphQLObject, _Input extends {}, _Optimistic extends GraphQLObject> {
5
6
  artifact: MutationArtifact;
6
7
  kind: "HoudiniMutation";
@@ -8,9 +9,10 @@ export declare class MutationStore<_Data extends GraphQLObject, _Input extends {
8
9
  constructor({ artifact }: {
9
10
  artifact: MutationArtifact;
10
11
  });
11
- mutate(variables: _Input, { metadata, fetch, ...mutationConfig }?: {
12
+ mutate(variables: _Input, { metadata, fetch, event, ...mutationConfig }?: {
12
13
  metadata?: App.Metadata;
13
14
  fetch?: typeof globalThis.fetch;
15
+ event?: RequestEvent;
14
16
  } & MutationConfig<_Data, _Input, _Optimistic>): Promise<_Data>;
15
17
  subscribe(...args: Parameters<DocumentStore<_Data, _Input>['subscribe']>): import("$houdini/runtime/lib").Unsubscriber;
16
18
  }
@@ -22,7 +22,7 @@ __export(mutation_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(mutation_exports);
24
24
  var import_client = require("../client");
25
- var import_session = require("../session");
25
+ var import_query = require("./query");
26
26
  class MutationStore {
27
27
  artifact;
28
28
  kind = "HoudiniMutation";
@@ -34,13 +34,19 @@ class MutationStore {
34
34
  async mutate(variables, {
35
35
  metadata,
36
36
  fetch,
37
+ event,
37
38
  ...mutationConfig
38
39
  } = {}) {
40
+ const { context } = await (0, import_query.fetchParams)(this.artifact, this.artifact.name, {
41
+ fetch,
42
+ metadata,
43
+ event
44
+ });
39
45
  return (await this.store.send({
40
46
  variables,
41
- fetch,
47
+ fetch: context.fetch,
42
48
  metadata,
43
- session: await (0, import_session.getSession)(),
49
+ session: context.session,
44
50
  stuff: {
45
51
  ...mutationConfig
46
52
  }
@@ -9,7 +9,7 @@ export declare function cursorHandlers<_Data extends GraphQLObject, _Input exten
9
9
  storeName: string;
10
10
  observer: DocumentStore<_Data, _Input>;
11
11
  fetch: FetchFn<_Data, _Input>;
12
- fetchUpdate: FetchFn<_Data, _Input>;
12
+ fetchUpdate: (arg: Parameters<FetchFn<_Data, _Input>>[0], updates: string[]) => ReturnType<FetchFn<_Data, _Input>>;
13
13
  }): CursorHandlers<_Data, _Input>;
14
14
  export type CursorHandlers<_Data extends GraphQLObject, _Input> = {
15
15
  loadNextPage: (args?: {
@@ -42,7 +42,8 @@ function cursorHandlers({
42
42
  input,
43
43
  functionName,
44
44
  metadata = {},
45
- fetch
45
+ fetch,
46
+ where
46
47
  }) => {
47
48
  const config = (0, import_config.getCurrentConfig)();
48
49
  const loadVariables = {
@@ -52,12 +53,15 @@ function cursorHandlers({
52
53
  if (!loadVariables[pageSizeVar] && !artifact.refetch.pageSize) {
53
54
  throw (0, import_pageInfo.missingPageSizeError)(functionName);
54
55
  }
55
- const { data } = await parentFetchUpdate({
56
- variables: loadVariables,
57
- fetch,
58
- metadata,
59
- policy: import_lib.CachePolicy.NetworkOnly
60
- });
56
+ const { data } = await parentFetchUpdate(
57
+ {
58
+ variables: loadVariables,
59
+ fetch,
60
+ metadata,
61
+ policy: import_lib.CachePolicy.NetworkOnly
62
+ },
63
+ [where === "start" ? "prepend" : "append"]
64
+ );
61
65
  const resultPath = [...artifact.refetch.path];
62
66
  if (artifact.refetch.embedded) {
63
67
  const { targetType } = artifact.refetch;
@@ -77,22 +81,28 @@ function cursorHandlers({
77
81
  fetch,
78
82
  metadata
79
83
  } = {}) => {
84
+ if (artifact.refetch?.direction === "backward") {
85
+ console.warn(`\u26A0\uFE0F ${storeName}.loadNextPage was called but it does not support forwards pagination.
86
+ If you think this is an error, please open an issue on GitHub`);
87
+ return;
88
+ }
80
89
  const currentPageInfo = (0, import_pageInfo.extractPageInfo)(getState().data, artifact.refetch.path);
81
90
  if (!currentPageInfo.hasNextPage) {
82
91
  return;
83
92
  }
84
93
  const input = {
85
- after: after ?? currentPageInfo.endCursor
94
+ first: first ?? artifact.refetch.pageSize,
95
+ after: after ?? currentPageInfo.endCursor,
96
+ before: null,
97
+ last: null
86
98
  };
87
- if (first) {
88
- input.first = first;
89
- }
90
99
  return await loadPage({
91
100
  pageSizeVar: "first",
92
101
  functionName: "loadNextPage",
93
102
  input,
94
103
  fetch,
95
- metadata
104
+ metadata,
105
+ where: "end"
96
106
  });
97
107
  },
98
108
  loadPreviousPage: async ({
@@ -101,43 +111,64 @@ function cursorHandlers({
101
111
  fetch,
102
112
  metadata
103
113
  } = {}) => {
114
+ if (artifact.refetch?.direction === "forward") {
115
+ console.warn(`\u26A0\uFE0F ${storeName}.loadPreviousPage was called but it does not support backwards pagination.
116
+ If you think this is an error, please open an issue on GitHub`);
117
+ return;
118
+ }
104
119
  const currentPageInfo = (0, import_pageInfo.extractPageInfo)(getState().data, artifact.refetch.path);
105
120
  if (!currentPageInfo.hasPreviousPage) {
106
121
  return;
107
122
  }
108
123
  const input = {
109
- before: before ?? currentPageInfo.startCursor
124
+ before: before ?? currentPageInfo.startCursor,
125
+ last: last ?? artifact.refetch.pageSize,
126
+ first: null,
127
+ after: null
110
128
  };
111
- if (last) {
112
- input.last = last;
113
- }
114
129
  return await loadPage({
115
130
  pageSizeVar: "last",
116
131
  functionName: "loadPreviousPage",
117
132
  input,
118
133
  fetch,
119
- metadata
134
+ metadata,
135
+ where: "start"
120
136
  });
121
137
  },
122
138
  pageInfo,
123
139
  async fetch(args) {
124
140
  const { params } = await (0, import_query.fetchParams)(artifact, storeName, args);
125
141
  const { variables } = params ?? {};
126
- const queryVariables = {
127
- ...variables
128
- };
129
142
  if (variables && !(0, import_deepEquals.deepEquals)(getState().variables, variables)) {
130
- return await parentFetch({
131
- ...params,
132
- then(data) {
133
- pageInfo.set((0, import_pageInfo.extractPageInfo)(data, artifact.refetch.path));
134
- }
135
- });
143
+ return await parentFetch(params);
144
+ }
145
+ try {
146
+ var currentPageInfo = (0, import_pageInfo.extractPageInfo)(getState().data, artifact.refetch.path);
147
+ } catch {
148
+ return await parentFetch(params);
136
149
  }
150
+ const queryVariables = {};
137
151
  const count = (0, import_pageInfo.countPage)(artifact.refetch.path.concat("edges"), getState().data) || artifact.refetch.pageSize;
138
152
  if (count && count > artifact.refetch.pageSize) {
139
- queryVariables[artifact.refetch.update === "prepend" ? "last" : "first"] = count;
153
+ if (currentPageInfo.hasPreviousPage && currentPageInfo.hasNextPage && !(variables?.["first"] && variables?.["after"] || variables?.["last"] && variables?.["before"])) {
154
+ console.warn(`\u26A0\uFE0F Encountered a fetch() in the middle of the connection.
155
+ Make sure to pass a cursor value by hand that includes the current set (ie the entry before startCursor)
156
+ `);
157
+ return observer.state;
158
+ }
159
+ if (!currentPageInfo.hasPreviousPage) {
160
+ queryVariables["first"] = count;
161
+ queryVariables["after"] = null;
162
+ queryVariables["last"] = null;
163
+ queryVariables["before"] = null;
164
+ } else if (!currentPageInfo.hasNextPage) {
165
+ queryVariables["last"] = count;
166
+ queryVariables["first"] = null;
167
+ queryVariables["after"] = null;
168
+ queryVariables["before"] = null;
169
+ }
140
170
  }
171
+ Object.assign(queryVariables, variables ?? {});
141
172
  const result = await parentFetch({
142
173
  ...params,
143
174
  variables: queryVariables
@@ -3,7 +3,7 @@ import type { FragmentArtifact, GraphQLObject, HoudiniFetchContext, QueryArtifac
3
3
  import type { Readable, Subscriber } from 'svelte/store';
4
4
  import type { StoreConfig } from '../query';
5
5
  import type { CursorHandlers } from './cursor';
6
- import type { PageInfo } from './pageInfo';
6
+ import { type PageInfo } from './pageInfo';
7
7
  type FragmentStoreConfig<_Data extends GraphQLObject, _Input> = StoreConfig<_Data, _Input, FragmentArtifact> & {
8
8
  paginationArtifact: QueryArtifact;
9
9
  };
@@ -15,7 +15,7 @@ declare class BasePaginatedFragmentStore<_Data extends GraphQLObject, _Input> {
15
15
  constructor(config: FragmentStoreConfig<_Data, _Input>);
16
16
  protected queryVariables(store: Readable<FragmentPaginatedResult<_Data, unknown>>): _Input;
17
17
  }
18
- declare class FragmentStoreCursor<_Data extends GraphQLObject, _Input extends Record<string, any>> extends BasePaginatedFragmentStore<_Data, _Input> {
18
+ export declare class FragmentStoreCursor<_Data extends GraphQLObject, _Input extends Record<string, any>> extends BasePaginatedFragmentStore<_Data, _Input> {
19
19
  get(initialValue: _Data | null): {
20
20
  kind: import("$houdini/runtime/lib/types").ArtifactKind;
21
21
  data: Readable<_Data | null>;
@@ -27,48 +27,20 @@ declare class FragmentStoreCursor<_Data extends GraphQLObject, _Input extends Re
27
27
  fetching: Readable<boolean>;
28
28
  fetch: (args?: import("../query").QueryStoreFetchParams<_Data, _Input> | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
29
29
  pageInfo: import("svelte/store").Writable<PageInfo>;
30
- };
31
- protected storeHandlers(observer: DocumentStore<_Data, _Input>): CursorHandlers<_Data, _Input>;
32
- }
33
- export declare class FragmentStoreForwardCursor<_Data extends GraphQLObject, _Input extends Record<string, any>> extends FragmentStoreCursor<_Data, _Input> {
34
- get(initialValue: _Data | null): {
35
30
  loadNextPage: (args?: {
36
31
  first?: number | undefined;
37
32
  after?: string | undefined;
38
33
  fetch?: typeof fetch | undefined;
39
34
  metadata: {};
40
35
  } | undefined) => Promise<void>;
41
- kind: import("$houdini/runtime/lib/types").ArtifactKind;
42
- data: Readable<_Data | null>;
43
- subscribe: (run: Subscriber<FragmentPaginatedResult<_Data, {
44
- pageInfo: PageInfo;
45
- }>>, invalidate?: ((value?: FragmentPaginatedResult<_Data, {
46
- pageInfo: PageInfo;
47
- }> | undefined) => void) | undefined) => () => void;
48
- fetching: Readable<boolean>;
49
- fetch: (args?: import("../query").QueryStoreFetchParams<_Data, _Input> | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
50
- pageInfo: import("svelte/store").Writable<PageInfo>;
51
- };
52
- }
53
- export declare class FragmentStoreBackwardCursor<_Data extends GraphQLObject, _Input extends Record<string, any>> extends FragmentStoreCursor<_Data, _Input> {
54
- get(initialValue: _Data | null): {
55
36
  loadPreviousPage: (args?: {
56
37
  last?: number | undefined;
57
38
  before?: string | undefined;
58
39
  fetch?: typeof fetch | undefined;
59
40
  metadata?: {} | undefined;
60
41
  } | undefined) => Promise<void>;
61
- kind: import("$houdini/runtime/lib/types").ArtifactKind;
62
- data: Readable<_Data | null>;
63
- subscribe: (run: Subscriber<FragmentPaginatedResult<_Data, {
64
- pageInfo: PageInfo;
65
- }>>, invalidate?: ((value?: FragmentPaginatedResult<_Data, {
66
- pageInfo: PageInfo;
67
- }> | undefined) => void) | undefined) => () => void;
68
- fetching: Readable<boolean>;
69
- fetch: (args?: import("../query").QueryStoreFetchParams<_Data, _Input> | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
70
- pageInfo: import("svelte/store").Writable<PageInfo>;
71
42
  };
43
+ protected storeHandlers(observer: DocumentStore<_Data, _Input>): CursorHandlers<_Data, _Input>;
72
44
  }
73
45
  export declare class FragmentStoreOffset<_Data extends GraphQLObject, _Input extends Record<string, any>> extends BasePaginatedFragmentStore<_Data, _Input> {
74
46
  get(initialValue: _Data | null): {