houdini-react 1.3.7 → 2.0.0-next.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/index.d.ts +1 -3
- package/build/plugin/state.d.ts +3 -0
- package/build/plugin/vite.d.ts +1 -44
- package/build/plugin-cjs/index.js +34065 -28140
- package/build/plugin-esm/index.js +32507 -26576
- package/build/runtime/hooks/index.d.ts +1 -1
- package/build/runtime/hooks/useMutation.d.ts +3 -0
- package/build/runtime/routing/Router.d.ts +6 -32
- package/build/runtime/routing/hooks.d.ts +40 -0
- package/build/runtime/routing/index.d.ts +1 -0
- package/build/runtime-cjs/client.js +0 -2
- package/build/runtime-cjs/clientPlugin.js +0 -2
- package/build/runtime-cjs/hooks/index.d.ts +1 -1
- package/build/runtime-cjs/hooks/index.js +2 -2
- package/build/runtime-cjs/hooks/useDeepCompareEffect.js +4 -0
- package/build/runtime-cjs/hooks/useDocumentHandle.js +8 -4
- package/build/runtime-cjs/hooks/useDocumentStore.js +6 -2
- package/build/runtime-cjs/hooks/useDocumentSubscription.js +7 -2
- package/build/runtime-cjs/hooks/useFragment.js +5 -0
- package/build/runtime-cjs/hooks/useMutation.d.ts +3 -0
- package/build/runtime-cjs/hooks/useMutation.js +26 -11
- package/build/runtime-cjs/hooks/useQueryHandle.js +6 -0
- package/build/runtime-cjs/index.js +10 -5
- package/build/runtime-cjs/manifest.js +0 -2
- package/build/runtime-cjs/routing/Router.d.ts +6 -32
- package/build/runtime-cjs/routing/Router.js +22 -65
- package/build/runtime-cjs/routing/cache.js +3 -0
- package/build/runtime-cjs/routing/hooks.d.ts +40 -0
- package/build/runtime-cjs/routing/hooks.js +93 -0
- package/build/runtime-cjs/routing/index.d.ts +1 -0
- package/build/runtime-cjs/routing/index.js +4 -1
- package/build/runtime-esm/hooks/index.d.ts +1 -1
- package/build/runtime-esm/hooks/index.js +2 -3
- package/build/runtime-esm/hooks/useDocumentHandle.js +1 -1
- package/build/runtime-esm/hooks/useDocumentStore.js +1 -1
- package/build/runtime-esm/hooks/useDocumentSubscription.js +2 -1
- package/build/runtime-esm/hooks/useFragment.js +1 -0
- package/build/runtime-esm/hooks/useMutation.d.ts +3 -0
- package/build/runtime-esm/hooks/useMutation.js +24 -10
- package/build/runtime-esm/hooks/useQueryHandle.js +2 -0
- package/build/runtime-esm/routing/Router.d.ts +6 -32
- package/build/runtime-esm/routing/Router.js +10 -52
- package/build/runtime-esm/routing/cache.js +3 -0
- package/build/runtime-esm/routing/hooks.d.ts +40 -0
- package/build/runtime-esm/routing/hooks.js +53 -0
- package/build/runtime-esm/routing/index.d.ts +1 -0
- package/build/runtime-esm/routing/index.js +1 -0
- package/build/server-cjs/index.js +3 -3
- package/package.json +4 -4
|
@@ -2,7 +2,7 @@ export { useQuery } from './useQuery';
|
|
|
2
2
|
export { useQueryHandle } from './useQueryHandle';
|
|
3
3
|
export { useFragment } from './useFragment';
|
|
4
4
|
export { useFragmentHandle } from './useFragmentHandle';
|
|
5
|
-
export { useMutation } from './useMutation';
|
|
5
|
+
export { useMutation, RuntimeGraphQLError } from './useMutation';
|
|
6
6
|
export { useSubscription } from './useSubscription';
|
|
7
7
|
export { type DocumentHandle } from './useDocumentHandle';
|
|
8
8
|
export { type UseQueryConfig } from './useQueryHandle';
|
|
@@ -9,3 +9,6 @@ export type MutationHandler<_Result, _Input, _Optimistic extends GraphQLObject>
|
|
|
9
9
|
export declare function useMutation<_Result extends GraphQLObject, _Input extends GraphQLVariables, _Optimistic extends GraphQLObject>({ artifact, }: {
|
|
10
10
|
artifact: MutationArtifact;
|
|
11
11
|
}): [boolean, MutationHandler<_Result, _Input, _Optimistic>];
|
|
12
|
+
export declare class RuntimeGraphQLError extends Error {
|
|
13
|
+
raw: QueryResult['errors'];
|
|
14
|
+
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import type { Cache } from '$houdini/runtime/cache/cache';
|
|
2
2
|
import { DocumentStore, HoudiniClient } from '$houdini/runtime/client';
|
|
3
|
-
import { LRUCache } from '$houdini/runtime/lib/lru';
|
|
4
|
-
import { GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
5
|
-
import { QueryArtifact } from '$houdini/runtime/lib/types';
|
|
3
|
+
import type { LRUCache } from '$houdini/runtime/lib/lru';
|
|
4
|
+
import type { GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
5
|
+
import type { QueryArtifact } from '$houdini/runtime/lib/types';
|
|
6
6
|
import type { RouterManifest } from '$houdini/runtime/router/types';
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
type PageComponent
|
|
11
|
-
url: string;
|
|
12
|
-
}>;
|
|
8
|
+
import { type SuspenseCache } from './cache';
|
|
9
|
+
import { type DocumentHandle } from '../hooks/useDocumentHandle';
|
|
10
|
+
import { type PageComponent, type PendingCache } from './hooks';
|
|
13
11
|
type ComponentType = any;
|
|
14
12
|
/**
|
|
15
13
|
* Router is the top level entry point for the filesystem-based router.
|
|
@@ -22,11 +20,6 @@ export declare function Router({ manifest, initialURL, assetPrefix, injectToStre
|
|
|
22
20
|
assetPrefix: string;
|
|
23
21
|
injectToStream?: undefined | ((chunk: string) => void);
|
|
24
22
|
}): React.JSX.Element;
|
|
25
|
-
export declare const useLocation: () => {
|
|
26
|
-
pathname: string;
|
|
27
|
-
params: Record<string, any>;
|
|
28
|
-
goto: (url: string) => void;
|
|
29
|
-
};
|
|
30
23
|
export declare function RouterContextProvider({ children, client, cache, artifact_cache, component_cache, data_cache, ssr_signals, last_variables, session: ssrSession, }: {
|
|
31
24
|
children: React.ReactNode;
|
|
32
25
|
client: HoudiniClient;
|
|
@@ -38,26 +31,7 @@ export declare function RouterContextProvider({ children, client, cache, artifac
|
|
|
38
31
|
last_variables: LRUCache<GraphQLVariables>;
|
|
39
32
|
session?: App.Session;
|
|
40
33
|
}): React.JSX.Element;
|
|
41
|
-
type RouterContext = {
|
|
42
|
-
client: HoudiniClient;
|
|
43
|
-
cache: Cache;
|
|
44
|
-
artifact_cache: SuspenseCache<QueryArtifact>;
|
|
45
|
-
component_cache: SuspenseCache<PageComponent>;
|
|
46
|
-
data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
47
|
-
ssr_signals: PendingCache;
|
|
48
|
-
last_variables: LRUCache<GraphQLVariables>;
|
|
49
|
-
session: App.Session;
|
|
50
|
-
setSession: (newSession: Partial<App.Session>) => void;
|
|
51
|
-
};
|
|
52
|
-
export type PendingCache = SuspenseCache<Promise<void> & {
|
|
53
|
-
resolve: () => void;
|
|
54
|
-
reject: (message: string) => void;
|
|
55
|
-
}>;
|
|
56
|
-
export declare const useRouterContext: () => RouterContext;
|
|
57
|
-
export declare function useClient(): HoudiniClient;
|
|
58
|
-
export declare function useCache(): Cache;
|
|
59
34
|
export declare function updateLocalSession(session: App.Session): void;
|
|
60
|
-
export declare function useSession(): [App.Session, (newSession: Partial<App.Session>) => void];
|
|
61
35
|
export declare function useCurrentVariables(): GraphQLVariables;
|
|
62
36
|
export declare function useQueryResult<_Data extends GraphQLObject, _Input extends GraphQLVariables>(name: string): [_Data | null, DocumentHandle<any, _Data, _Input>];
|
|
63
37
|
export type RouterCache = {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Cache } from '$houdini/runtime/cache/cache';
|
|
2
|
+
import type { DocumentStore, HoudiniClient } from '$houdini/runtime/client';
|
|
3
|
+
import type { LRUCache } from '$houdini/runtime/lib/lru';
|
|
4
|
+
import type { GraphQLObject, GraphQLVariables, QueryArtifact } from '$houdini/runtime/lib/types';
|
|
5
|
+
import { default as React } from 'react';
|
|
6
|
+
import type { SuspenseCache } from './cache';
|
|
7
|
+
export type PageComponent = React.ComponentType<{
|
|
8
|
+
url: string;
|
|
9
|
+
}>;
|
|
10
|
+
export type PendingCache = SuspenseCache<Promise<void> & {
|
|
11
|
+
resolve: () => void;
|
|
12
|
+
reject: (message: string) => void;
|
|
13
|
+
}>;
|
|
14
|
+
type RouterContext = {
|
|
15
|
+
client: HoudiniClient;
|
|
16
|
+
cache: Cache;
|
|
17
|
+
artifact_cache: SuspenseCache<QueryArtifact>;
|
|
18
|
+
component_cache: SuspenseCache<PageComponent>;
|
|
19
|
+
data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
20
|
+
ssr_signals: PendingCache;
|
|
21
|
+
last_variables: LRUCache<GraphQLVariables>;
|
|
22
|
+
session: App.Session;
|
|
23
|
+
setSession: (newSession: Partial<App.Session>) => void;
|
|
24
|
+
};
|
|
25
|
+
export declare const Context: React.Context<RouterContext | null>;
|
|
26
|
+
export declare const LocationContext: React.Context<{
|
|
27
|
+
pathname: string;
|
|
28
|
+
params: Record<string, any>;
|
|
29
|
+
goto: (url: string) => void;
|
|
30
|
+
}>;
|
|
31
|
+
export declare const useLocation: () => {
|
|
32
|
+
pathname: string;
|
|
33
|
+
params: Record<string, any>;
|
|
34
|
+
goto: (url: string) => void;
|
|
35
|
+
};
|
|
36
|
+
export declare const useRouterContext: () => RouterContext;
|
|
37
|
+
export declare function useClient(): HoudiniClient;
|
|
38
|
+
export declare function useCache(): Cache;
|
|
39
|
+
export declare function useSession(): [App.Session, (newSession: Partial<App.Session>) => void];
|
|
40
|
+
export {};
|
|
@@ -2,7 +2,7 @@ export { useQuery } from './useQuery';
|
|
|
2
2
|
export { useQueryHandle } from './useQueryHandle';
|
|
3
3
|
export { useFragment } from './useFragment';
|
|
4
4
|
export { useFragmentHandle } from './useFragmentHandle';
|
|
5
|
-
export { useMutation } from './useMutation';
|
|
5
|
+
export { useMutation, RuntimeGraphQLError } from './useMutation';
|
|
6
6
|
export { useSubscription } from './useSubscription';
|
|
7
7
|
export { type DocumentHandle } from './useDocumentHandle';
|
|
8
8
|
export { type UseQueryConfig } from './useQueryHandle';
|
|
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var hooks_exports = {};
|
|
20
20
|
__export(hooks_exports, {
|
|
21
|
+
RuntimeGraphQLError: () => import_useMutation.RuntimeGraphQLError,
|
|
21
22
|
useFragment: () => import_useFragment.useFragment,
|
|
22
23
|
useFragmentHandle: () => import_useFragmentHandle.useFragmentHandle,
|
|
23
24
|
useMutation: () => import_useMutation.useMutation,
|
|
@@ -32,10 +33,9 @@ var import_useFragment = require("./useFragment");
|
|
|
32
33
|
var import_useFragmentHandle = require("./useFragmentHandle");
|
|
33
34
|
var import_useMutation = require("./useMutation");
|
|
34
35
|
var import_useSubscription = require("./useSubscription");
|
|
35
|
-
var import_useDocumentHandle = require("./useDocumentHandle");
|
|
36
|
-
var import_useQueryHandle2 = require("./useQueryHandle");
|
|
37
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38
37
|
0 && (module.exports = {
|
|
38
|
+
RuntimeGraphQLError,
|
|
39
39
|
useFragment,
|
|
40
40
|
useFragmentHandle,
|
|
41
41
|
useMutation,
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -31,7 +35,7 @@ var import_pageInfo = require("$houdini/runtime/lib/pageInfo");
|
|
|
31
35
|
var import_pagination = require("$houdini/runtime/lib/pagination");
|
|
32
36
|
var import_types = require("$houdini/runtime/lib/types");
|
|
33
37
|
var import_react = __toESM(require("react"));
|
|
34
|
-
var
|
|
38
|
+
var import_hooks = require("../routing/hooks");
|
|
35
39
|
function useDocumentHandle({
|
|
36
40
|
artifact,
|
|
37
41
|
observer,
|
|
@@ -39,9 +43,9 @@ function useDocumentHandle({
|
|
|
39
43
|
}) {
|
|
40
44
|
const [forwardPending, setForwardPending] = import_react.default.useState(false);
|
|
41
45
|
const [backwardPending, setBackwardPending] = import_react.default.useState(false);
|
|
42
|
-
const location = (0,
|
|
43
|
-
const [session] = (0,
|
|
44
|
-
const client = (0,
|
|
46
|
+
const location = (0, import_hooks.useLocation)();
|
|
47
|
+
const [session] = (0, import_hooks.useSession)();
|
|
48
|
+
const client = (0, import_hooks.useClient)();
|
|
45
49
|
const paginationObserver = import_react.default.useMemo(() => {
|
|
46
50
|
if (!artifact.refetch?.paginated) {
|
|
47
51
|
return null;
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -28,14 +32,14 @@ __export(useDocumentStore_exports, {
|
|
|
28
32
|
});
|
|
29
33
|
module.exports = __toCommonJS(useDocumentStore_exports);
|
|
30
34
|
var React = __toESM(require("react"));
|
|
31
|
-
var
|
|
35
|
+
var import_hooks = require("../routing/hooks");
|
|
32
36
|
var import_useIsMounted = require("./useIsMounted");
|
|
33
37
|
function useDocumentStore({
|
|
34
38
|
artifact,
|
|
35
39
|
observer: obs,
|
|
36
40
|
...observeParams
|
|
37
41
|
}) {
|
|
38
|
-
const client = (0,
|
|
42
|
+
const client = (0, import_hooks.useClient)();
|
|
39
43
|
const isMountedRef = (0, import_useIsMounted.useIsMountedRef)();
|
|
40
44
|
let [observer, setObserver] = React.useState(
|
|
41
45
|
() => obs ?? client.observe({
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -27,7 +31,7 @@ __export(useDocumentSubscription_exports, {
|
|
|
27
31
|
useDocumentSubscription: () => useDocumentSubscription
|
|
28
32
|
});
|
|
29
33
|
module.exports = __toCommonJS(useDocumentSubscription_exports);
|
|
30
|
-
var
|
|
34
|
+
var import_hooks = require("../routing/hooks");
|
|
31
35
|
var import_useDeepCompareEffect = __toESM(require("./useDeepCompareEffect"));
|
|
32
36
|
var import_useDocumentStore = require("./useDocumentStore");
|
|
33
37
|
function useDocumentSubscription({
|
|
@@ -41,12 +45,13 @@ function useDocumentSubscription({
|
|
|
41
45
|
artifact,
|
|
42
46
|
...observeParams
|
|
43
47
|
});
|
|
44
|
-
const [session] = (0,
|
|
48
|
+
const [session] = (0, import_hooks.useSession)();
|
|
45
49
|
(0, import_useDeepCompareEffect.default)(() => {
|
|
46
50
|
if (!disabled) {
|
|
47
51
|
observer.send({
|
|
48
52
|
variables,
|
|
49
53
|
session,
|
|
54
|
+
// TODO: metadata
|
|
50
55
|
metadata: {},
|
|
51
56
|
...send
|
|
52
57
|
});
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -53,6 +57,7 @@ function useFragment(reference, document) {
|
|
|
53
57
|
artifact: document.artifact,
|
|
54
58
|
variables,
|
|
55
59
|
initialValue: cachedValue,
|
|
60
|
+
// dont subscribe to anything if we are loading
|
|
56
61
|
disabled: loading,
|
|
57
62
|
send: {
|
|
58
63
|
stuff: {
|
|
@@ -9,3 +9,6 @@ export type MutationHandler<_Result, _Input, _Optimistic extends GraphQLObject>
|
|
|
9
9
|
export declare function useMutation<_Result extends GraphQLObject, _Input extends GraphQLVariables, _Optimistic extends GraphQLObject>({ artifact, }: {
|
|
10
10
|
artifact: MutationArtifact;
|
|
11
11
|
}): [boolean, MutationHandler<_Result, _Input, _Optimistic>];
|
|
12
|
+
export declare class RuntimeGraphQLError extends Error {
|
|
13
|
+
raw: QueryResult['errors'];
|
|
14
|
+
}
|
|
@@ -18,35 +18,50 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var useMutation_exports = {};
|
|
20
20
|
__export(useMutation_exports, {
|
|
21
|
+
RuntimeGraphQLError: () => RuntimeGraphQLError,
|
|
21
22
|
useMutation: () => useMutation
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(useMutation_exports);
|
|
24
|
-
var
|
|
25
|
+
var import_hooks = require("../routing/hooks");
|
|
25
26
|
var import_useDocumentStore = require("./useDocumentStore");
|
|
26
27
|
function useMutation({
|
|
27
28
|
artifact
|
|
28
29
|
}) {
|
|
29
30
|
const [storeValue, observer] = (0, import_useDocumentStore.useDocumentStore)({ artifact });
|
|
30
31
|
const pending = storeValue.fetching;
|
|
31
|
-
const [session] = (0,
|
|
32
|
-
const mutate = ({
|
|
32
|
+
const [session] = (0, import_hooks.useSession)();
|
|
33
|
+
const mutate = async ({
|
|
33
34
|
metadata,
|
|
34
35
|
fetch,
|
|
35
36
|
variables,
|
|
36
37
|
abortController,
|
|
37
38
|
...mutationConfig
|
|
38
|
-
}) =>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
}) => {
|
|
40
|
+
const result = await observer.send({
|
|
41
|
+
variables,
|
|
42
|
+
metadata,
|
|
43
|
+
session,
|
|
44
|
+
abortController,
|
|
45
|
+
stuff: {
|
|
46
|
+
...mutationConfig
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
if (result.errors && result.errors?.length > 0) {
|
|
50
|
+
const err = new RuntimeGraphQLError(
|
|
51
|
+
result.errors.map((error) => error.message).join(". ")
|
|
52
|
+
);
|
|
53
|
+
err.raw = result.errors;
|
|
54
|
+
throw err;
|
|
45
55
|
}
|
|
46
|
-
|
|
56
|
+
return result;
|
|
57
|
+
};
|
|
47
58
|
return [pending, mutate];
|
|
48
59
|
}
|
|
60
|
+
class RuntimeGraphQLError extends Error {
|
|
61
|
+
raw = [];
|
|
62
|
+
}
|
|
49
63
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50
64
|
0 && (module.exports = {
|
|
65
|
+
RuntimeGraphQLError,
|
|
51
66
|
useMutation
|
|
52
67
|
});
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -81,11 +85,13 @@ function useQueryHandle({ artifact }, variables = null, config = {}) {
|
|
|
81
85
|
const suspenseUnit = {
|
|
82
86
|
then: loadPromise.then.bind(loadPromise),
|
|
83
87
|
resolve,
|
|
88
|
+
// @ts-ignore
|
|
84
89
|
variables
|
|
85
90
|
};
|
|
86
91
|
promiseCache.set(identifier, suspenseUnit);
|
|
87
92
|
handle.fetch({
|
|
88
93
|
variables,
|
|
94
|
+
// @ts-ignore: this is actually allowed... 🤫
|
|
89
95
|
stuff: {
|
|
90
96
|
silenceLoading: true
|
|
91
97
|
}
|
|
@@ -19,24 +19,28 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
};
|
|
20
20
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
21
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
26
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
27
|
mod
|
|
24
28
|
));
|
|
25
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
|
-
var
|
|
27
|
-
__export(
|
|
30
|
+
var index_exports = {};
|
|
31
|
+
__export(index_exports, {
|
|
28
32
|
Router: () => Router,
|
|
29
33
|
router_cache: () => import_routing2.router_cache,
|
|
30
34
|
useLocation: () => import_routing2.useLocation,
|
|
31
35
|
useRoute: () => import_routing2.useRoute,
|
|
32
36
|
useSession: () => import_routing2.useSession
|
|
33
37
|
});
|
|
34
|
-
module.exports = __toCommonJS(
|
|
38
|
+
module.exports = __toCommonJS(index_exports);
|
|
35
39
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
40
|
var import_client = __toESM(require("./client"));
|
|
37
41
|
var import_manifest = __toESM(require("./manifest"));
|
|
38
42
|
var import_routing = require("./routing");
|
|
39
|
-
__reExport(
|
|
43
|
+
__reExport(index_exports, require("./hooks"), module.exports);
|
|
40
44
|
var import_routing2 = require("./routing");
|
|
41
45
|
function Router({
|
|
42
46
|
cache,
|
|
@@ -79,5 +83,6 @@ function Router({
|
|
|
79
83
|
router_cache,
|
|
80
84
|
useLocation,
|
|
81
85
|
useRoute,
|
|
82
|
-
useSession
|
|
86
|
+
useSession,
|
|
87
|
+
...require("./hooks")
|
|
83
88
|
});
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import type { Cache } from '$houdini/runtime/cache/cache';
|
|
2
2
|
import { DocumentStore, HoudiniClient } from '$houdini/runtime/client';
|
|
3
|
-
import { LRUCache } from '$houdini/runtime/lib/lru';
|
|
4
|
-
import { GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
5
|
-
import { QueryArtifact } from '$houdini/runtime/lib/types';
|
|
3
|
+
import type { LRUCache } from '$houdini/runtime/lib/lru';
|
|
4
|
+
import type { GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
5
|
+
import type { QueryArtifact } from '$houdini/runtime/lib/types';
|
|
6
6
|
import type { RouterManifest } from '$houdini/runtime/router/types';
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
type PageComponent
|
|
11
|
-
url: string;
|
|
12
|
-
}>;
|
|
8
|
+
import { type SuspenseCache } from './cache';
|
|
9
|
+
import { type DocumentHandle } from '../hooks/useDocumentHandle';
|
|
10
|
+
import { type PageComponent, type PendingCache } from './hooks';
|
|
13
11
|
type ComponentType = any;
|
|
14
12
|
/**
|
|
15
13
|
* Router is the top level entry point for the filesystem-based router.
|
|
@@ -22,11 +20,6 @@ export declare function Router({ manifest, initialURL, assetPrefix, injectToStre
|
|
|
22
20
|
assetPrefix: string;
|
|
23
21
|
injectToStream?: undefined | ((chunk: string) => void);
|
|
24
22
|
}): React.JSX.Element;
|
|
25
|
-
export declare const useLocation: () => {
|
|
26
|
-
pathname: string;
|
|
27
|
-
params: Record<string, any>;
|
|
28
|
-
goto: (url: string) => void;
|
|
29
|
-
};
|
|
30
23
|
export declare function RouterContextProvider({ children, client, cache, artifact_cache, component_cache, data_cache, ssr_signals, last_variables, session: ssrSession, }: {
|
|
31
24
|
children: React.ReactNode;
|
|
32
25
|
client: HoudiniClient;
|
|
@@ -38,26 +31,7 @@ export declare function RouterContextProvider({ children, client, cache, artifac
|
|
|
38
31
|
last_variables: LRUCache<GraphQLVariables>;
|
|
39
32
|
session?: App.Session;
|
|
40
33
|
}): React.JSX.Element;
|
|
41
|
-
type RouterContext = {
|
|
42
|
-
client: HoudiniClient;
|
|
43
|
-
cache: Cache;
|
|
44
|
-
artifact_cache: SuspenseCache<QueryArtifact>;
|
|
45
|
-
component_cache: SuspenseCache<PageComponent>;
|
|
46
|
-
data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
47
|
-
ssr_signals: PendingCache;
|
|
48
|
-
last_variables: LRUCache<GraphQLVariables>;
|
|
49
|
-
session: App.Session;
|
|
50
|
-
setSession: (newSession: Partial<App.Session>) => void;
|
|
51
|
-
};
|
|
52
|
-
export type PendingCache = SuspenseCache<Promise<void> & {
|
|
53
|
-
resolve: () => void;
|
|
54
|
-
reject: (message: string) => void;
|
|
55
|
-
}>;
|
|
56
|
-
export declare const useRouterContext: () => RouterContext;
|
|
57
|
-
export declare function useClient(): HoudiniClient;
|
|
58
|
-
export declare function useCache(): Cache;
|
|
59
34
|
export declare function updateLocalSession(session: App.Session): void;
|
|
60
|
-
export declare function useSession(): [App.Session, (newSession: Partial<App.Session>) => void];
|
|
61
35
|
export declare function useCurrentVariables(): GraphQLVariables;
|
|
62
36
|
export declare function useQueryResult<_Data extends GraphQLObject, _Input extends GraphQLVariables>(name: string): [_Data | null, DocumentHandle<any, _Data, _Input>];
|
|
63
37
|
export type RouterCache = {
|