houdini-react 1.2.45 → 1.2.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/plugin-cjs/index.js +24 -2
- package/build/plugin-esm/index.js +24 -2
- package/build/runtime/hooks/useDocumentHandle.d.ts +2 -0
- package/build/runtime/routing/Router.d.ts +2 -1
- package/build/runtime-cjs/clientPlugin.js +1 -1
- package/build/runtime-cjs/hooks/useDocumentHandle.d.ts +2 -0
- package/build/runtime-cjs/hooks/useDocumentHandle.js +20 -5
- package/build/runtime-cjs/routing/Router.d.ts +2 -1
- package/build/runtime-cjs/routing/Router.js +15 -7
- package/build/runtime-esm/clientPlugin.js +1 -1
- package/build/runtime-esm/hooks/useDocumentHandle.d.ts +2 -0
- package/build/runtime-esm/hooks/useDocumentHandle.js +21 -6
- package/build/runtime-esm/routing/Router.d.ts +2 -1
- package/build/runtime-esm/routing/Router.js +15 -7
- package/package.json +4 -4
|
@@ -77863,7 +77863,12 @@ function deepMerge2(filepath, ...targets) {
|
|
|
77863
77863
|
}
|
|
77864
77864
|
function parseJS(str, config) {
|
|
77865
77865
|
const defaultConfig = {
|
|
77866
|
-
plugins: [
|
|
77866
|
+
plugins: [
|
|
77867
|
+
"typescript",
|
|
77868
|
+
"importAssertions",
|
|
77869
|
+
"decorators-legacy",
|
|
77870
|
+
"explicitResourceManagement"
|
|
77871
|
+
],
|
|
77867
77872
|
sourceType: "module"
|
|
77868
77873
|
};
|
|
77869
77874
|
return (0, import_parser.parse)(str || "", config ? deepMerge2("", defaultConfig, config) : defaultConfig).program;
|
|
@@ -78809,7 +78814,18 @@ async function extractQueries(source) {
|
|
|
78809
78814
|
} else {
|
|
78810
78815
|
return [];
|
|
78811
78816
|
}
|
|
78812
|
-
return props.
|
|
78817
|
+
return props.reduce((queries, query2) => {
|
|
78818
|
+
if (query2 === "children") {
|
|
78819
|
+
return queries;
|
|
78820
|
+
}
|
|
78821
|
+
if (query2.endsWith("$handle")) {
|
|
78822
|
+
query2 = query2.substring(0, query2.length - "$handle".length);
|
|
78823
|
+
}
|
|
78824
|
+
if (queries.includes(query2)) {
|
|
78825
|
+
return queries;
|
|
78826
|
+
}
|
|
78827
|
+
return queries.concat([query2]);
|
|
78828
|
+
}, []);
|
|
78813
78829
|
}
|
|
78814
78830
|
function isSecondaryBuild() {
|
|
78815
78831
|
return process.env.HOUDINI_SECONDARY_BUILD && process.env.HOUDINI_SECONDARY_BUILD !== "false";
|
|
@@ -79850,6 +79866,12 @@ var vite_default = {
|
|
|
79850
79866
|
initialVariables: variables,
|
|
79851
79867
|
})
|
|
79852
79868
|
|
|
79869
|
+
// initialize the observer we just created
|
|
79870
|
+
observer.send({
|
|
79871
|
+
setup: true,
|
|
79872
|
+
variables,
|
|
79873
|
+
})
|
|
79874
|
+
|
|
79853
79875
|
// save it in the cache
|
|
79854
79876
|
initialData[artifactName] = observer
|
|
79855
79877
|
initialVariables[artifactName] = variables
|
|
@@ -77853,7 +77853,12 @@ function deepMerge2(filepath, ...targets) {
|
|
|
77853
77853
|
}
|
|
77854
77854
|
function parseJS(str, config) {
|
|
77855
77855
|
const defaultConfig = {
|
|
77856
|
-
plugins: [
|
|
77856
|
+
plugins: [
|
|
77857
|
+
"typescript",
|
|
77858
|
+
"importAssertions",
|
|
77859
|
+
"decorators-legacy",
|
|
77860
|
+
"explicitResourceManagement"
|
|
77861
|
+
],
|
|
77857
77862
|
sourceType: "module"
|
|
77858
77863
|
};
|
|
77859
77864
|
return (0, import_parser.parse)(str || "", config ? deepMerge2("", defaultConfig, config) : defaultConfig).program;
|
|
@@ -78799,7 +78804,18 @@ async function extractQueries(source) {
|
|
|
78799
78804
|
} else {
|
|
78800
78805
|
return [];
|
|
78801
78806
|
}
|
|
78802
|
-
return props.
|
|
78807
|
+
return props.reduce((queries, query2) => {
|
|
78808
|
+
if (query2 === "children") {
|
|
78809
|
+
return queries;
|
|
78810
|
+
}
|
|
78811
|
+
if (query2.endsWith("$handle")) {
|
|
78812
|
+
query2 = query2.substring(0, query2.length - "$handle".length);
|
|
78813
|
+
}
|
|
78814
|
+
if (queries.includes(query2)) {
|
|
78815
|
+
return queries;
|
|
78816
|
+
}
|
|
78817
|
+
return queries.concat([query2]);
|
|
78818
|
+
}, []);
|
|
78803
78819
|
}
|
|
78804
78820
|
function isSecondaryBuild() {
|
|
78805
78821
|
return process.env.HOUDINI_SECONDARY_BUILD && process.env.HOUDINI_SECONDARY_BUILD !== "false";
|
|
@@ -79840,6 +79856,12 @@ var vite_default = {
|
|
|
79840
79856
|
initialVariables: variables,
|
|
79841
79857
|
})
|
|
79842
79858
|
|
|
79859
|
+
// initialize the observer we just created
|
|
79860
|
+
observer.send({
|
|
79861
|
+
setup: true,
|
|
79862
|
+
variables,
|
|
79863
|
+
})
|
|
79864
|
+
|
|
79843
79865
|
// save it in the cache
|
|
79844
79866
|
initialData[artifactName] = observer
|
|
79845
79867
|
initialVariables[artifactName] = variables
|
|
@@ -10,6 +10,8 @@ export declare function useDocumentHandle<_Artifact extends QueryArtifact, _Data
|
|
|
10
10
|
export type DocumentHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends GraphQLVariables = GraphQLVariables> = {
|
|
11
11
|
data: _Data;
|
|
12
12
|
partial: boolean;
|
|
13
|
+
fetch: FetchFn<_Data, Partial<_Input>>;
|
|
14
|
+
variables: _Input;
|
|
13
15
|
} & RefetchHandlers<_Artifact, _Data, _Input>;
|
|
14
16
|
type RefetchHandlers<_Artifact extends QueryArtifact, _Data extends GraphQLObject, _Input> = _Artifact extends {
|
|
15
17
|
refetch: {
|
|
@@ -5,6 +5,7 @@ import { GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
|
5
5
|
import { QueryArtifact } from '$houdini/runtime/lib/types';
|
|
6
6
|
import type { RouterManifest } from '$houdini/runtime/router/types';
|
|
7
7
|
import React from 'react';
|
|
8
|
+
import { DocumentHandle } from '../hooks/useDocumentHandle';
|
|
8
9
|
import { SuspenseCache } from './cache';
|
|
9
10
|
type ComponentType = any;
|
|
10
11
|
/**
|
|
@@ -54,7 +55,7 @@ export declare function useCache(): Cache;
|
|
|
54
55
|
export declare function updateLocalSession(session: App.Session): void;
|
|
55
56
|
export declare function useSession(): [App.Session, (newSession: Partial<App.Session>) => void];
|
|
56
57
|
export declare function useCurrentVariables(): GraphQLVariables;
|
|
57
|
-
export declare function useQueryResult<_Data extends GraphQLObject, _Input extends GraphQLVariables>(name: string): [_Data | null,
|
|
58
|
+
export declare function useQueryResult<_Data extends GraphQLObject, _Input extends GraphQLVariables>(name: string): [_Data | null, DocumentHandle<any, _Data, _Input>];
|
|
58
59
|
export type RouterCache = {
|
|
59
60
|
artifact_cache: SuspenseCache<QueryArtifact>;
|
|
60
61
|
component_cache: SuspenseCache<(props: any) => React.ReactElement>;
|
|
@@ -10,6 +10,8 @@ export declare function useDocumentHandle<_Artifact extends QueryArtifact, _Data
|
|
|
10
10
|
export type DocumentHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends GraphQLVariables = GraphQLVariables> = {
|
|
11
11
|
data: _Data;
|
|
12
12
|
partial: boolean;
|
|
13
|
+
fetch: FetchFn<_Data, Partial<_Input>>;
|
|
14
|
+
variables: _Input;
|
|
13
15
|
} & RefetchHandlers<_Artifact, _Data, _Input>;
|
|
14
16
|
type RefetchHandlers<_Artifact extends QueryArtifact, _Data extends GraphQLObject, _Input> = _Artifact extends {
|
|
15
17
|
refetch: {
|
|
@@ -40,6 +40,13 @@ function useDocumentHandle({
|
|
|
40
40
|
const [forwardPending, setForwardPending] = import_react.default.useState(false);
|
|
41
41
|
const [backwardPending, setBackwardPending] = import_react.default.useState(false);
|
|
42
42
|
const [session] = (0, import_Router.useSession)();
|
|
43
|
+
const client = (0, import_Router.useClient)();
|
|
44
|
+
const paginationObserver = import_react.default.useMemo(() => {
|
|
45
|
+
if (!artifact.refetch?.paginated) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return client.observe({ artifact });
|
|
49
|
+
}, [artifact.name]);
|
|
43
50
|
return import_react.default.useMemo(() => {
|
|
44
51
|
const wrapLoad = (setLoading, fn) => {
|
|
45
52
|
return async (value) => {
|
|
@@ -55,7 +62,9 @@ function useDocumentHandle({
|
|
|
55
62
|
});
|
|
56
63
|
if (artifact.kind !== import_types.ArtifactKind.Query || !artifact.refetch?.paginated) {
|
|
57
64
|
return {
|
|
65
|
+
artifact,
|
|
58
66
|
data: storeValue.data,
|
|
67
|
+
variables: storeValue.variables,
|
|
59
68
|
fetch: fetchQuery,
|
|
60
69
|
partial: storeValue.partial
|
|
61
70
|
};
|
|
@@ -67,12 +76,12 @@ function useDocumentHandle({
|
|
|
67
76
|
getVariables: () => storeValue.variables,
|
|
68
77
|
fetch: fetchQuery,
|
|
69
78
|
fetchUpdate: (args, updates) => {
|
|
70
|
-
return
|
|
79
|
+
return paginationObserver.send({
|
|
71
80
|
...args,
|
|
72
81
|
cacheParams: {
|
|
82
|
+
...args?.cacheParams,
|
|
73
83
|
disableSubscriptions: true,
|
|
74
|
-
applyUpdates: updates
|
|
75
|
-
...args?.cacheParams
|
|
84
|
+
applyUpdates: updates
|
|
76
85
|
},
|
|
77
86
|
session
|
|
78
87
|
});
|
|
@@ -80,7 +89,9 @@ function useDocumentHandle({
|
|
|
80
89
|
getSession: async () => session
|
|
81
90
|
});
|
|
82
91
|
return {
|
|
92
|
+
artifact,
|
|
83
93
|
data: storeValue.data,
|
|
94
|
+
variables: storeValue.variables,
|
|
84
95
|
fetch: handlers.fetch,
|
|
85
96
|
partial: storeValue.partial,
|
|
86
97
|
loadNext: wrapLoad(setForwardPending, handlers.loadNextPage),
|
|
@@ -98,7 +109,7 @@ function useDocumentHandle({
|
|
|
98
109
|
storeName: artifact.name,
|
|
99
110
|
fetch: fetchQuery,
|
|
100
111
|
fetchUpdate: async (args, updates = ["append"]) => {
|
|
101
|
-
return
|
|
112
|
+
return paginationObserver.send({
|
|
102
113
|
...args,
|
|
103
114
|
cacheParams: {
|
|
104
115
|
disableSubscriptions: true,
|
|
@@ -110,7 +121,9 @@ function useDocumentHandle({
|
|
|
110
121
|
getSession: async () => session
|
|
111
122
|
});
|
|
112
123
|
return {
|
|
124
|
+
artifact,
|
|
113
125
|
data: storeValue.data,
|
|
126
|
+
variables: storeValue.variables,
|
|
114
127
|
fetch: handlers.fetch,
|
|
115
128
|
partial: storeValue.partial,
|
|
116
129
|
loadNext: wrapLoad(setForwardPending, handlers.loadNextPage),
|
|
@@ -118,12 +131,14 @@ function useDocumentHandle({
|
|
|
118
131
|
};
|
|
119
132
|
}
|
|
120
133
|
return {
|
|
134
|
+
artifact,
|
|
121
135
|
data: storeValue.data,
|
|
136
|
+
variables: storeValue.variables,
|
|
122
137
|
fetch: fetchQuery,
|
|
123
138
|
refetch: fetchQuery,
|
|
124
139
|
partial: storeValue.partial
|
|
125
140
|
};
|
|
126
|
-
}, [artifact, observer, session, storeValue
|
|
141
|
+
}, [artifact, observer, session, storeValue]);
|
|
127
142
|
}
|
|
128
143
|
// Annotate the CommonJS export names for ESM import in node:
|
|
129
144
|
0 && (module.exports = {
|
|
@@ -5,6 +5,7 @@ import { GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
|
5
5
|
import { QueryArtifact } from '$houdini/runtime/lib/types';
|
|
6
6
|
import type { RouterManifest } from '$houdini/runtime/router/types';
|
|
7
7
|
import React from 'react';
|
|
8
|
+
import { DocumentHandle } from '../hooks/useDocumentHandle';
|
|
8
9
|
import { SuspenseCache } from './cache';
|
|
9
10
|
type ComponentType = any;
|
|
10
11
|
/**
|
|
@@ -54,7 +55,7 @@ export declare function useCache(): Cache;
|
|
|
54
55
|
export declare function updateLocalSession(session: App.Session): void;
|
|
55
56
|
export declare function useSession(): [App.Session, (newSession: Partial<App.Session>) => void];
|
|
56
57
|
export declare function useCurrentVariables(): GraphQLVariables;
|
|
57
|
-
export declare function useQueryResult<_Data extends GraphQLObject, _Input extends GraphQLVariables>(name: string): [_Data | null,
|
|
58
|
+
export declare function useQueryResult<_Data extends GraphQLObject, _Input extends GraphQLVariables>(name: string): [_Data | null, DocumentHandle<any, _Data, _Input>];
|
|
58
59
|
export type RouterCache = {
|
|
59
60
|
artifact_cache: SuspenseCache<QueryArtifact>;
|
|
60
61
|
component_cache: SuspenseCache<(props: any) => React.ReactElement>;
|
|
@@ -46,6 +46,7 @@ var import_scalars = require("$houdini/runtime/lib/scalars");
|
|
|
46
46
|
var import_match = require("$houdini/runtime/router/match");
|
|
47
47
|
var import_react = __toESM(require("react"));
|
|
48
48
|
var import_react2 = require("react");
|
|
49
|
+
var import_useDocumentHandle = require("../hooks/useDocumentHandle");
|
|
49
50
|
var import_useDocumentStore = require("../hooks/useDocumentStore");
|
|
50
51
|
var import_cache = require("./cache");
|
|
51
52
|
const PreloadWhich = {
|
|
@@ -62,7 +63,7 @@ function Router({
|
|
|
62
63
|
const [currentURL, setCurrentURL] = import_react.default.useState(() => {
|
|
63
64
|
return initialURL || window.location.pathname;
|
|
64
65
|
});
|
|
65
|
-
const [page, variables] = (0, import_match.find_match)(manifest, currentURL);
|
|
66
|
+
const [page, variables] = (0, import_match.find_match)(import_config.default, manifest, currentURL);
|
|
66
67
|
if (!page) {
|
|
67
68
|
throw new Error("404");
|
|
68
69
|
}
|
|
@@ -96,7 +97,7 @@ function Router({
|
|
|
96
97
|
setCurrentURL(val);
|
|
97
98
|
},
|
|
98
99
|
preload(url, which) {
|
|
99
|
-
const [page2, variables2] = (0, import_match.find_match)(manifest, url);
|
|
100
|
+
const [page2, variables2] = (0, import_match.find_match)(import_config.default, manifest, url);
|
|
100
101
|
if (["both", "component"].includes(which)) {
|
|
101
102
|
loadComponent(page2);
|
|
102
103
|
}
|
|
@@ -141,7 +142,6 @@ function usePageData({
|
|
|
141
142
|
reject = rej;
|
|
142
143
|
observer.send({
|
|
143
144
|
variables,
|
|
144
|
-
cacheParams: { disableSubscriptions: true },
|
|
145
145
|
session
|
|
146
146
|
}).then(async () => {
|
|
147
147
|
data_cache.set(id, observer);
|
|
@@ -181,9 +181,10 @@ function usePageData({
|
|
|
181
181
|
config: import_config.default
|
|
182
182
|
})
|
|
183
183
|
)}
|
|
184
|
+
}).then(() => {
|
|
185
|
+
window.__houdini__nav_caches__?.data_cache.set(artifactName, new_store)
|
|
184
186
|
})
|
|
185
187
|
|
|
186
|
-
window.__houdini__nav_caches__?.data_cache.set(artifactName, new_store)
|
|
187
188
|
}
|
|
188
189
|
|
|
189
190
|
|
|
@@ -392,15 +393,22 @@ const LocationContext = import_react.default.createContext({
|
|
|
392
393
|
params: {}
|
|
393
394
|
});
|
|
394
395
|
function useQueryResult(name) {
|
|
395
|
-
const
|
|
396
|
-
const
|
|
396
|
+
const { data_cache, artifact_cache } = useRouterContext();
|
|
397
|
+
const store_ref = data_cache.get(name);
|
|
398
|
+
const [storeValue, observer] = (0, import_useDocumentStore.useDocumentStore)({
|
|
397
399
|
artifact: store_ref.artifact,
|
|
398
400
|
observer: store_ref
|
|
399
401
|
});
|
|
402
|
+
const { data, errors } = storeValue;
|
|
400
403
|
if (errors && errors.length > 0) {
|
|
401
404
|
throw new Error(JSON.stringify(errors));
|
|
402
405
|
}
|
|
403
|
-
|
|
406
|
+
const handle = (0, import_useDocumentHandle.useDocumentHandle)({
|
|
407
|
+
artifact: artifact_cache.get(name),
|
|
408
|
+
observer,
|
|
409
|
+
storeValue
|
|
410
|
+
});
|
|
411
|
+
return [data, handle];
|
|
404
412
|
}
|
|
405
413
|
function useLinkBehavior({
|
|
406
414
|
goto,
|
|
@@ -10,6 +10,8 @@ export declare function useDocumentHandle<_Artifact extends QueryArtifact, _Data
|
|
|
10
10
|
export type DocumentHandle<_Artifact extends QueryArtifact, _Data extends GraphQLObject = GraphQLObject, _Input extends GraphQLVariables = GraphQLVariables> = {
|
|
11
11
|
data: _Data;
|
|
12
12
|
partial: boolean;
|
|
13
|
+
fetch: FetchFn<_Data, Partial<_Input>>;
|
|
14
|
+
variables: _Input;
|
|
13
15
|
} & RefetchHandlers<_Artifact, _Data, _Input>;
|
|
14
16
|
type RefetchHandlers<_Artifact extends QueryArtifact, _Data extends GraphQLObject, _Input> = _Artifact extends {
|
|
15
17
|
refetch: {
|
|
@@ -2,7 +2,7 @@ import { extractPageInfo } from "$houdini/runtime/lib/pageInfo";
|
|
|
2
2
|
import { cursorHandlers, offsetHandlers } from "$houdini/runtime/lib/pagination";
|
|
3
3
|
import { ArtifactKind } from "$houdini/runtime/lib/types";
|
|
4
4
|
import React from "react";
|
|
5
|
-
import { useSession } from "../routing/Router";
|
|
5
|
+
import { useClient, useSession } from "../routing/Router";
|
|
6
6
|
function useDocumentHandle({
|
|
7
7
|
artifact,
|
|
8
8
|
observer,
|
|
@@ -11,6 +11,13 @@ function useDocumentHandle({
|
|
|
11
11
|
const [forwardPending, setForwardPending] = React.useState(false);
|
|
12
12
|
const [backwardPending, setBackwardPending] = React.useState(false);
|
|
13
13
|
const [session] = useSession();
|
|
14
|
+
const client = useClient();
|
|
15
|
+
const paginationObserver = React.useMemo(() => {
|
|
16
|
+
if (!artifact.refetch?.paginated) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return client.observe({ artifact });
|
|
20
|
+
}, [artifact.name]);
|
|
14
21
|
return React.useMemo(() => {
|
|
15
22
|
const wrapLoad = (setLoading, fn) => {
|
|
16
23
|
return async (value) => {
|
|
@@ -26,7 +33,9 @@ function useDocumentHandle({
|
|
|
26
33
|
});
|
|
27
34
|
if (artifact.kind !== ArtifactKind.Query || !artifact.refetch?.paginated) {
|
|
28
35
|
return {
|
|
36
|
+
artifact,
|
|
29
37
|
data: storeValue.data,
|
|
38
|
+
variables: storeValue.variables,
|
|
30
39
|
fetch: fetchQuery,
|
|
31
40
|
partial: storeValue.partial
|
|
32
41
|
};
|
|
@@ -38,12 +47,12 @@ function useDocumentHandle({
|
|
|
38
47
|
getVariables: () => storeValue.variables,
|
|
39
48
|
fetch: fetchQuery,
|
|
40
49
|
fetchUpdate: (args, updates) => {
|
|
41
|
-
return
|
|
50
|
+
return paginationObserver.send({
|
|
42
51
|
...args,
|
|
43
52
|
cacheParams: {
|
|
53
|
+
...args?.cacheParams,
|
|
44
54
|
disableSubscriptions: true,
|
|
45
|
-
applyUpdates: updates
|
|
46
|
-
...args?.cacheParams
|
|
55
|
+
applyUpdates: updates
|
|
47
56
|
},
|
|
48
57
|
session
|
|
49
58
|
});
|
|
@@ -51,7 +60,9 @@ function useDocumentHandle({
|
|
|
51
60
|
getSession: async () => session
|
|
52
61
|
});
|
|
53
62
|
return {
|
|
63
|
+
artifact,
|
|
54
64
|
data: storeValue.data,
|
|
65
|
+
variables: storeValue.variables,
|
|
55
66
|
fetch: handlers.fetch,
|
|
56
67
|
partial: storeValue.partial,
|
|
57
68
|
loadNext: wrapLoad(setForwardPending, handlers.loadNextPage),
|
|
@@ -69,7 +80,7 @@ function useDocumentHandle({
|
|
|
69
80
|
storeName: artifact.name,
|
|
70
81
|
fetch: fetchQuery,
|
|
71
82
|
fetchUpdate: async (args, updates = ["append"]) => {
|
|
72
|
-
return
|
|
83
|
+
return paginationObserver.send({
|
|
73
84
|
...args,
|
|
74
85
|
cacheParams: {
|
|
75
86
|
disableSubscriptions: true,
|
|
@@ -81,7 +92,9 @@ function useDocumentHandle({
|
|
|
81
92
|
getSession: async () => session
|
|
82
93
|
});
|
|
83
94
|
return {
|
|
95
|
+
artifact,
|
|
84
96
|
data: storeValue.data,
|
|
97
|
+
variables: storeValue.variables,
|
|
85
98
|
fetch: handlers.fetch,
|
|
86
99
|
partial: storeValue.partial,
|
|
87
100
|
loadNext: wrapLoad(setForwardPending, handlers.loadNextPage),
|
|
@@ -89,12 +102,14 @@ function useDocumentHandle({
|
|
|
89
102
|
};
|
|
90
103
|
}
|
|
91
104
|
return {
|
|
105
|
+
artifact,
|
|
92
106
|
data: storeValue.data,
|
|
107
|
+
variables: storeValue.variables,
|
|
93
108
|
fetch: fetchQuery,
|
|
94
109
|
refetch: fetchQuery,
|
|
95
110
|
partial: storeValue.partial
|
|
96
111
|
};
|
|
97
|
-
}, [artifact, observer, session, storeValue
|
|
112
|
+
}, [artifact, observer, session, storeValue]);
|
|
98
113
|
}
|
|
99
114
|
export {
|
|
100
115
|
useDocumentHandle
|
|
@@ -5,6 +5,7 @@ import { GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
|
5
5
|
import { QueryArtifact } from '$houdini/runtime/lib/types';
|
|
6
6
|
import type { RouterManifest } from '$houdini/runtime/router/types';
|
|
7
7
|
import React from 'react';
|
|
8
|
+
import { DocumentHandle } from '../hooks/useDocumentHandle';
|
|
8
9
|
import { SuspenseCache } from './cache';
|
|
9
10
|
type ComponentType = any;
|
|
10
11
|
/**
|
|
@@ -54,7 +55,7 @@ export declare function useCache(): Cache;
|
|
|
54
55
|
export declare function updateLocalSession(session: App.Session): void;
|
|
55
56
|
export declare function useSession(): [App.Session, (newSession: Partial<App.Session>) => void];
|
|
56
57
|
export declare function useCurrentVariables(): GraphQLVariables;
|
|
57
|
-
export declare function useQueryResult<_Data extends GraphQLObject, _Input extends GraphQLVariables>(name: string): [_Data | null,
|
|
58
|
+
export declare function useQueryResult<_Data extends GraphQLObject, _Input extends GraphQLVariables>(name: string): [_Data | null, DocumentHandle<any, _Data, _Input>];
|
|
58
59
|
export type RouterCache = {
|
|
59
60
|
artifact_cache: SuspenseCache<QueryArtifact>;
|
|
60
61
|
component_cache: SuspenseCache<(props: any) => React.ReactElement>;
|
|
@@ -5,6 +5,7 @@ import { marshalSelection, marshalInputs } from "$houdini/runtime/lib/scalars";
|
|
|
5
5
|
import { find_match } from "$houdini/runtime/router/match";
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { useContext } from "react";
|
|
8
|
+
import { useDocumentHandle } from "../hooks/useDocumentHandle";
|
|
8
9
|
import { useDocumentStore } from "../hooks/useDocumentStore";
|
|
9
10
|
import { suspense_cache } from "./cache";
|
|
10
11
|
const PreloadWhich = {
|
|
@@ -21,7 +22,7 @@ function Router({
|
|
|
21
22
|
const [currentURL, setCurrentURL] = React.useState(() => {
|
|
22
23
|
return initialURL || window.location.pathname;
|
|
23
24
|
});
|
|
24
|
-
const [page, variables] = find_match(manifest, currentURL);
|
|
25
|
+
const [page, variables] = find_match(configFile, manifest, currentURL);
|
|
25
26
|
if (!page) {
|
|
26
27
|
throw new Error("404");
|
|
27
28
|
}
|
|
@@ -55,7 +56,7 @@ function Router({
|
|
|
55
56
|
setCurrentURL(val);
|
|
56
57
|
},
|
|
57
58
|
preload(url, which) {
|
|
58
|
-
const [page2, variables2] = find_match(manifest, url);
|
|
59
|
+
const [page2, variables2] = find_match(configFile, manifest, url);
|
|
59
60
|
if (["both", "component"].includes(which)) {
|
|
60
61
|
loadComponent(page2);
|
|
61
62
|
}
|
|
@@ -100,7 +101,6 @@ function usePageData({
|
|
|
100
101
|
reject = rej;
|
|
101
102
|
observer.send({
|
|
102
103
|
variables,
|
|
103
|
-
cacheParams: { disableSubscriptions: true },
|
|
104
104
|
session
|
|
105
105
|
}).then(async () => {
|
|
106
106
|
data_cache.set(id, observer);
|
|
@@ -140,9 +140,10 @@ function usePageData({
|
|
|
140
140
|
config: configFile
|
|
141
141
|
})
|
|
142
142
|
)}
|
|
143
|
+
}).then(() => {
|
|
144
|
+
window.__houdini__nav_caches__?.data_cache.set(artifactName, new_store)
|
|
143
145
|
})
|
|
144
146
|
|
|
145
|
-
window.__houdini__nav_caches__?.data_cache.set(artifactName, new_store)
|
|
146
147
|
}
|
|
147
148
|
|
|
148
149
|
|
|
@@ -351,15 +352,22 @@ const LocationContext = React.createContext({
|
|
|
351
352
|
params: {}
|
|
352
353
|
});
|
|
353
354
|
function useQueryResult(name) {
|
|
354
|
-
const
|
|
355
|
-
const
|
|
355
|
+
const { data_cache, artifact_cache } = useRouterContext();
|
|
356
|
+
const store_ref = data_cache.get(name);
|
|
357
|
+
const [storeValue, observer] = useDocumentStore({
|
|
356
358
|
artifact: store_ref.artifact,
|
|
357
359
|
observer: store_ref
|
|
358
360
|
});
|
|
361
|
+
const { data, errors } = storeValue;
|
|
359
362
|
if (errors && errors.length > 0) {
|
|
360
363
|
throw new Error(JSON.stringify(errors));
|
|
361
364
|
}
|
|
362
|
-
|
|
365
|
+
const handle = useDocumentHandle({
|
|
366
|
+
artifact: artifact_cache.get(name),
|
|
367
|
+
observer,
|
|
368
|
+
storeValue
|
|
369
|
+
});
|
|
370
|
+
return [data, handle];
|
|
363
371
|
}
|
|
364
372
|
function useLinkBehavior({
|
|
365
373
|
goto,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "houdini-react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.46",
|
|
4
4
|
"description": "The React plugin for houdini",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"express": "^4.18.2",
|
|
38
38
|
"graphql": "^15.8.0",
|
|
39
39
|
"graphql-yoga": "^4.0.4",
|
|
40
|
-
"react": "
|
|
41
|
-
"react-dom": "
|
|
40
|
+
"react": "19.0.0-canary-2b036d3f1-20240327",
|
|
41
|
+
"react-dom": "19.0.0-canary-2b036d3f1-20240327",
|
|
42
42
|
"react-streaming-compat": "^0.3.18",
|
|
43
43
|
"recast": "^0.23.1",
|
|
44
44
|
"rollup": "^3.7.4",
|
|
45
45
|
"use-deep-compare-effect": "^1.8.1",
|
|
46
|
-
"houdini": "^1.2.
|
|
46
|
+
"houdini": "^1.2.46"
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
49
|
"build"
|