houdini-react 0.0.0-20240311072355 → 0.0.0-20240328033619
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 +9 -1
- package/build/plugin-esm/index.js +9 -1
- package/build/runtime/hooks/useDocumentHandle.d.ts +1 -0
- package/build/runtime/routing/Router.d.ts +2 -1
- package/build/runtime-cjs/hooks/useDocumentHandle.d.ts +1 -0
- package/build/runtime-cjs/routing/Router.d.ts +2 -1
- package/build/runtime-cjs/routing/Router.js +12 -3
- package/build/runtime-esm/hooks/useDocumentHandle.d.ts +1 -0
- package/build/runtime-esm/routing/Router.d.ts +2 -1
- package/build/runtime-esm/routing/Router.js +12 -3
- package/package.json +4 -4
|
@@ -78809,7 +78809,15 @@ async function extractQueries(source) {
|
|
|
78809
78809
|
} else {
|
|
78810
78810
|
return [];
|
|
78811
78811
|
}
|
|
78812
|
-
return props.
|
|
78812
|
+
return props.reduce((queries, query2) => {
|
|
78813
|
+
if (query2 === "children") {
|
|
78814
|
+
return queries;
|
|
78815
|
+
}
|
|
78816
|
+
if (query2.endsWith("$handle")) {
|
|
78817
|
+
query2 = query2.substring(0, query2.length - "$handle".length);
|
|
78818
|
+
}
|
|
78819
|
+
return queries.concat([query2]);
|
|
78820
|
+
}, []);
|
|
78813
78821
|
}
|
|
78814
78822
|
function isSecondaryBuild() {
|
|
78815
78823
|
return process.env.HOUDINI_SECONDARY_BUILD && process.env.HOUDINI_SECONDARY_BUILD !== "false";
|
|
@@ -78799,7 +78799,15 @@ async function extractQueries(source) {
|
|
|
78799
78799
|
} else {
|
|
78800
78800
|
return [];
|
|
78801
78801
|
}
|
|
78802
|
-
return props.
|
|
78802
|
+
return props.reduce((queries, query2) => {
|
|
78803
|
+
if (query2 === "children") {
|
|
78804
|
+
return queries;
|
|
78805
|
+
}
|
|
78806
|
+
if (query2.endsWith("$handle")) {
|
|
78807
|
+
query2 = query2.substring(0, query2.length - "$handle".length);
|
|
78808
|
+
}
|
|
78809
|
+
return queries.concat([query2]);
|
|
78810
|
+
}, []);
|
|
78803
78811
|
}
|
|
78804
78812
|
function isSecondaryBuild() {
|
|
78805
78813
|
return process.env.HOUDINI_SECONDARY_BUILD && process.env.HOUDINI_SECONDARY_BUILD !== "false";
|
|
@@ -10,6 +10,7 @@ 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, _Input>;
|
|
13
14
|
} & RefetchHandlers<_Artifact, _Data, _Input>;
|
|
14
15
|
type RefetchHandlers<_Artifact extends QueryArtifact, _Data extends GraphQLObject, _Input> = _Artifact extends {
|
|
15
16
|
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,7 @@ 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, _Input>;
|
|
13
14
|
} & RefetchHandlers<_Artifact, _Data, _Input>;
|
|
14
15
|
type RefetchHandlers<_Artifact extends QueryArtifact, _Data extends GraphQLObject, _Input> = _Artifact extends {
|
|
15
16
|
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>;
|
|
@@ -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 = {
|
|
@@ -392,15 +393,23 @@ 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 artifact = artifact_cache.get(name);
|
|
407
|
+
const handle = (0, import_useDocumentHandle.useDocumentHandle)({
|
|
408
|
+
artifact,
|
|
409
|
+
observer,
|
|
410
|
+
storeValue
|
|
411
|
+
});
|
|
412
|
+
return [data, handle];
|
|
404
413
|
}
|
|
405
414
|
function useLinkBehavior({
|
|
406
415
|
goto,
|
|
@@ -10,6 +10,7 @@ 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, _Input>;
|
|
13
14
|
} & RefetchHandlers<_Artifact, _Data, _Input>;
|
|
14
15
|
type RefetchHandlers<_Artifact extends QueryArtifact, _Data extends GraphQLObject, _Input> = _Artifact extends {
|
|
15
16
|
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>;
|
|
@@ -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 = {
|
|
@@ -351,15 +352,23 @@ 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 artifact = artifact_cache.get(name);
|
|
366
|
+
const handle = useDocumentHandle({
|
|
367
|
+
artifact,
|
|
368
|
+
observer,
|
|
369
|
+
storeValue
|
|
370
|
+
});
|
|
371
|
+
return [data, handle];
|
|
363
372
|
}
|
|
364
373
|
function useLinkBehavior({
|
|
365
374
|
goto,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "houdini-react",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-20240328033619",
|
|
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": "^0.0.0-
|
|
46
|
+
"houdini": "^0.0.0-20240328033619"
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
49
|
"build"
|