houdini-svelte 2.1.9 → 2.1.10
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 +4 -4
- package/build/plugin-esm/index.js +4 -4
- package/build/preprocess-cjs/index.js +4 -4
- package/build/preprocess-esm/index.js +4 -4
- package/build/runtime/fragments.d.ts +1 -1
- package/build/runtime/stores/fragment.d.ts +58 -2
- package/build/runtime/stores/index.d.ts +2 -3
- package/build/runtime/stores/query.d.ts +27 -1
- package/build/runtime-cjs/fragments.d.ts +1 -1
- package/build/runtime-cjs/stores/fragment.d.ts +58 -2
- package/build/runtime-cjs/stores/fragment.js +180 -2
- package/build/runtime-cjs/stores/index.d.ts +2 -3
- package/build/runtime-cjs/stores/index.js +8 -2
- package/build/runtime-cjs/stores/query.d.ts +27 -1
- package/build/runtime-cjs/stores/query.js +118 -0
- package/build/runtime-esm/fragments.d.ts +1 -1
- package/build/runtime-esm/stores/fragment.d.ts +58 -2
- package/build/runtime-esm/stores/fragment.js +179 -3
- package/build/runtime-esm/stores/index.d.ts +2 -3
- package/build/runtime-esm/stores/index.js +6 -3
- package/build/runtime-esm/stores/query.d.ts +27 -1
- package/build/runtime-esm/stores/query.js +118 -2
- package/build/test-cjs/index.js +4 -4
- package/build/test-esm/index.js +4 -4
- package/package.json +1 -1
- package/build/runtime/stores/pagination/fragment.d.ts +0 -58
- package/build/runtime/stores/pagination/index.d.ts +0 -2
- package/build/runtime/stores/pagination/query.d.ts +0 -30
- package/build/runtime-cjs/stores/pagination/fragment.d.ts +0 -58
- package/build/runtime-cjs/stores/pagination/fragment.js +0 -207
- package/build/runtime-cjs/stores/pagination/index.d.ts +0 -2
- package/build/runtime-cjs/stores/pagination/index.js +0 -35
- package/build/runtime-cjs/stores/pagination/query.d.ts +0 -30
- package/build/runtime-cjs/stores/pagination/query.js +0 -147
- package/build/runtime-esm/stores/pagination/fragment.d.ts +0 -58
- package/build/runtime-esm/stores/pagination/fragment.js +0 -182
- package/build/runtime-esm/stores/pagination/index.d.ts +0 -2
- package/build/runtime-esm/stores/pagination/index.js +0 -8
- package/build/runtime-esm/stores/pagination/query.d.ts +0 -30
- package/build/runtime-esm/stores/pagination/query.js +0 -122
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { getCurrentConfig, keyFieldsForType } from "$houdini/runtime/lib/config";
|
|
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";
|
|
5
|
-
import { CompiledFragmentKind } from "$houdini/runtime/lib/types";
|
|
6
|
-
import { derived, get } from "svelte/store";
|
|
7
|
-
import { getClient } from "../../client";
|
|
8
|
-
import { getSession } from "../../session";
|
|
9
|
-
import { FragmentStore } from "../fragment";
|
|
10
|
-
class BasePaginatedFragmentStore {
|
|
11
|
-
paginated = true;
|
|
12
|
-
paginationArtifact;
|
|
13
|
-
name;
|
|
14
|
-
kind = CompiledFragmentKind;
|
|
15
|
-
artifact;
|
|
16
|
-
constructor(config) {
|
|
17
|
-
this.paginationArtifact = config.paginationArtifact;
|
|
18
|
-
this.name = config.storeName;
|
|
19
|
-
this.artifact = config.artifact;
|
|
20
|
-
}
|
|
21
|
-
queryVariables(getState) {
|
|
22
|
-
const config = getCurrentConfig();
|
|
23
|
-
const { targetType } = this.paginationArtifact.refetch || {};
|
|
24
|
-
const typeConfig = config.types?.[targetType || ""];
|
|
25
|
-
if (!typeConfig) {
|
|
26
|
-
throw new Error(
|
|
27
|
-
`Missing type refetch configuration for ${targetType}. For more information, see ${siteURL}/guides/pagination#paginated-fragments`
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
let idVariables = {};
|
|
31
|
-
const value = getState();
|
|
32
|
-
if (typeConfig.resolve?.arguments) {
|
|
33
|
-
idVariables = typeConfig.resolve.arguments?.(value) || {};
|
|
34
|
-
} else {
|
|
35
|
-
const keys = keyFieldsForType(config, targetType || "");
|
|
36
|
-
idVariables = Object.fromEntries(keys.map((key) => [key, value[key]]));
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
...idVariables
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
class FragmentStoreCursor extends BasePaginatedFragmentStore {
|
|
44
|
-
get(initialValue) {
|
|
45
|
-
const base = new FragmentStore({
|
|
46
|
-
artifact: this.artifact,
|
|
47
|
-
storeName: this.name
|
|
48
|
-
});
|
|
49
|
-
const store = base.get(initialValue);
|
|
50
|
-
const paginationStore = getClient().observe({
|
|
51
|
-
artifact: this.paginationArtifact,
|
|
52
|
-
initialValue: store.initialValue
|
|
53
|
-
});
|
|
54
|
-
const handlers = this.storeHandlers(
|
|
55
|
-
paginationStore,
|
|
56
|
-
initialValue,
|
|
57
|
-
() => get(store),
|
|
58
|
-
() => store.variables
|
|
59
|
-
);
|
|
60
|
-
const subscribe = (run, invalidate) => {
|
|
61
|
-
const combined = derived([store, paginationStore], ([$parent, $pagination]) => {
|
|
62
|
-
return {
|
|
63
|
-
...$pagination,
|
|
64
|
-
data: $parent,
|
|
65
|
-
pageInfo: extractPageInfo($parent, this.paginationArtifact.refetch.path)
|
|
66
|
-
};
|
|
67
|
-
});
|
|
68
|
-
return combined.subscribe(run, invalidate);
|
|
69
|
-
};
|
|
70
|
-
return {
|
|
71
|
-
kind: CompiledFragmentKind,
|
|
72
|
-
subscribe,
|
|
73
|
-
fetch: handlers.fetch,
|
|
74
|
-
loadNextPage: handlers.loadNextPage,
|
|
75
|
-
loadPreviousPage: handlers.loadPreviousPage
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
storeHandlers(observer, initialValue, getState, getVariables) {
|
|
79
|
-
return cursorHandlers({
|
|
80
|
-
getState,
|
|
81
|
-
getVariables,
|
|
82
|
-
artifact: this.paginationArtifact,
|
|
83
|
-
fetchUpdate: async (args, updates) => {
|
|
84
|
-
return observer.send({
|
|
85
|
-
session: await getSession(),
|
|
86
|
-
...args,
|
|
87
|
-
variables: {
|
|
88
|
-
...args?.variables,
|
|
89
|
-
...this.queryVariables(getState)
|
|
90
|
-
},
|
|
91
|
-
cacheParams: {
|
|
92
|
-
applyUpdates: updates,
|
|
93
|
-
disableSubscriptions: true
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
},
|
|
97
|
-
fetch: async (args) => {
|
|
98
|
-
return await observer.send({
|
|
99
|
-
session: await getSession(),
|
|
100
|
-
...args,
|
|
101
|
-
variables: {
|
|
102
|
-
...args?.variables,
|
|
103
|
-
...this.queryVariables(getState)
|
|
104
|
-
},
|
|
105
|
-
cacheParams: {
|
|
106
|
-
disableSubscriptions: true
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
},
|
|
110
|
-
getSession
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
class FragmentStoreOffset extends BasePaginatedFragmentStore {
|
|
115
|
-
get(initialValue) {
|
|
116
|
-
const base = new FragmentStore({
|
|
117
|
-
artifact: this.artifact,
|
|
118
|
-
storeName: this.name
|
|
119
|
-
});
|
|
120
|
-
const store = base.get(initialValue);
|
|
121
|
-
const paginationStore = getClient().observe({
|
|
122
|
-
artifact: this.paginationArtifact,
|
|
123
|
-
initialValue: store.initialValue
|
|
124
|
-
});
|
|
125
|
-
const getState = () => get(store);
|
|
126
|
-
const handlers = offsetHandlers({
|
|
127
|
-
getState,
|
|
128
|
-
getVariables: () => store.variables,
|
|
129
|
-
artifact: this.paginationArtifact,
|
|
130
|
-
fetch: async (args) => {
|
|
131
|
-
return paginationStore.send({
|
|
132
|
-
...args,
|
|
133
|
-
session: await getSession(),
|
|
134
|
-
variables: {
|
|
135
|
-
...this.queryVariables(getState),
|
|
136
|
-
...args?.variables
|
|
137
|
-
},
|
|
138
|
-
cacheParams: {
|
|
139
|
-
disableSubscriptions: true
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
},
|
|
143
|
-
fetchUpdate: async (args) => {
|
|
144
|
-
return paginationStore.send({
|
|
145
|
-
session: await getSession(),
|
|
146
|
-
...args,
|
|
147
|
-
variables: {
|
|
148
|
-
...this.queryVariables(getState),
|
|
149
|
-
...args?.variables
|
|
150
|
-
},
|
|
151
|
-
cacheParams: {
|
|
152
|
-
disableSubscriptions: true,
|
|
153
|
-
applyUpdates: ["append"]
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
},
|
|
157
|
-
getSession,
|
|
158
|
-
storeName: this.name
|
|
159
|
-
});
|
|
160
|
-
const subscribe = (run, invalidate) => {
|
|
161
|
-
const combined = derived([store, paginationStore], ([$parent, $pagination]) => {
|
|
162
|
-
return {
|
|
163
|
-
...$pagination,
|
|
164
|
-
data: $parent
|
|
165
|
-
};
|
|
166
|
-
});
|
|
167
|
-
return combined.subscribe(run, invalidate);
|
|
168
|
-
};
|
|
169
|
-
return {
|
|
170
|
-
kind: CompiledFragmentKind,
|
|
171
|
-
data: derived(paginationStore, ($value) => $value.data),
|
|
172
|
-
subscribe,
|
|
173
|
-
fetch: handlers.fetch,
|
|
174
|
-
loadNextPage: handlers.loadNextPage,
|
|
175
|
-
fetching: derived(paginationStore, ($store) => $store.fetching)
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
export {
|
|
180
|
-
FragmentStoreCursor,
|
|
181
|
-
FragmentStoreOffset
|
|
182
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/// <reference types="svelte" />
|
|
2
|
-
import type { GraphQLObject, QueryArtifact, QueryResult, CursorHandlers, OffsetHandlers, PageInfo, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
3
|
-
import type { Subscriber } from 'svelte/store';
|
|
4
|
-
import type { ClientFetchParams, LoadEventFetchParams, QueryStoreFetchParams, RequestEventFetchParams } from '../../types';
|
|
5
|
-
import type { StoreConfig } from '../query';
|
|
6
|
-
import { QueryStore } from '../query';
|
|
7
|
-
export type CursorStoreResult<_Data extends GraphQLObject, _Input extends GraphQLVariables> = QueryResult<_Data, _Input> & {
|
|
8
|
-
pageInfo: PageInfo;
|
|
9
|
-
};
|
|
10
|
-
export declare class QueryStoreCursor<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends QueryStore<_Data, _Input> {
|
|
11
|
-
#private;
|
|
12
|
-
paginated: boolean;
|
|
13
|
-
constructor(config: StoreConfig<_Data, _Input, QueryArtifact>);
|
|
14
|
-
fetch(params?: RequestEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
15
|
-
fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
16
|
-
fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
17
|
-
fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
18
|
-
loadPreviousPage(args?: Parameters<Required<CursorHandlers<_Data, _Input>>['loadPreviousPage']>[0]): Promise<QueryResult<_Data, _Input>>;
|
|
19
|
-
loadNextPage(args?: Parameters<CursorHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<QueryResult<_Data, _Input>>;
|
|
20
|
-
subscribe(run: Subscriber<CursorStoreResult<_Data, _Input>>, invalidate?: ((value?: CursorStoreResult<_Data, _Input> | undefined) => void) | undefined): () => void;
|
|
21
|
-
}
|
|
22
|
-
export declare class QueryStoreOffset<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends QueryStore<_Data, _Input> {
|
|
23
|
-
#private;
|
|
24
|
-
paginated: boolean;
|
|
25
|
-
loadNextPage(args?: Parameters<OffsetHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<void>;
|
|
26
|
-
fetch(params?: RequestEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
27
|
-
fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
28
|
-
fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
29
|
-
fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
30
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { extractPageInfo } from "$houdini/runtime/lib/pageInfo";
|
|
2
|
-
import { cursorHandlers, offsetHandlers } from "$houdini/runtime/lib/pagination";
|
|
3
|
-
import { get, derived } from "svelte/store";
|
|
4
|
-
import { getClient } from "../../client";
|
|
5
|
-
import { getSession } from "../../session";
|
|
6
|
-
import { QueryStore } from "../query";
|
|
7
|
-
class QueryStoreCursor extends QueryStore {
|
|
8
|
-
paginated = true;
|
|
9
|
-
constructor(config) {
|
|
10
|
-
super(config);
|
|
11
|
-
}
|
|
12
|
-
#_handlers = null;
|
|
13
|
-
async #handlers() {
|
|
14
|
-
if (this.#_handlers) {
|
|
15
|
-
return this.#_handlers;
|
|
16
|
-
}
|
|
17
|
-
const paginationObserver = getClient().observe({
|
|
18
|
-
artifact: this.artifact
|
|
19
|
-
});
|
|
20
|
-
this.#_handlers = cursorHandlers({
|
|
21
|
-
artifact: this.artifact,
|
|
22
|
-
getState: () => get(this.observer).data,
|
|
23
|
-
getVariables: () => get(this.observer).variables,
|
|
24
|
-
fetch: super.fetch.bind(this),
|
|
25
|
-
getSession,
|
|
26
|
-
fetchUpdate: async (args, updates) => {
|
|
27
|
-
return paginationObserver.send({
|
|
28
|
-
...args,
|
|
29
|
-
cacheParams: {
|
|
30
|
-
applyUpdates: updates,
|
|
31
|
-
disableSubscriptions: true,
|
|
32
|
-
...args?.cacheParams
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
return this.#_handlers;
|
|
38
|
-
}
|
|
39
|
-
async fetch(args) {
|
|
40
|
-
const handlers = await this.#handlers();
|
|
41
|
-
return await handlers.fetch.call(this, args);
|
|
42
|
-
}
|
|
43
|
-
async loadPreviousPage(args) {
|
|
44
|
-
const handlers = await this.#handlers();
|
|
45
|
-
try {
|
|
46
|
-
return await handlers.loadPreviousPage(args);
|
|
47
|
-
} catch (e) {
|
|
48
|
-
const err = e;
|
|
49
|
-
if (err.name === "AbortError") {
|
|
50
|
-
return get(this.observer);
|
|
51
|
-
} else {
|
|
52
|
-
throw err;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
async loadNextPage(args) {
|
|
57
|
-
const handlers = await this.#handlers();
|
|
58
|
-
try {
|
|
59
|
-
return await handlers.loadNextPage(args);
|
|
60
|
-
} catch (e) {
|
|
61
|
-
const err = e;
|
|
62
|
-
if (err.name === "AbortError") {
|
|
63
|
-
return get(this.observer);
|
|
64
|
-
} else {
|
|
65
|
-
throw err;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
subscribe(run, invalidate) {
|
|
70
|
-
const combined = derived([{ subscribe: super.subscribe.bind(this) }], ([$parent]) => {
|
|
71
|
-
return {
|
|
72
|
-
...$parent,
|
|
73
|
-
pageInfo: extractPageInfo($parent.data, this.artifact.refetch.path)
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
return combined.subscribe(run, invalidate);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
class QueryStoreOffset extends QueryStore {
|
|
80
|
-
paginated = true;
|
|
81
|
-
async loadNextPage(args) {
|
|
82
|
-
const handlers = await this.#handlers();
|
|
83
|
-
return await handlers.loadNextPage.call(this, args);
|
|
84
|
-
}
|
|
85
|
-
async fetch(args) {
|
|
86
|
-
const handlers = await this.#handlers();
|
|
87
|
-
return await handlers.fetch.call(this, args);
|
|
88
|
-
}
|
|
89
|
-
#_handlers = null;
|
|
90
|
-
async #handlers() {
|
|
91
|
-
if (this.#_handlers) {
|
|
92
|
-
return this.#_handlers;
|
|
93
|
-
}
|
|
94
|
-
const paginationObserver = getClient().observe({
|
|
95
|
-
artifact: this.artifact
|
|
96
|
-
});
|
|
97
|
-
this.#_handlers = offsetHandlers({
|
|
98
|
-
artifact: this.artifact,
|
|
99
|
-
storeName: this.name,
|
|
100
|
-
fetch: super.fetch.bind(this),
|
|
101
|
-
getState: () => get(this.observer).data,
|
|
102
|
-
getVariables: () => get(this.observer).variables,
|
|
103
|
-
getSession,
|
|
104
|
-
fetchUpdate: async (args) => {
|
|
105
|
-
return paginationObserver.send({
|
|
106
|
-
...args,
|
|
107
|
-
variables: {
|
|
108
|
-
...args?.variables
|
|
109
|
-
},
|
|
110
|
-
cacheParams: {
|
|
111
|
-
applyUpdates: ["append"]
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
return this.#_handlers;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
export {
|
|
120
|
-
QueryStoreCursor,
|
|
121
|
-
QueryStoreOffset
|
|
122
|
-
};
|