houdini-react 1.3.9 → 2.0.0-next.1
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/vite.d.ts +1 -44
- package/build/plugin-cjs/index.js +33840 -27913
- package/build/plugin-esm/index.js +32265 -26334
- package/build/runtime/hooks/index.d.ts +1 -1
- package/build/runtime/hooks/useMutation.d.ts +3 -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 +4 -0
- package/build/runtime-cjs/hooks/useDocumentStore.js +4 -0
- package/build/runtime-cjs/hooks/useDocumentSubscription.js +5 -0
- 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 +24 -9
- 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.js +11 -3
- package/build/runtime-cjs/routing/cache.js +3 -0
- package/build/runtime-cjs/routing/hooks.js +4 -0
- package/build/runtime-cjs/routing/index.js +3 -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/useDocumentSubscription.js +1 -0
- 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 +23 -9
- package/build/runtime-esm/hooks/useQueryHandle.js +2 -0
- package/build/runtime-esm/routing/Router.js +7 -3
- package/build/runtime-esm/routing/cache.js +3 -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
|
+
}
|
|
@@ -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
|
));
|
|
@@ -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
|
));
|
|
@@ -47,6 +51,7 @@ function useDocumentSubscription({
|
|
|
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,6 +18,7 @@ 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);
|
|
@@ -29,24 +30,38 @@ function useMutation({
|
|
|
29
30
|
const [storeValue, observer] = (0, import_useDocumentStore.useDocumentStore)({ artifact });
|
|
30
31
|
const pending = storeValue.fetching;
|
|
31
32
|
const [session] = (0, import_hooks.useSession)();
|
|
32
|
-
const mutate = ({
|
|
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
|
});
|
|
@@ -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
|
));
|
|
@@ -245,7 +249,7 @@ function usePageData({
|
|
|
245
249
|
window.__houdini__nav_caches__.ssr_signals.delete(artifactName)
|
|
246
250
|
}
|
|
247
251
|
}
|
|
248
|
-
|
|
252
|
+
</script>
|
|
249
253
|
`);
|
|
250
254
|
resolve();
|
|
251
255
|
}).catch(reject);
|
|
@@ -290,7 +294,7 @@ function usePageData({
|
|
|
290
294
|
const artifact = mod.default;
|
|
291
295
|
artifact_cache.set(artifact_id, artifact);
|
|
292
296
|
injectToStream?.(`
|
|
293
|
-
<script type="module" src="${assetPrefix}/artifacts/${artifact.name}.js" async=""
|
|
297
|
+
<script type="module" src="${assetPrefix}/artifacts/${artifact.name}.js" async=""></script>
|
|
294
298
|
`);
|
|
295
299
|
load_query({ id: artifact.name, artifact, variables: variables2 });
|
|
296
300
|
}).catch((err) => {
|
|
@@ -405,7 +409,11 @@ function useLinkNavigation({ goto }) {
|
|
|
405
409
|
return;
|
|
406
410
|
}
|
|
407
411
|
const link = e.target?.closest("a");
|
|
408
|
-
if (!(link && link instanceof HTMLAnchorElement && link.href && (!link.target || link.target === "_self") && link.origin === location.origin && !link.hasAttribute("download") && e.button === 0 &&
|
|
412
|
+
if (!(link && link instanceof HTMLAnchorElement && link.href && (!link.target || link.target === "_self") && link.origin === location.origin && !link.hasAttribute("download") && e.button === 0 && // left clicks only
|
|
413
|
+
!e.metaKey && // open in new tab (mac)
|
|
414
|
+
!e.ctrlKey && // open in new tab (windows)
|
|
415
|
+
!e.altKey && // download
|
|
416
|
+
!e.shiftKey && !e.defaultPrevented)) {
|
|
409
417
|
return;
|
|
410
418
|
}
|
|
411
419
|
const target = link.attributes.getNamedItem("href")?.value;
|
|
@@ -31,6 +31,8 @@ function suspense_cache(initialData) {
|
|
|
31
31
|
return cache;
|
|
32
32
|
}
|
|
33
33
|
class SuspenseCache extends import_lru.LRUCache {
|
|
34
|
+
// if get is called before set, we need to invoke a callback.
|
|
35
|
+
// that means we need a place to put our callbacks
|
|
34
36
|
#callbacks = /* @__PURE__ */ new Map();
|
|
35
37
|
get(key) {
|
|
36
38
|
if (super.has(key)) {
|
|
@@ -40,6 +42,7 @@ class SuspenseCache extends import_lru.LRUCache {
|
|
|
40
42
|
this.#subscribe(key, resolve, reject);
|
|
41
43
|
});
|
|
42
44
|
}
|
|
45
|
+
// TODO: reject?
|
|
43
46
|
set(key, value) {
|
|
44
47
|
super.set(key, value);
|
|
45
48
|
if (this.#callbacks.has(key)) {
|
|
@@ -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,5 +27,7 @@ __reExport(routing_exports, require("./hooks"), module.exports);
|
|
|
27
27
|
var import_cache = require("./cache");
|
|
28
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
29
29
|
0 && (module.exports = {
|
|
30
|
-
suspense_cache
|
|
30
|
+
suspense_cache,
|
|
31
|
+
...require("./Router"),
|
|
32
|
+
...require("./hooks")
|
|
31
33
|
});
|
|
@@ -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';
|
|
@@ -2,11 +2,10 @@ import { useQuery } from "./useQuery";
|
|
|
2
2
|
import { useQueryHandle } from "./useQueryHandle";
|
|
3
3
|
import { useFragment } from "./useFragment";
|
|
4
4
|
import { useFragmentHandle } from "./useFragmentHandle";
|
|
5
|
-
import { useMutation } from "./useMutation";
|
|
5
|
+
import { useMutation, RuntimeGraphQLError } from "./useMutation";
|
|
6
6
|
import { useSubscription } from "./useSubscription";
|
|
7
|
-
import {} from "./useDocumentHandle";
|
|
8
|
-
import {} from "./useQueryHandle";
|
|
9
7
|
export {
|
|
8
|
+
RuntimeGraphQLError,
|
|
10
9
|
useFragment,
|
|
11
10
|
useFragmentHandle,
|
|
12
11
|
useMutation,
|
|
@@ -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
|
+
}
|
|
@@ -6,23 +6,37 @@ function useMutation({
|
|
|
6
6
|
const [storeValue, observer] = useDocumentStore({ artifact });
|
|
7
7
|
const pending = storeValue.fetching;
|
|
8
8
|
const [session] = useSession();
|
|
9
|
-
const mutate = ({
|
|
9
|
+
const mutate = async ({
|
|
10
10
|
metadata,
|
|
11
11
|
fetch,
|
|
12
12
|
variables,
|
|
13
13
|
abortController,
|
|
14
14
|
...mutationConfig
|
|
15
|
-
}) =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
}) => {
|
|
16
|
+
const result = await observer.send({
|
|
17
|
+
variables,
|
|
18
|
+
metadata,
|
|
19
|
+
session,
|
|
20
|
+
abortController,
|
|
21
|
+
stuff: {
|
|
22
|
+
...mutationConfig
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
if (result.errors && result.errors?.length > 0) {
|
|
26
|
+
const err = new RuntimeGraphQLError(
|
|
27
|
+
result.errors.map((error) => error.message).join(". ")
|
|
28
|
+
);
|
|
29
|
+
err.raw = result.errors;
|
|
30
|
+
throw err;
|
|
22
31
|
}
|
|
23
|
-
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
24
34
|
return [pending, mutate];
|
|
25
35
|
}
|
|
36
|
+
class RuntimeGraphQLError extends Error {
|
|
37
|
+
raw = [];
|
|
38
|
+
}
|
|
26
39
|
export {
|
|
40
|
+
RuntimeGraphQLError,
|
|
27
41
|
useMutation
|
|
28
42
|
};
|
|
@@ -52,11 +52,13 @@ function useQueryHandle({ artifact }, variables = null, config = {}) {
|
|
|
52
52
|
const suspenseUnit = {
|
|
53
53
|
then: loadPromise.then.bind(loadPromise),
|
|
54
54
|
resolve,
|
|
55
|
+
// @ts-ignore
|
|
55
56
|
variables
|
|
56
57
|
};
|
|
57
58
|
promiseCache.set(identifier, suspenseUnit);
|
|
58
59
|
handle.fetch({
|
|
59
60
|
variables,
|
|
61
|
+
// @ts-ignore: this is actually allowed... 🤫
|
|
60
62
|
stuff: {
|
|
61
63
|
silenceLoading: true
|
|
62
64
|
}
|
|
@@ -209,7 +209,7 @@ function usePageData({
|
|
|
209
209
|
window.__houdini__nav_caches__.ssr_signals.delete(artifactName)
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
-
|
|
212
|
+
</script>
|
|
213
213
|
`);
|
|
214
214
|
resolve();
|
|
215
215
|
}).catch(reject);
|
|
@@ -254,7 +254,7 @@ function usePageData({
|
|
|
254
254
|
const artifact = mod.default;
|
|
255
255
|
artifact_cache.set(artifact_id, artifact);
|
|
256
256
|
injectToStream?.(`
|
|
257
|
-
<script type="module" src="${assetPrefix}/artifacts/${artifact.name}.js" async=""
|
|
257
|
+
<script type="module" src="${assetPrefix}/artifacts/${artifact.name}.js" async=""></script>
|
|
258
258
|
`);
|
|
259
259
|
load_query({ id: artifact.name, artifact, variables: variables2 });
|
|
260
260
|
}).catch((err) => {
|
|
@@ -369,7 +369,11 @@ function useLinkNavigation({ goto }) {
|
|
|
369
369
|
return;
|
|
370
370
|
}
|
|
371
371
|
const link = e.target?.closest("a");
|
|
372
|
-
if (!(link && link instanceof HTMLAnchorElement && link.href && (!link.target || link.target === "_self") && link.origin === location.origin && !link.hasAttribute("download") && e.button === 0 &&
|
|
372
|
+
if (!(link && link instanceof HTMLAnchorElement && link.href && (!link.target || link.target === "_self") && link.origin === location.origin && !link.hasAttribute("download") && e.button === 0 && // left clicks only
|
|
373
|
+
!e.metaKey && // open in new tab (mac)
|
|
374
|
+
!e.ctrlKey && // open in new tab (windows)
|
|
375
|
+
!e.altKey && // download
|
|
376
|
+
!e.shiftKey && !e.defaultPrevented)) {
|
|
373
377
|
return;
|
|
374
378
|
}
|
|
375
379
|
const target = link.attributes.getNamedItem("href")?.value;
|
|
@@ -7,6 +7,8 @@ function suspense_cache(initialData) {
|
|
|
7
7
|
return cache;
|
|
8
8
|
}
|
|
9
9
|
class SuspenseCache extends LRUCache {
|
|
10
|
+
// if get is called before set, we need to invoke a callback.
|
|
11
|
+
// that means we need a place to put our callbacks
|
|
10
12
|
#callbacks = /* @__PURE__ */ new Map();
|
|
11
13
|
get(key) {
|
|
12
14
|
if (super.has(key)) {
|
|
@@ -16,6 +18,7 @@ class SuspenseCache extends LRUCache {
|
|
|
16
18
|
this.#subscribe(key, resolve, reject);
|
|
17
19
|
});
|
|
18
20
|
}
|
|
21
|
+
// TODO: reject?
|
|
19
22
|
set(key, value) {
|
|
20
23
|
super.set(key, value);
|
|
21
24
|
if (this.#callbacks.has(key)) {
|
|
@@ -16,11 +16,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var index_exports = {};
|
|
20
|
+
__export(index_exports, {
|
|
21
21
|
renderToStream: () => import_server.renderToStream
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(index_exports);
|
|
24
24
|
var import_server = require("react-streaming-compat/server");
|
|
25
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
26
|
0 && (module.exports = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "houdini-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-next.1",
|
|
4
4
|
"description": "The React plugin for houdini",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"cookies": "^0.8.0",
|
|
35
35
|
"estraverse": "^5.3.0",
|
|
36
36
|
"express": "^4.18.2",
|
|
37
|
-
"graphql": "^
|
|
37
|
+
"graphql": "^16.10.0",
|
|
38
38
|
"graphql-yoga": "^4.0.4",
|
|
39
39
|
"react": "^19.0.0",
|
|
40
40
|
"react-dom": "^19.0.0",
|
|
41
41
|
"react-streaming-compat": "^0.3.18",
|
|
42
42
|
"recast": "^0.23.1",
|
|
43
|
-
"rollup": "^4.
|
|
43
|
+
"rollup": "^4.39.0",
|
|
44
44
|
"use-deep-compare-effect": "^1.8.1",
|
|
45
|
-
"houdini": "^
|
|
45
|
+
"houdini": "^2.0.0-next.1"
|
|
46
46
|
},
|
|
47
47
|
"files": [
|
|
48
48
|
"build"
|