houdini 2.0.0-next.45 → 2.0.0-next.46
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/cmd/init.js +2 -2
- package/build/package.json +1 -1
- package/build/runtime/cache/index.d.ts +1 -1
- package/build/runtime/cache/storage.d.ts +1 -1
- package/build/runtime/cache/storage.js +1 -0
- package/build/runtime/pagination.d.ts +4 -2
- package/build/runtime/pagination.js +35 -1
- package/package.json +2 -2
package/build/cmd/init.js
CHANGED
|
@@ -472,12 +472,12 @@ async function packageJSON(targetPath, frameworkInfo) {
|
|
|
472
472
|
}
|
|
473
473
|
packageJSON2.devDependencies = {
|
|
474
474
|
...packageJSON2.devDependencies,
|
|
475
|
-
houdini: "^2.0.0-next.
|
|
475
|
+
houdini: "^2.0.0-next.46"
|
|
476
476
|
};
|
|
477
477
|
if (frameworkInfo.framework === "svelte" || frameworkInfo.framework === "kit") {
|
|
478
478
|
packageJSON2.devDependencies = {
|
|
479
479
|
...packageJSON2.devDependencies,
|
|
480
|
-
"houdini-svelte": "^3.0.0-next.
|
|
480
|
+
"houdini-svelte": "^3.0.0-next.38"
|
|
481
481
|
};
|
|
482
482
|
} else {
|
|
483
483
|
throw new Error(`Unmanaged framework: "${JSON.stringify(frameworkInfo)}"`);
|
package/build/package.json
CHANGED
|
@@ -52,7 +52,7 @@ export declare class Cache {
|
|
|
52
52
|
getFieldTime(id: string, field: string): number | null | undefined;
|
|
53
53
|
config(): ConfigFile;
|
|
54
54
|
serialize(): string;
|
|
55
|
-
hydrate(...args: Parameters<InMemoryStorage['hydrate']>):
|
|
55
|
+
hydrate(...args: Parameters<InMemoryStorage['hydrate']>): Layer | undefined;
|
|
56
56
|
clearLayer(layerID: Layer['id']): void;
|
|
57
57
|
reset(): void;
|
|
58
58
|
getEpoch(): number;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import type { SendParams } from './documentStore.js';
|
|
2
2
|
import type { CursorHandlers, FetchFn, GraphQLObject, GraphQLVariables, QueryArtifact, QueryResult, FetchParams } from './types.js';
|
|
3
|
-
export declare function cursorHandlers<_Data extends GraphQLObject, _Input extends GraphQLVariables | null | undefined>({ artifact, fetchUpdate: parentFetchUpdate, fetch: parentFetch, getState, getVariables, getSession, previousCursors, nextCursors, }: {
|
|
3
|
+
export declare function cursorHandlers<_Data extends GraphQLObject, _Input extends GraphQLVariables | null | undefined>({ artifact, fetchUpdate: parentFetchUpdate, fetch: parentFetch, getState, getVariables, getSession, getLoading, previousCursors, nextCursors, }: {
|
|
4
4
|
artifact: QueryArtifact;
|
|
5
5
|
getState: () => _Data | null;
|
|
6
6
|
getVariables: () => NonNullable<_Input>;
|
|
7
7
|
getSession: () => Promise<App.Session>;
|
|
8
8
|
fetch: FetchFn<_Data, _Input>;
|
|
9
9
|
fetchUpdate: (arg: SendParams, updates: string[]) => ReturnType<FetchFn<_Data, _Input>>;
|
|
10
|
+
getLoading?: () => boolean;
|
|
10
11
|
previousCursors?: (string | null)[];
|
|
11
12
|
nextCursors?: (string | null)[];
|
|
12
13
|
}): CursorHandlers<_Data, _Input>;
|
|
13
|
-
export declare function offsetHandlers<_Data extends GraphQLObject, _Input extends GraphQLVariables | null | undefined>({ artifact, storeName: _storeName, getState, getVariables, fetch: parentFetch, fetchUpdate: parentFetchUpdate, getSession, }: {
|
|
14
|
+
export declare function offsetHandlers<_Data extends GraphQLObject, _Input extends GraphQLVariables | null | undefined>({ artifact, storeName: _storeName, getState, getVariables, fetch: parentFetch, fetchUpdate: parentFetchUpdate, getSession, getLoading, }: {
|
|
14
15
|
artifact: QueryArtifact;
|
|
15
16
|
fetch: FetchFn<_Data, _Input>;
|
|
16
17
|
fetchUpdate: (arg: SendParams) => ReturnType<FetchFn<_Data, _Input>>;
|
|
@@ -18,6 +19,7 @@ export declare function offsetHandlers<_Data extends GraphQLObject, _Input exten
|
|
|
18
19
|
getState: () => _Data | null;
|
|
19
20
|
getVariables: () => _Input;
|
|
20
21
|
getSession: () => Promise<App.Session>;
|
|
22
|
+
getLoading?: () => boolean;
|
|
21
23
|
}): {
|
|
22
24
|
loadNextPage: ({ limit, offset, fetch, metadata, }?: {
|
|
23
25
|
limit?: number;
|
|
@@ -9,6 +9,7 @@ function cursorHandlers({
|
|
|
9
9
|
getState,
|
|
10
10
|
getVariables,
|
|
11
11
|
getSession,
|
|
12
|
+
getLoading,
|
|
12
13
|
previousCursors = [],
|
|
13
14
|
nextCursors = []
|
|
14
15
|
}) {
|
|
@@ -58,6 +59,15 @@ function cursorHandlers({
|
|
|
58
59
|
const getPageInfo = () => {
|
|
59
60
|
return extractPageInfo(getState(), artifact.refetch?.path ?? []);
|
|
60
61
|
};
|
|
62
|
+
const loadingNoOp = () => Promise.resolve({
|
|
63
|
+
data: getState(),
|
|
64
|
+
errors: null,
|
|
65
|
+
fetching: false,
|
|
66
|
+
partial: false,
|
|
67
|
+
stale: false,
|
|
68
|
+
source: DataSource.Cache,
|
|
69
|
+
variables: getVariables()
|
|
70
|
+
});
|
|
61
71
|
return {
|
|
62
72
|
loadNextPage: ({
|
|
63
73
|
first,
|
|
@@ -65,6 +75,9 @@ function cursorHandlers({
|
|
|
65
75
|
fetch,
|
|
66
76
|
metadata
|
|
67
77
|
} = {}) => {
|
|
78
|
+
if (getLoading?.()) {
|
|
79
|
+
return loadingNoOp();
|
|
80
|
+
}
|
|
68
81
|
const isSinglePage = artifact.refetch?.mode === "SinglePage";
|
|
69
82
|
const direction = artifact.refetch?.direction;
|
|
70
83
|
if (isSinglePage && direction === "backward") {
|
|
@@ -146,6 +159,9 @@ function cursorHandlers({
|
|
|
146
159
|
fetch,
|
|
147
160
|
metadata
|
|
148
161
|
} = {}) => {
|
|
162
|
+
if (getLoading?.()) {
|
|
163
|
+
return loadingNoOp();
|
|
164
|
+
}
|
|
149
165
|
const isSinglePage = artifact.refetch?.mode === "SinglePage";
|
|
150
166
|
const direction = artifact.refetch?.direction;
|
|
151
167
|
if (isSinglePage && (direction === "forward" || direction === "both") && previousCursors.length > 0) {
|
|
@@ -209,6 +225,9 @@ function cursorHandlers({
|
|
|
209
225
|
},
|
|
210
226
|
async fetch(args) {
|
|
211
227
|
const { variables } = args ?? {};
|
|
228
|
+
if (getLoading?.()) {
|
|
229
|
+
return loadingNoOp();
|
|
230
|
+
}
|
|
212
231
|
if (variables && !deepEquals(getVariables(), variables)) {
|
|
213
232
|
return await parentFetch(args);
|
|
214
233
|
}
|
|
@@ -255,7 +274,8 @@ function offsetHandlers({
|
|
|
255
274
|
getVariables,
|
|
256
275
|
fetch: parentFetch,
|
|
257
276
|
fetchUpdate: parentFetchUpdate,
|
|
258
|
-
getSession
|
|
277
|
+
getSession,
|
|
278
|
+
getLoading
|
|
259
279
|
}) {
|
|
260
280
|
const isSinglePage = artifact.refetch?.mode === "SinglePage";
|
|
261
281
|
const getOffset = () => {
|
|
@@ -273,6 +293,9 @@ function offsetHandlers({
|
|
|
273
293
|
fetch,
|
|
274
294
|
metadata
|
|
275
295
|
} = {}) => {
|
|
296
|
+
if (getLoading?.()) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
276
299
|
const queryVariables = {
|
|
277
300
|
...getVariables(),
|
|
278
301
|
offset: offset ?? getOffset()
|
|
@@ -296,6 +319,17 @@ function offsetHandlers({
|
|
|
296
319
|
},
|
|
297
320
|
async fetch(params = {}) {
|
|
298
321
|
const { variables } = params;
|
|
322
|
+
if (getLoading?.()) {
|
|
323
|
+
return {
|
|
324
|
+
data: getState(),
|
|
325
|
+
errors: null,
|
|
326
|
+
fetching: false,
|
|
327
|
+
partial: false,
|
|
328
|
+
stale: false,
|
|
329
|
+
source: DataSource.Cache,
|
|
330
|
+
variables: getVariables() ?? null
|
|
331
|
+
};
|
|
332
|
+
}
|
|
299
333
|
if (variables && !deepEquals(getVariables(), variables)) {
|
|
300
334
|
return parentFetch.call(this, params);
|
|
301
335
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "houdini",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.46",
|
|
4
4
|
"description": "The disappearing GraphQL clients",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"recast": "^0.23.11",
|
|
51
51
|
"sql.js": "^1.14.1",
|
|
52
52
|
"ws": "^8.21.0",
|
|
53
|
-
"houdini-core": "^2.0.0-next.
|
|
53
|
+
"houdini-core": "^2.0.0-next.32"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"graphql": ">=16",
|