houdini-svelte 1.1.2 → 1.1.4-react.0
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.
- package/build/plugin-cjs/index.js +261 -225
- package/build/plugin-esm/index.js +261 -225
- package/build/preprocess-cjs/index.js +272 -225
- package/build/preprocess-esm/index.js +272 -225
- package/build/runtime/stores/index.d.ts +1 -1
- package/build/runtime/stores/pagination/fragment.d.ts +4 -7
- package/build/runtime/stores/pagination/query.d.ts +3 -4
- package/build/runtime/stores/query.d.ts +2 -54
- package/build/runtime/types.d.ts +40 -28
- package/build/runtime-cjs/stores/index.d.ts +1 -1
- package/build/runtime-cjs/stores/pagination/fragment.d.ts +4 -7
- package/build/runtime-cjs/stores/pagination/fragment.js +6 -9
- package/build/runtime-cjs/stores/pagination/query.d.ts +3 -4
- package/build/runtime-cjs/stores/pagination/query.js +28 -22
- package/build/runtime-cjs/stores/query.d.ts +2 -54
- package/build/runtime-cjs/types.d.ts +40 -28
- package/build/runtime-esm/stores/index.d.ts +1 -1
- package/build/runtime-esm/stores/pagination/fragment.d.ts +4 -7
- package/build/runtime-esm/stores/pagination/fragment.js +4 -7
- package/build/runtime-esm/stores/pagination/query.d.ts +3 -4
- package/build/runtime-esm/stores/pagination/query.js +23 -17
- package/build/runtime-esm/stores/query.d.ts +2 -54
- package/build/runtime-esm/types.d.ts +40 -28
- package/build/test-cjs/index.js +601 -491
- package/build/test-esm/index.js +601 -491
- package/package.json +2 -2
- package/build/runtime/stores/pagination/cursor.d.ts +0 -13
- package/build/runtime/stores/pagination/fetch.d.ts +0 -3
- package/build/runtime/stores/pagination/offset.d.ts +0 -20
- package/build/runtime/stores/pagination/pageInfo.d.ts +0 -13
- package/build/runtime-cjs/stores/pagination/cursor.d.ts +0 -13
- package/build/runtime-cjs/stores/pagination/cursor.js +0 -191
- package/build/runtime-cjs/stores/pagination/fetch.d.ts +0 -3
- package/build/runtime-cjs/stores/pagination/fetch.js +0 -16
- package/build/runtime-cjs/stores/pagination/offset.d.ts +0 -20
- package/build/runtime-cjs/stores/pagination/offset.js +0 -89
- package/build/runtime-cjs/stores/pagination/pageInfo.d.ts +0 -13
- package/build/runtime-cjs/stores/pagination/pageInfo.js +0 -79
- package/build/runtime-esm/stores/pagination/cursor.d.ts +0 -13
- package/build/runtime-esm/stores/pagination/cursor.js +0 -167
- package/build/runtime-esm/stores/pagination/fetch.d.ts +0 -3
- package/build/runtime-esm/stores/pagination/fetch.js +0 -0
- package/build/runtime-esm/stores/pagination/offset.d.ts +0 -20
- package/build/runtime-esm/stores/pagination/offset.js +0 -65
- package/build/runtime-esm/stores/pagination/pageInfo.d.ts +0 -13
- package/build/runtime-esm/stores/pagination/pageInfo.js +0 -52
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { DocumentStore } from '$houdini/runtime/client';
|
|
2
|
-
import type { FragmentArtifact, GraphQLObject, HoudiniFetchContext, QueryArtifact } from '$houdini/runtime/lib/types';
|
|
2
|
+
import type { FragmentArtifact, GraphQLObject, HoudiniFetchContext, QueryArtifact, PageInfo } from '$houdini/runtime/lib/types';
|
|
3
|
+
import { CursorHandlers } from '$houdini/runtime/lib/types';
|
|
3
4
|
import type { Readable, Subscriber } from 'svelte/store';
|
|
4
|
-
import type {
|
|
5
|
+
import type { OffsetFragmentStoreInstance } from '../../types';
|
|
5
6
|
import type { StoreConfig } from '../query';
|
|
6
|
-
import { type PageInfo } from './pageInfo';
|
|
7
7
|
type FragmentStoreConfig<_Data extends GraphQLObject, _Input> = StoreConfig<_Data, _Input, FragmentArtifact> & {
|
|
8
8
|
paginationArtifact: QueryArtifact;
|
|
9
9
|
};
|
|
@@ -19,15 +19,12 @@ declare class BasePaginatedFragmentStore<_Data extends GraphQLObject, _Input> {
|
|
|
19
19
|
export declare class FragmentStoreCursor<_Data extends GraphQLObject, _Input extends Record<string, any>> extends BasePaginatedFragmentStore<_Data, _Input> {
|
|
20
20
|
get(initialValue: _Data | null): {
|
|
21
21
|
kind: "HoudiniFragment";
|
|
22
|
-
data: Readable<_Data | null>;
|
|
23
22
|
subscribe: (run: Subscriber<FragmentPaginatedResult<_Data, {
|
|
24
23
|
pageInfo: PageInfo;
|
|
25
24
|
}>>, invalidate?: ((value?: FragmentPaginatedResult<_Data, {
|
|
26
25
|
pageInfo: PageInfo;
|
|
27
26
|
}> | undefined) => void) | undefined) => (() => void);
|
|
28
|
-
|
|
29
|
-
fetch: (args?: import("../query").QueryStoreFetchParams<_Data, _Input> | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
|
|
30
|
-
pageInfo: import("svelte/store").Writable<PageInfo>;
|
|
27
|
+
fetch: (args?: import("$houdini/runtime/lib/types").FetchParams<_Input> | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
|
|
31
28
|
loadNextPage: (args?: {
|
|
32
29
|
first?: number | undefined;
|
|
33
30
|
after?: string | undefined;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { GraphQLObject, QueryArtifact, QueryResult } from '$houdini/runtime/lib/types';
|
|
1
|
+
import type { GraphQLObject, QueryArtifact, QueryResult, CursorHandlers, OffsetHandlers, PageInfo } from '$houdini/runtime/lib/types';
|
|
2
2
|
import type { Subscriber } from 'svelte/store';
|
|
3
|
-
import type {
|
|
4
|
-
import
|
|
3
|
+
import type { ClientFetchParams, LoadEventFetchParams, QueryStoreFetchParams, RequestEventFetchParams } from '../../types';
|
|
4
|
+
import { StoreConfig } from '../query';
|
|
5
5
|
import { QueryStore } from '../query';
|
|
6
|
-
import { type PageInfo } from './pageInfo';
|
|
7
6
|
export type CursorStoreResult<_Data extends GraphQLObject, _Input extends {}> = QueryResult<_Data, _Input> & {
|
|
8
7
|
pageInfo: PageInfo;
|
|
9
8
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FetchContext } from '$houdini/runtime/client/plugins/fetch';
|
|
2
|
-
import type { GraphQLObject,
|
|
3
|
-
import type { LoadEvent, RequestEvent } from '@sveltejs/kit';
|
|
2
|
+
import type { GraphQLObject, MutationArtifact, QueryArtifact, QueryResult, CachePolicies } from '$houdini/runtime/lib/types';
|
|
4
3
|
import type { PluginArtifactData } from '../../plugin/artifactData';
|
|
4
|
+
import type { ClientFetchParams, LoadEventFetchParams, QueryStoreFetchParams, RequestEventFetchParams } from '../types';
|
|
5
5
|
import { BaseStore } from './base';
|
|
6
6
|
export declare class QueryStore<_Data extends GraphQLObject, _Input extends {}> extends BaseStore<_Data, _Input, QueryArtifact> {
|
|
7
7
|
variables: boolean;
|
|
@@ -31,55 +31,3 @@ export declare function fetchParams<_Data extends GraphQLObject, _Input>(artifac
|
|
|
31
31
|
policy: CachePolicies | undefined;
|
|
32
32
|
params: QueryStoreFetchParams<_Data, _Input>;
|
|
33
33
|
}>;
|
|
34
|
-
type FetchGlobalParams<_Data extends GraphQLObject, _Input> = {
|
|
35
|
-
variables?: _Input;
|
|
36
|
-
/**
|
|
37
|
-
* The policy to use when performing the fetch. If set to CachePolicy.NetworkOnly,
|
|
38
|
-
* a request will always be sent, even if the variables are the same as the last call
|
|
39
|
-
* to fetch.
|
|
40
|
-
*/
|
|
41
|
-
policy?: CachePolicies;
|
|
42
|
-
/**
|
|
43
|
-
* An object that will be passed to the fetch function.
|
|
44
|
-
* You can do what you want with it!
|
|
45
|
-
*/
|
|
46
|
-
metadata?: App.Metadata;
|
|
47
|
-
/**
|
|
48
|
-
* Set to true if you want the promise to pause while it's resolving.
|
|
49
|
-
* Only enable this if you know what you are doing. This will cause route
|
|
50
|
-
* transitions to pause while loading data.
|
|
51
|
-
*/
|
|
52
|
-
blocking?: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* A function to call after the fetch happens (whether fake or not)
|
|
55
|
-
*/
|
|
56
|
-
then?: (val: _Data | null) => void | Promise<void>;
|
|
57
|
-
};
|
|
58
|
-
export type LoadEventFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams<_Data, _Input> & {
|
|
59
|
-
/**
|
|
60
|
-
* Directly the `even` param coming from the `load` function
|
|
61
|
-
*/
|
|
62
|
-
event?: LoadEvent;
|
|
63
|
-
};
|
|
64
|
-
export type RequestEventFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams<_Data, _Input> & {
|
|
65
|
-
/**
|
|
66
|
-
* A RequestEvent should be provided when the store is being used in an endpoint.
|
|
67
|
-
* When this happens, fetch also needs to be provided
|
|
68
|
-
*/
|
|
69
|
-
event?: RequestEvent;
|
|
70
|
-
/**
|
|
71
|
-
* The fetch function to use when using this store in an endpoint.
|
|
72
|
-
*/
|
|
73
|
-
fetch?: LoadEvent['fetch'];
|
|
74
|
-
};
|
|
75
|
-
export type ClientFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams<_Data, _Input> & {
|
|
76
|
-
/**
|
|
77
|
-
* An object containing all of the current info necessary for a
|
|
78
|
-
* client-side fetch. Must be called in component initialization with
|
|
79
|
-
* something like this: `const context = getHoudiniFetchContext()`
|
|
80
|
-
*/
|
|
81
|
-
context?: HoudiniFetchContext;
|
|
82
|
-
};
|
|
83
|
-
export type QueryStoreFetchParams<_Data extends GraphQLObject, _Input> = QueryStoreLoadParams<_Data, _Input> | ClientFetchParams<_Data, _Input>;
|
|
84
|
-
export type QueryStoreLoadParams<_Data extends GraphQLObject, _Input> = LoadEventFetchParams<_Data, _Input> | RequestEventFetchParams<_Data, _Input>;
|
|
85
|
-
export {};
|
package/build/runtime/types.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type { FetchQueryResult, CompiledFragmentKind, QueryResult, GraphQLObject } from '$houdini/runtime/lib/types';
|
|
2
|
-
import type { LoadEvent } from '@sveltejs/kit';
|
|
3
|
-
import type { Readable
|
|
4
|
-
import type { QueryStoreFetchParams } from './stores';
|
|
5
|
-
import type { PageInfo } from './stores/pagination/pageInfo';
|
|
1
|
+
import type { FetchQueryResult, CompiledFragmentKind, QueryResult, GraphQLObject, CursorHandlers, OffsetHandlers, PageInfo, HoudiniFetchContext, FetchParams } from '$houdini/runtime/lib/types';
|
|
2
|
+
import type { LoadEvent, RequestEvent } from '@sveltejs/kit';
|
|
3
|
+
import type { Readable } from 'svelte/store';
|
|
6
4
|
export type QueryInputs<_Data> = FetchQueryResult<_Data> & {
|
|
7
5
|
variables: {
|
|
8
6
|
[key: string]: any;
|
|
@@ -54,29 +52,43 @@ export type OffsetFragmentStoreInstance<_Data extends GraphQLObject, _Input> = {
|
|
|
54
52
|
subscribe: Readable<Reshape<_Data, _Input>>['subscribe'];
|
|
55
53
|
fetching: Readable<boolean>;
|
|
56
54
|
} & OffsetHandlers<_Data, _Input>;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
metadata?: {};
|
|
69
|
-
}) => Promise<void>;
|
|
70
|
-
pageInfo: Writable<PageInfo>;
|
|
71
|
-
fetch(args?: QueryStoreFetchParams<_Data, _Input> | undefined): Promise<QueryResult<_Data, _Input>>;
|
|
55
|
+
type FetchGlobalParams<_Data extends GraphQLObject, _Input> = FetchParams<_Input> & {
|
|
56
|
+
/**
|
|
57
|
+
* Set to true if you want the promise to pause while it's resolving.
|
|
58
|
+
* Only enable this if you know what you are doing. This will cause route
|
|
59
|
+
* transitions to pause while loading data.
|
|
60
|
+
*/
|
|
61
|
+
blocking?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* A function to call after the fetch happens (whether fake or not)
|
|
64
|
+
*/
|
|
65
|
+
then?: (val: _Data | null) => void | Promise<void>;
|
|
72
66
|
};
|
|
73
|
-
export type
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
fetch?: typeof globalThis.fetch;
|
|
79
|
-
}) => Promise<void>;
|
|
80
|
-
fetch(args?: QueryStoreFetchParams<_Data, _Input> | undefined): Promise<QueryResult<_Data, _Input>>;
|
|
67
|
+
export type LoadEventFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams<_Data, _Input> & {
|
|
68
|
+
/**
|
|
69
|
+
* Directly the `even` param coming from the `load` function
|
|
70
|
+
*/
|
|
71
|
+
event?: LoadEvent;
|
|
81
72
|
};
|
|
73
|
+
export type RequestEventFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams<_Data, _Input> & {
|
|
74
|
+
/**
|
|
75
|
+
* A RequestEvent should be provided when the store is being used in an endpoint.
|
|
76
|
+
* When this happens, fetch also needs to be provided
|
|
77
|
+
*/
|
|
78
|
+
event?: RequestEvent;
|
|
79
|
+
/**
|
|
80
|
+
* The fetch function to use when using this store in an endpoint.
|
|
81
|
+
*/
|
|
82
|
+
fetch?: LoadEvent['fetch'];
|
|
83
|
+
};
|
|
84
|
+
export type ClientFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams<_Data, _Input> & {
|
|
85
|
+
/**
|
|
86
|
+
* An object containing all of the current info necessary for a
|
|
87
|
+
* client-side fetch. Must be called in component initialization with
|
|
88
|
+
* something like this: `const context = getHoudiniFetchContext()`
|
|
89
|
+
*/
|
|
90
|
+
context?: HoudiniFetchContext;
|
|
91
|
+
};
|
|
92
|
+
export type QueryStoreFetchParams<_Data extends GraphQLObject, _Input> = QueryStoreLoadParams<_Data, _Input> | ClientFetchParams<_Data, _Input>;
|
|
93
|
+
export type QueryStoreLoadParams<_Data extends GraphQLObject, _Input> = LoadEventFetchParams<_Data, _Input> | RequestEventFetchParams<_Data, _Input>;
|
|
82
94
|
export {};
|
|
@@ -2,4 +2,4 @@ export * from './pagination';
|
|
|
2
2
|
export { FragmentStore } from './fragment';
|
|
3
3
|
export { SubscriptionStore } from './subscription';
|
|
4
4
|
export { MutationStore, type MutationConfig } from './mutation';
|
|
5
|
-
export { QueryStore
|
|
5
|
+
export { QueryStore } from './query';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { DocumentStore } from '$houdini/runtime/client';
|
|
2
|
-
import type { FragmentArtifact, GraphQLObject, HoudiniFetchContext, QueryArtifact } from '$houdini/runtime/lib/types';
|
|
2
|
+
import type { FragmentArtifact, GraphQLObject, HoudiniFetchContext, QueryArtifact, PageInfo } from '$houdini/runtime/lib/types';
|
|
3
|
+
import { CursorHandlers } from '$houdini/runtime/lib/types';
|
|
3
4
|
import type { Readable, Subscriber } from 'svelte/store';
|
|
4
|
-
import type {
|
|
5
|
+
import type { OffsetFragmentStoreInstance } from '../../types';
|
|
5
6
|
import type { StoreConfig } from '../query';
|
|
6
|
-
import { type PageInfo } from './pageInfo';
|
|
7
7
|
type FragmentStoreConfig<_Data extends GraphQLObject, _Input> = StoreConfig<_Data, _Input, FragmentArtifact> & {
|
|
8
8
|
paginationArtifact: QueryArtifact;
|
|
9
9
|
};
|
|
@@ -19,15 +19,12 @@ declare class BasePaginatedFragmentStore<_Data extends GraphQLObject, _Input> {
|
|
|
19
19
|
export declare class FragmentStoreCursor<_Data extends GraphQLObject, _Input extends Record<string, any>> extends BasePaginatedFragmentStore<_Data, _Input> {
|
|
20
20
|
get(initialValue: _Data | null): {
|
|
21
21
|
kind: "HoudiniFragment";
|
|
22
|
-
data: Readable<_Data | null>;
|
|
23
22
|
subscribe: (run: Subscriber<FragmentPaginatedResult<_Data, {
|
|
24
23
|
pageInfo: PageInfo;
|
|
25
24
|
}>>, invalidate?: ((value?: FragmentPaginatedResult<_Data, {
|
|
26
25
|
pageInfo: PageInfo;
|
|
27
26
|
}> | undefined) => void) | undefined) => (() => void);
|
|
28
|
-
|
|
29
|
-
fetch: (args?: import("../query").QueryStoreFetchParams<_Data, _Input> | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
|
|
30
|
-
pageInfo: import("svelte/store").Writable<PageInfo>;
|
|
27
|
+
fetch: (args?: import("$houdini/runtime/lib/types").FetchParams<_Input> | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
|
|
31
28
|
loadNextPage: (args?: {
|
|
32
29
|
first?: number | undefined;
|
|
33
30
|
after?: string | undefined;
|
|
@@ -24,14 +24,13 @@ __export(fragment_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(fragment_exports);
|
|
25
25
|
var import_config = require("$houdini/runtime/lib/config");
|
|
26
26
|
var import_constants = require("$houdini/runtime/lib/constants");
|
|
27
|
+
var import_pageInfo = require("$houdini/runtime/lib/pageInfo");
|
|
28
|
+
var import_pagination = require("$houdini/runtime/lib/pagination");
|
|
27
29
|
var import_types = require("$houdini/runtime/lib/types");
|
|
28
30
|
var import_store = require("svelte/store");
|
|
29
31
|
var import_client = require("../../client");
|
|
30
32
|
var import_session = require("../../session");
|
|
31
33
|
var import_fragment = require("../fragment");
|
|
32
|
-
var import_cursor = require("./cursor");
|
|
33
|
-
var import_offset = require("./offset");
|
|
34
|
-
var import_pageInfo = require("./pageInfo");
|
|
35
34
|
class BasePaginatedFragmentStore {
|
|
36
35
|
paginated = true;
|
|
37
36
|
paginationArtifact;
|
|
@@ -94,17 +93,14 @@ class FragmentStoreCursor extends BasePaginatedFragmentStore {
|
|
|
94
93
|
};
|
|
95
94
|
return {
|
|
96
95
|
kind: import_types.CompiledFragmentKind,
|
|
97
|
-
data: (0, import_store.derived)(store, ($value) => $value),
|
|
98
96
|
subscribe,
|
|
99
|
-
fetching: (0, import_store.derived)([paginationStore], ([$store]) => $store.fetching),
|
|
100
97
|
fetch: handlers.fetch,
|
|
101
|
-
pageInfo: handlers.pageInfo,
|
|
102
98
|
loadNextPage: handlers.loadNextPage,
|
|
103
99
|
loadPreviousPage: handlers.loadPreviousPage
|
|
104
100
|
};
|
|
105
101
|
}
|
|
106
102
|
storeHandlers(observer, initialValue, getState, getVariables) {
|
|
107
|
-
return (0,
|
|
103
|
+
return (0, import_pagination.cursorHandlers)({
|
|
108
104
|
getState,
|
|
109
105
|
getVariables,
|
|
110
106
|
artifact: this.paginationArtifact,
|
|
@@ -137,7 +133,7 @@ class FragmentStoreCursor extends BasePaginatedFragmentStore {
|
|
|
137
133
|
}
|
|
138
134
|
});
|
|
139
135
|
},
|
|
140
|
-
|
|
136
|
+
getSession: import_session.getSession,
|
|
141
137
|
storeName: this.name
|
|
142
138
|
});
|
|
143
139
|
}
|
|
@@ -154,7 +150,7 @@ class FragmentStoreOffset extends BasePaginatedFragmentStore {
|
|
|
154
150
|
initialValue: store.initialValue
|
|
155
151
|
});
|
|
156
152
|
const getState = () => (0, import_store.get)(store);
|
|
157
|
-
const handlers = (0,
|
|
153
|
+
const handlers = (0, import_pagination.offsetHandlers)({
|
|
158
154
|
getState,
|
|
159
155
|
getVariables: () => store.variables,
|
|
160
156
|
artifact: this.paginationArtifact,
|
|
@@ -186,6 +182,7 @@ class FragmentStoreOffset extends BasePaginatedFragmentStore {
|
|
|
186
182
|
}
|
|
187
183
|
});
|
|
188
184
|
},
|
|
185
|
+
getSession: import_session.getSession,
|
|
189
186
|
storeName: this.name
|
|
190
187
|
});
|
|
191
188
|
const subscribe = (run, invalidate) => {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { GraphQLObject, QueryArtifact, QueryResult } from '$houdini/runtime/lib/types';
|
|
1
|
+
import type { GraphQLObject, QueryArtifact, QueryResult, CursorHandlers, OffsetHandlers, PageInfo } from '$houdini/runtime/lib/types';
|
|
2
2
|
import type { Subscriber } from 'svelte/store';
|
|
3
|
-
import type {
|
|
4
|
-
import
|
|
3
|
+
import type { ClientFetchParams, LoadEventFetchParams, QueryStoreFetchParams, RequestEventFetchParams } from '../../types';
|
|
4
|
+
import { StoreConfig } from '../query';
|
|
5
5
|
import { QueryStore } from '../query';
|
|
6
|
-
import { type PageInfo } from './pageInfo';
|
|
7
6
|
export type CursorStoreResult<_Data extends GraphQLObject, _Input extends {}> = QueryResult<_Data, _Input> & {
|
|
8
7
|
pageInfo: PageInfo;
|
|
9
8
|
};
|
|
@@ -22,41 +22,40 @@ __export(query_exports, {
|
|
|
22
22
|
QueryStoreOffset: () => QueryStoreOffset
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(query_exports);
|
|
25
|
+
var import_pageInfo = require("$houdini/runtime/lib/pageInfo");
|
|
26
|
+
var import_pagination = require("$houdini/runtime/lib/pagination");
|
|
25
27
|
var import_store = require("svelte/store");
|
|
26
28
|
var import_client = require("../../client");
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
var import_pageInfo = require("./pageInfo");
|
|
31
|
-
class QueryStoreCursor extends import_query.QueryStore {
|
|
29
|
+
var import_session = require("../../session");
|
|
30
|
+
var import_query2 = require("../query");
|
|
31
|
+
class QueryStoreCursor extends import_query2.QueryStore {
|
|
32
32
|
paginated = true;
|
|
33
33
|
constructor(config) {
|
|
34
34
|
super(config);
|
|
35
35
|
}
|
|
36
36
|
#_handlers = null;
|
|
37
|
-
|
|
37
|
+
async #handlers() {
|
|
38
38
|
if (this.#_handlers) {
|
|
39
39
|
return this.#_handlers;
|
|
40
40
|
}
|
|
41
|
+
await (0, import_client.initClient)();
|
|
41
42
|
const paginationObserver = (0, import_client.getClient)().observe({
|
|
42
43
|
artifact: this.artifact
|
|
43
44
|
});
|
|
44
|
-
this.#_handlers = (0,
|
|
45
|
+
this.#_handlers = (0, import_pagination.cursorHandlers)({
|
|
45
46
|
artifact: this.artifact,
|
|
46
|
-
initialValue: (0, import_store.get)(this.observer).data,
|
|
47
47
|
getState: () => (0, import_store.get)(this.observer).data,
|
|
48
48
|
getVariables: () => (0, import_store.get)(this.observer).variables,
|
|
49
49
|
storeName: this.name,
|
|
50
50
|
fetch: super.fetch.bind(this),
|
|
51
|
+
getSession: import_session.getSession,
|
|
51
52
|
fetchUpdate: async (args, updates) => {
|
|
52
|
-
await (0, import_client.initClient)();
|
|
53
53
|
return paginationObserver.send({
|
|
54
54
|
...args,
|
|
55
|
-
variables: {
|
|
56
|
-
...args?.variables
|
|
57
|
-
},
|
|
58
55
|
cacheParams: {
|
|
59
|
-
applyUpdates: updates
|
|
56
|
+
applyUpdates: updates,
|
|
57
|
+
disableSubscriptions: true,
|
|
58
|
+
...args?.cacheParams
|
|
60
59
|
}
|
|
61
60
|
});
|
|
62
61
|
}
|
|
@@ -64,13 +63,16 @@ class QueryStoreCursor extends import_query.QueryStore {
|
|
|
64
63
|
return this.#_handlers;
|
|
65
64
|
}
|
|
66
65
|
async fetch(args) {
|
|
67
|
-
|
|
66
|
+
const handlers = await this.#handlers();
|
|
67
|
+
return await handlers.fetch.call(this, args);
|
|
68
68
|
}
|
|
69
69
|
async loadPreviousPage(args) {
|
|
70
|
-
|
|
70
|
+
const handlers = await this.#handlers();
|
|
71
|
+
return await handlers.loadPreviousPage(args);
|
|
71
72
|
}
|
|
72
73
|
async loadNextPage(args) {
|
|
73
|
-
|
|
74
|
+
const handlers = await this.#handlers();
|
|
75
|
+
return await handlers.loadNextPage(args);
|
|
74
76
|
}
|
|
75
77
|
subscribe(run, invalidate) {
|
|
76
78
|
const combined = (0, import_store.derived)([{ subscribe: super.subscribe.bind(this) }], ([$parent]) => {
|
|
@@ -82,28 +84,32 @@ class QueryStoreCursor extends import_query.QueryStore {
|
|
|
82
84
|
return combined.subscribe(run, invalidate);
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
|
-
class QueryStoreOffset extends
|
|
87
|
+
class QueryStoreOffset extends import_query2.QueryStore {
|
|
86
88
|
paginated = true;
|
|
87
89
|
async loadNextPage(args) {
|
|
88
|
-
|
|
90
|
+
const handlers = await this.#handlers();
|
|
91
|
+
return await handlers.loadNextPage.call(this, args);
|
|
89
92
|
}
|
|
90
|
-
fetch(args) {
|
|
91
|
-
|
|
93
|
+
async fetch(args) {
|
|
94
|
+
const handlers = await this.#handlers();
|
|
95
|
+
return await handlers.fetch.call(this, args);
|
|
92
96
|
}
|
|
93
97
|
#_handlers = null;
|
|
94
|
-
|
|
98
|
+
async #handlers() {
|
|
95
99
|
if (this.#_handlers) {
|
|
96
100
|
return this.#_handlers;
|
|
97
101
|
}
|
|
102
|
+
await (0, import_client.initClient)();
|
|
98
103
|
const paginationObserver = (0, import_client.getClient)().observe({
|
|
99
104
|
artifact: this.artifact
|
|
100
105
|
});
|
|
101
|
-
this.#_handlers = (0,
|
|
106
|
+
this.#_handlers = (0, import_pagination.offsetHandlers)({
|
|
102
107
|
artifact: this.artifact,
|
|
103
108
|
storeName: this.name,
|
|
104
109
|
fetch: super.fetch,
|
|
105
110
|
getState: () => (0, import_store.get)(this.observer).data,
|
|
106
111
|
getVariables: () => (0, import_store.get)(this.observer).variables,
|
|
112
|
+
getSession: import_session.getSession,
|
|
107
113
|
fetchUpdate: async (args) => {
|
|
108
114
|
await (0, import_client.initClient)();
|
|
109
115
|
return paginationObserver.send({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FetchContext } from '$houdini/runtime/client/plugins/fetch';
|
|
2
|
-
import type { GraphQLObject,
|
|
3
|
-
import type { LoadEvent, RequestEvent } from '@sveltejs/kit';
|
|
2
|
+
import type { GraphQLObject, MutationArtifact, QueryArtifact, QueryResult, CachePolicies } from '$houdini/runtime/lib/types';
|
|
4
3
|
import type { PluginArtifactData } from '../../plugin/artifactData';
|
|
4
|
+
import type { ClientFetchParams, LoadEventFetchParams, QueryStoreFetchParams, RequestEventFetchParams } from '../types';
|
|
5
5
|
import { BaseStore } from './base';
|
|
6
6
|
export declare class QueryStore<_Data extends GraphQLObject, _Input extends {}> extends BaseStore<_Data, _Input, QueryArtifact> {
|
|
7
7
|
variables: boolean;
|
|
@@ -31,55 +31,3 @@ export declare function fetchParams<_Data extends GraphQLObject, _Input>(artifac
|
|
|
31
31
|
policy: CachePolicies | undefined;
|
|
32
32
|
params: QueryStoreFetchParams<_Data, _Input>;
|
|
33
33
|
}>;
|
|
34
|
-
type FetchGlobalParams<_Data extends GraphQLObject, _Input> = {
|
|
35
|
-
variables?: _Input;
|
|
36
|
-
/**
|
|
37
|
-
* The policy to use when performing the fetch. If set to CachePolicy.NetworkOnly,
|
|
38
|
-
* a request will always be sent, even if the variables are the same as the last call
|
|
39
|
-
* to fetch.
|
|
40
|
-
*/
|
|
41
|
-
policy?: CachePolicies;
|
|
42
|
-
/**
|
|
43
|
-
* An object that will be passed to the fetch function.
|
|
44
|
-
* You can do what you want with it!
|
|
45
|
-
*/
|
|
46
|
-
metadata?: App.Metadata;
|
|
47
|
-
/**
|
|
48
|
-
* Set to true if you want the promise to pause while it's resolving.
|
|
49
|
-
* Only enable this if you know what you are doing. This will cause route
|
|
50
|
-
* transitions to pause while loading data.
|
|
51
|
-
*/
|
|
52
|
-
blocking?: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* A function to call after the fetch happens (whether fake or not)
|
|
55
|
-
*/
|
|
56
|
-
then?: (val: _Data | null) => void | Promise<void>;
|
|
57
|
-
};
|
|
58
|
-
export type LoadEventFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams<_Data, _Input> & {
|
|
59
|
-
/**
|
|
60
|
-
* Directly the `even` param coming from the `load` function
|
|
61
|
-
*/
|
|
62
|
-
event?: LoadEvent;
|
|
63
|
-
};
|
|
64
|
-
export type RequestEventFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams<_Data, _Input> & {
|
|
65
|
-
/**
|
|
66
|
-
* A RequestEvent should be provided when the store is being used in an endpoint.
|
|
67
|
-
* When this happens, fetch also needs to be provided
|
|
68
|
-
*/
|
|
69
|
-
event?: RequestEvent;
|
|
70
|
-
/**
|
|
71
|
-
* The fetch function to use when using this store in an endpoint.
|
|
72
|
-
*/
|
|
73
|
-
fetch?: LoadEvent['fetch'];
|
|
74
|
-
};
|
|
75
|
-
export type ClientFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams<_Data, _Input> & {
|
|
76
|
-
/**
|
|
77
|
-
* An object containing all of the current info necessary for a
|
|
78
|
-
* client-side fetch. Must be called in component initialization with
|
|
79
|
-
* something like this: `const context = getHoudiniFetchContext()`
|
|
80
|
-
*/
|
|
81
|
-
context?: HoudiniFetchContext;
|
|
82
|
-
};
|
|
83
|
-
export type QueryStoreFetchParams<_Data extends GraphQLObject, _Input> = QueryStoreLoadParams<_Data, _Input> | ClientFetchParams<_Data, _Input>;
|
|
84
|
-
export type QueryStoreLoadParams<_Data extends GraphQLObject, _Input> = LoadEventFetchParams<_Data, _Input> | RequestEventFetchParams<_Data, _Input>;
|
|
85
|
-
export {};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type { FetchQueryResult, CompiledFragmentKind, QueryResult, GraphQLObject } from '$houdini/runtime/lib/types';
|
|
2
|
-
import type { LoadEvent } from '@sveltejs/kit';
|
|
3
|
-
import type { Readable
|
|
4
|
-
import type { QueryStoreFetchParams } from './stores';
|
|
5
|
-
import type { PageInfo } from './stores/pagination/pageInfo';
|
|
1
|
+
import type { FetchQueryResult, CompiledFragmentKind, QueryResult, GraphQLObject, CursorHandlers, OffsetHandlers, PageInfo, HoudiniFetchContext, FetchParams } from '$houdini/runtime/lib/types';
|
|
2
|
+
import type { LoadEvent, RequestEvent } from '@sveltejs/kit';
|
|
3
|
+
import type { Readable } from 'svelte/store';
|
|
6
4
|
export type QueryInputs<_Data> = FetchQueryResult<_Data> & {
|
|
7
5
|
variables: {
|
|
8
6
|
[key: string]: any;
|
|
@@ -54,29 +52,43 @@ export type OffsetFragmentStoreInstance<_Data extends GraphQLObject, _Input> = {
|
|
|
54
52
|
subscribe: Readable<Reshape<_Data, _Input>>['subscribe'];
|
|
55
53
|
fetching: Readable<boolean>;
|
|
56
54
|
} & OffsetHandlers<_Data, _Input>;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
metadata?: {};
|
|
69
|
-
}) => Promise<void>;
|
|
70
|
-
pageInfo: Writable<PageInfo>;
|
|
71
|
-
fetch(args?: QueryStoreFetchParams<_Data, _Input> | undefined): Promise<QueryResult<_Data, _Input>>;
|
|
55
|
+
type FetchGlobalParams<_Data extends GraphQLObject, _Input> = FetchParams<_Input> & {
|
|
56
|
+
/**
|
|
57
|
+
* Set to true if you want the promise to pause while it's resolving.
|
|
58
|
+
* Only enable this if you know what you are doing. This will cause route
|
|
59
|
+
* transitions to pause while loading data.
|
|
60
|
+
*/
|
|
61
|
+
blocking?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* A function to call after the fetch happens (whether fake or not)
|
|
64
|
+
*/
|
|
65
|
+
then?: (val: _Data | null) => void | Promise<void>;
|
|
72
66
|
};
|
|
73
|
-
export type
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
fetch?: typeof globalThis.fetch;
|
|
79
|
-
}) => Promise<void>;
|
|
80
|
-
fetch(args?: QueryStoreFetchParams<_Data, _Input> | undefined): Promise<QueryResult<_Data, _Input>>;
|
|
67
|
+
export type LoadEventFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams<_Data, _Input> & {
|
|
68
|
+
/**
|
|
69
|
+
* Directly the `even` param coming from the `load` function
|
|
70
|
+
*/
|
|
71
|
+
event?: LoadEvent;
|
|
81
72
|
};
|
|
73
|
+
export type RequestEventFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams<_Data, _Input> & {
|
|
74
|
+
/**
|
|
75
|
+
* A RequestEvent should be provided when the store is being used in an endpoint.
|
|
76
|
+
* When this happens, fetch also needs to be provided
|
|
77
|
+
*/
|
|
78
|
+
event?: RequestEvent;
|
|
79
|
+
/**
|
|
80
|
+
* The fetch function to use when using this store in an endpoint.
|
|
81
|
+
*/
|
|
82
|
+
fetch?: LoadEvent['fetch'];
|
|
83
|
+
};
|
|
84
|
+
export type ClientFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams<_Data, _Input> & {
|
|
85
|
+
/**
|
|
86
|
+
* An object containing all of the current info necessary for a
|
|
87
|
+
* client-side fetch. Must be called in component initialization with
|
|
88
|
+
* something like this: `const context = getHoudiniFetchContext()`
|
|
89
|
+
*/
|
|
90
|
+
context?: HoudiniFetchContext;
|
|
91
|
+
};
|
|
92
|
+
export type QueryStoreFetchParams<_Data extends GraphQLObject, _Input> = QueryStoreLoadParams<_Data, _Input> | ClientFetchParams<_Data, _Input>;
|
|
93
|
+
export type QueryStoreLoadParams<_Data extends GraphQLObject, _Input> = LoadEventFetchParams<_Data, _Input> | RequestEventFetchParams<_Data, _Input>;
|
|
82
94
|
export {};
|
|
@@ -2,4 +2,4 @@ export * from './pagination';
|
|
|
2
2
|
export { FragmentStore } from './fragment';
|
|
3
3
|
export { SubscriptionStore } from './subscription';
|
|
4
4
|
export { MutationStore, type MutationConfig } from './mutation';
|
|
5
|
-
export { QueryStore
|
|
5
|
+
export { QueryStore } from './query';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { DocumentStore } from '$houdini/runtime/client';
|
|
2
|
-
import type { FragmentArtifact, GraphQLObject, HoudiniFetchContext, QueryArtifact } from '$houdini/runtime/lib/types';
|
|
2
|
+
import type { FragmentArtifact, GraphQLObject, HoudiniFetchContext, QueryArtifact, PageInfo } from '$houdini/runtime/lib/types';
|
|
3
|
+
import { CursorHandlers } from '$houdini/runtime/lib/types';
|
|
3
4
|
import type { Readable, Subscriber } from 'svelte/store';
|
|
4
|
-
import type {
|
|
5
|
+
import type { OffsetFragmentStoreInstance } from '../../types';
|
|
5
6
|
import type { StoreConfig } from '../query';
|
|
6
|
-
import { type PageInfo } from './pageInfo';
|
|
7
7
|
type FragmentStoreConfig<_Data extends GraphQLObject, _Input> = StoreConfig<_Data, _Input, FragmentArtifact> & {
|
|
8
8
|
paginationArtifact: QueryArtifact;
|
|
9
9
|
};
|
|
@@ -19,15 +19,12 @@ declare class BasePaginatedFragmentStore<_Data extends GraphQLObject, _Input> {
|
|
|
19
19
|
export declare class FragmentStoreCursor<_Data extends GraphQLObject, _Input extends Record<string, any>> extends BasePaginatedFragmentStore<_Data, _Input> {
|
|
20
20
|
get(initialValue: _Data | null): {
|
|
21
21
|
kind: "HoudiniFragment";
|
|
22
|
-
data: Readable<_Data | null>;
|
|
23
22
|
subscribe: (run: Subscriber<FragmentPaginatedResult<_Data, {
|
|
24
23
|
pageInfo: PageInfo;
|
|
25
24
|
}>>, invalidate?: ((value?: FragmentPaginatedResult<_Data, {
|
|
26
25
|
pageInfo: PageInfo;
|
|
27
26
|
}> | undefined) => void) | undefined) => (() => void);
|
|
28
|
-
|
|
29
|
-
fetch: (args?: import("../query").QueryStoreFetchParams<_Data, _Input> | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
|
|
30
|
-
pageInfo: import("svelte/store").Writable<PageInfo>;
|
|
27
|
+
fetch: (args?: import("$houdini/runtime/lib/types").FetchParams<_Input> | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
|
|
31
28
|
loadNextPage: (args?: {
|
|
32
29
|
first?: number | undefined;
|
|
33
30
|
after?: string | undefined;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { getCurrentConfig, keyFieldsForType } from "$houdini/runtime/lib/config";
|
|
2
2
|
import { siteURL } from "$houdini/runtime/lib/constants";
|
|
3
|
+
import { extractPageInfo } from "$houdini/runtime/lib/pageInfo";
|
|
4
|
+
import { cursorHandlers, offsetHandlers } from "$houdini/runtime/lib/pagination";
|
|
3
5
|
import { CompiledFragmentKind } from "$houdini/runtime/lib/types";
|
|
4
6
|
import { derived, get } from "svelte/store";
|
|
5
7
|
import { getClient, initClient } from "../../client";
|
|
6
8
|
import { getSession } from "../../session";
|
|
7
9
|
import { FragmentStore } from "../fragment";
|
|
8
|
-
import { cursorHandlers } from "./cursor";
|
|
9
|
-
import { offsetHandlers } from "./offset";
|
|
10
|
-
import { extractPageInfo } from "./pageInfo";
|
|
11
10
|
class BasePaginatedFragmentStore {
|
|
12
11
|
paginated = true;
|
|
13
12
|
paginationArtifact;
|
|
@@ -70,11 +69,8 @@ class FragmentStoreCursor extends BasePaginatedFragmentStore {
|
|
|
70
69
|
};
|
|
71
70
|
return {
|
|
72
71
|
kind: CompiledFragmentKind,
|
|
73
|
-
data: derived(store, ($value) => $value),
|
|
74
72
|
subscribe,
|
|
75
|
-
fetching: derived([paginationStore], ([$store]) => $store.fetching),
|
|
76
73
|
fetch: handlers.fetch,
|
|
77
|
-
pageInfo: handlers.pageInfo,
|
|
78
74
|
loadNextPage: handlers.loadNextPage,
|
|
79
75
|
loadPreviousPage: handlers.loadPreviousPage
|
|
80
76
|
};
|
|
@@ -113,7 +109,7 @@ class FragmentStoreCursor extends BasePaginatedFragmentStore {
|
|
|
113
109
|
}
|
|
114
110
|
});
|
|
115
111
|
},
|
|
116
|
-
|
|
112
|
+
getSession,
|
|
117
113
|
storeName: this.name
|
|
118
114
|
});
|
|
119
115
|
}
|
|
@@ -162,6 +158,7 @@ class FragmentStoreOffset extends BasePaginatedFragmentStore {
|
|
|
162
158
|
}
|
|
163
159
|
});
|
|
164
160
|
},
|
|
161
|
+
getSession,
|
|
165
162
|
storeName: this.name
|
|
166
163
|
});
|
|
167
164
|
const subscribe = (run, invalidate) => {
|