houdini 1.2.43 → 1.2.45
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-cjs/index.js +684 -786
- package/build/cmd-esm/index.js +534 -636
- package/build/codegen/generators/artifacts/inputs.d.ts +1 -1
- package/build/codegen/generators/comments/jsdoc.d.ts +2 -0
- package/build/codegen/transforms/index.d.ts +1 -0
- package/build/codegen/transforms/runtimeScalars.d.ts +2 -0
- package/build/codegen-cjs/index.js +677 -782
- package/build/codegen-esm/index.js +527 -632
- package/build/lib/config.d.ts +1 -0
- package/build/lib/graphql.d.ts +1 -1
- package/build/lib/index.d.ts +1 -0
- package/build/lib/typescript.d.ts +19 -0
- package/build/lib-cjs/index.js +711 -477
- package/build/lib-esm/index.js +705 -477
- package/build/runtime/client/index.d.ts +7 -1
- package/build/runtime/client/plugins/fragment.d.ts +2 -2
- package/build/runtime/client/plugins/mutation.d.ts +2 -1
- package/build/runtime/client/plugins/query.d.ts +2 -2
- package/build/runtime/lib/config.d.ts +12 -2
- package/build/runtime/lib/scalars.d.ts +1 -1
- package/build/runtime/lib/types.d.ts +17 -2
- package/build/runtime/router/session.d.ts +1 -2
- package/build/runtime/router/types.d.ts +3 -1
- package/build/runtime-cjs/client/index.d.ts +7 -1
- package/build/runtime-cjs/client/index.js +26 -11
- package/build/runtime-cjs/client/plugins/fragment.d.ts +2 -2
- package/build/runtime-cjs/client/plugins/fragment.js +4 -11
- package/build/runtime-cjs/client/plugins/mutation.d.ts +2 -1
- package/build/runtime-cjs/client/plugins/mutation.js +8 -15
- package/build/runtime-cjs/client/plugins/query.d.ts +2 -2
- package/build/runtime-cjs/client/plugins/query.js +18 -11
- package/build/runtime-cjs/lib/config.d.ts +12 -2
- package/build/runtime-cjs/lib/scalars.d.ts +1 -1
- package/build/runtime-cjs/lib/scalars.js +4 -0
- package/build/runtime-cjs/lib/types.d.ts +17 -2
- package/build/runtime-cjs/router/server.js +2 -3
- package/build/runtime-cjs/router/session.d.ts +1 -2
- package/build/runtime-cjs/router/session.js +25 -11
- package/build/runtime-cjs/router/types.d.ts +3 -1
- package/build/runtime-esm/client/index.d.ts +7 -1
- package/build/runtime-esm/client/index.js +26 -11
- package/build/runtime-esm/client/plugins/fragment.d.ts +2 -2
- package/build/runtime-esm/client/plugins/fragment.js +1 -2
- package/build/runtime-esm/client/plugins/mutation.d.ts +2 -1
- package/build/runtime-esm/client/plugins/mutation.js +1 -2
- package/build/runtime-esm/client/plugins/query.d.ts +2 -2
- package/build/runtime-esm/client/plugins/query.js +15 -2
- package/build/runtime-esm/lib/config.d.ts +12 -2
- package/build/runtime-esm/lib/scalars.d.ts +1 -1
- package/build/runtime-esm/lib/scalars.js +6 -0
- package/build/runtime-esm/lib/types.d.ts +17 -2
- package/build/runtime-esm/router/server.js +2 -3
- package/build/runtime-esm/router/session.d.ts +1 -2
- package/build/runtime-esm/router/session.js +25 -11
- package/build/runtime-esm/router/types.d.ts +3 -1
- package/build/test-cjs/index.js +706 -785
- package/build/test-esm/index.js +556 -635
- package/build/vite-cjs/index.js +793 -793
- package/build/vite-esm/index.js +643 -643
- package/package.json +1 -1
- package/build/codegen/generators/typescript/typeReference.d.ts +0 -8
- package/build/codegen/generators/typescript/types.d.ts +0 -10
|
@@ -23,8 +23,12 @@ export type ObserveParams<_Data extends GraphQLObject, _Artifact extends Documen
|
|
|
23
23
|
};
|
|
24
24
|
export declare class HoudiniClient {
|
|
25
25
|
url: string;
|
|
26
|
-
readonly plugins: ClientPlugin[];
|
|
27
26
|
readonly throwOnError_operations: ThrowOnErrorOperations[];
|
|
27
|
+
private cache;
|
|
28
|
+
private throwOnError;
|
|
29
|
+
private fetchParams;
|
|
30
|
+
private pipeline;
|
|
31
|
+
private extraPlugins;
|
|
28
32
|
proxies: Record<string, (operation: {
|
|
29
33
|
query: string;
|
|
30
34
|
variables: any;
|
|
@@ -32,7 +36,9 @@ export declare class HoudiniClient {
|
|
|
32
36
|
session: App.Session | null | undefined;
|
|
33
37
|
}) => Promise<any>>;
|
|
34
38
|
componentCache: Record<string, any>;
|
|
39
|
+
setCache(cache: Cache): void;
|
|
35
40
|
constructor({ url, fetchParams, plugins, pipeline, throwOnError, }?: HoudiniClientConstructorArgs);
|
|
41
|
+
get plugins(): ClientPlugin[];
|
|
36
42
|
observe<_Data extends GraphQLObject, _Input extends GraphQLVariables>({ enableCache, fetching, ...rest }: ObserveParams<_Data, DocumentArtifact, _Input>): DocumentStore<_Data, _Input>;
|
|
37
43
|
registerProxy(url: string, handler: (operation: {
|
|
38
44
|
query: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const fragment: ClientPlugin;
|
|
1
|
+
import type { Cache } from '../../cache/cache';
|
|
2
|
+
export declare const fragment: (cache: Cache) => import("..").ClientPlugin;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Cache } from '../../cache/cache';
|
|
2
|
+
export declare const mutation: (cache: Cache) => import("..").ClientPlugin;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const query: ClientPlugin;
|
|
1
|
+
import type { Cache } from '../../cache/cache';
|
|
2
|
+
export declare const query: (cache: Cache) => import("..").ClientPlugin;
|
|
@@ -119,13 +119,23 @@ export type ConfigFile = {
|
|
|
119
119
|
*/
|
|
120
120
|
router?: RouterConfig;
|
|
121
121
|
/**
|
|
122
|
-
* A collection of flags to opt-into experimental features
|
|
122
|
+
* A collection of flags to opt-into experimental features are not yet stable and can break on any
|
|
123
|
+
* minor version.
|
|
123
124
|
*/
|
|
124
125
|
features?: {
|
|
125
|
-
|
|
126
|
+
/** Interact with the cache directly using an imperative API.*/
|
|
126
127
|
imperativeCache?: boolean;
|
|
128
|
+
runtimeScalars?: Record<string, {
|
|
129
|
+
type: string;
|
|
130
|
+
resolve: (args: RuntimeScalarPayload) => any;
|
|
131
|
+
}>;
|
|
132
|
+
/** [React Only] Emebed component references in query responses*/
|
|
133
|
+
componentFields?: boolean;
|
|
127
134
|
};
|
|
128
135
|
};
|
|
136
|
+
export type RuntimeScalarPayload = {
|
|
137
|
+
session?: App.Session | null | undefined;
|
|
138
|
+
};
|
|
129
139
|
type RouterConfig = {
|
|
130
140
|
auth?: AuthStrategy;
|
|
131
141
|
apiEndpoint?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConfigFile } from './config';
|
|
2
|
-
import type
|
|
2
|
+
import { type FragmentArtifact, type MutationArtifact, type QueryArtifact, type SubscriptionArtifact, type SubscriptionSelection } from './types';
|
|
3
3
|
export declare function marshalSelection({ selection, data, }: {
|
|
4
4
|
selection: SubscriptionSelection;
|
|
5
5
|
data: any;
|
|
@@ -31,6 +31,9 @@ declare global {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
+
export type RuntimeScalarResolver = (args: {
|
|
35
|
+
session: App.Session;
|
|
36
|
+
}) => any;
|
|
34
37
|
export type Fragment<_Result> = {
|
|
35
38
|
readonly shape?: _Result;
|
|
36
39
|
};
|
|
@@ -72,6 +75,7 @@ export type InputObject = {
|
|
|
72
75
|
fields: Record<string, string>;
|
|
73
76
|
types: Record<string, Record<string, string>>;
|
|
74
77
|
defaults: Record<string, any>;
|
|
78
|
+
runtimeScalars: Record<string, string>;
|
|
75
79
|
};
|
|
76
80
|
export type BaseCompiledDocument<_Kind extends ArtifactKinds> = {
|
|
77
81
|
name: string;
|
|
@@ -363,6 +367,14 @@ export type PageManifest = {
|
|
|
363
367
|
layouts: string[];
|
|
364
368
|
/** The filepath of the unit */
|
|
365
369
|
path: string;
|
|
370
|
+
/**
|
|
371
|
+
* The name and type of every route paramter that this page can use.
|
|
372
|
+
* null indicates the type is unknown (not constrained by a query)
|
|
373
|
+
**/
|
|
374
|
+
params: Record<string, {
|
|
375
|
+
type: string;
|
|
376
|
+
wrappers: string[];
|
|
377
|
+
} | null>;
|
|
366
378
|
};
|
|
367
379
|
export type QueryManifest = {
|
|
368
380
|
/** the name of the query */
|
|
@@ -373,6 +385,9 @@ export type QueryManifest = {
|
|
|
373
385
|
loading: boolean;
|
|
374
386
|
/** The filepath of the unit */
|
|
375
387
|
path: string;
|
|
376
|
-
/** The
|
|
377
|
-
variables: string
|
|
388
|
+
/** The name and GraphQL type for the variables that this query cares about */
|
|
389
|
+
variables: Record<string, {
|
|
390
|
+
wrappers: string[];
|
|
391
|
+
type: string;
|
|
392
|
+
}>;
|
|
378
393
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { ConfigFile } from '../lib';
|
|
2
2
|
type ServerHandlerArgs = {
|
|
3
|
-
|
|
3
|
+
request: Request;
|
|
4
4
|
config: ConfigFile;
|
|
5
5
|
session_keys: string[];
|
|
6
|
-
headers: Headers;
|
|
7
6
|
};
|
|
8
7
|
export declare function handle_request(args: ServerHandlerArgs): Promise<Response | undefined>;
|
|
9
8
|
export type Server = {
|
|
@@ -16,7 +16,9 @@ export type RouterPageManifest<_ComponentType> = {
|
|
|
16
16
|
default: QueryArtifact;
|
|
17
17
|
}>;
|
|
18
18
|
loading: boolean;
|
|
19
|
-
variables: string
|
|
19
|
+
variables: Record<string, {
|
|
20
|
+
type: string;
|
|
21
|
+
}>;
|
|
20
22
|
}>;
|
|
21
23
|
component: () => Promise<{
|
|
22
24
|
default: (props: any) => _ComponentType;
|
|
@@ -23,8 +23,12 @@ export type ObserveParams<_Data extends GraphQLObject, _Artifact extends Documen
|
|
|
23
23
|
};
|
|
24
24
|
export declare class HoudiniClient {
|
|
25
25
|
url: string;
|
|
26
|
-
readonly plugins: ClientPlugin[];
|
|
27
26
|
readonly throwOnError_operations: ThrowOnErrorOperations[];
|
|
27
|
+
private cache;
|
|
28
|
+
private throwOnError;
|
|
29
|
+
private fetchParams;
|
|
30
|
+
private pipeline;
|
|
31
|
+
private extraPlugins;
|
|
28
32
|
proxies: Record<string, (operation: {
|
|
29
33
|
query: string;
|
|
30
34
|
variables: any;
|
|
@@ -32,7 +36,9 @@ export declare class HoudiniClient {
|
|
|
32
36
|
session: App.Session | null | undefined;
|
|
33
37
|
}) => Promise<any>>;
|
|
34
38
|
componentCache: Record<string, any>;
|
|
39
|
+
setCache(cache: Cache): void;
|
|
35
40
|
constructor({ url, fetchParams, plugins, pipeline, throwOnError, }?: HoudiniClientConstructorArgs);
|
|
41
|
+
get plugins(): ClientPlugin[];
|
|
36
42
|
observe<_Data extends GraphQLObject, _Input extends GraphQLVariables>({ enableCache, fetching, ...rest }: ObserveParams<_Data, DocumentArtifact, _Input>): DocumentStore<_Data, _Input>;
|
|
37
43
|
registerProxy(url: string, handler: (operation: {
|
|
38
44
|
query: string;
|
|
@@ -33,6 +33,7 @@ __export(client_exports, {
|
|
|
33
33
|
subscription: () => import_plugins2.subscription
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(client_exports);
|
|
36
|
+
var import_cache = __toESM(require("../cache"), 1);
|
|
36
37
|
var import_lib = require("../lib");
|
|
37
38
|
var import_flatten = require("../lib/flatten");
|
|
38
39
|
var import_documentStore = require("./documentStore");
|
|
@@ -42,10 +43,17 @@ var import_documentStore2 = require("./documentStore");
|
|
|
42
43
|
var import_plugins2 = require("./plugins");
|
|
43
44
|
class HoudiniClient {
|
|
44
45
|
url;
|
|
45
|
-
plugins;
|
|
46
46
|
throwOnError_operations;
|
|
47
|
+
cache = null;
|
|
48
|
+
throwOnError;
|
|
49
|
+
fetchParams;
|
|
50
|
+
pipeline;
|
|
51
|
+
extraPlugins;
|
|
47
52
|
proxies = {};
|
|
48
53
|
componentCache = {};
|
|
54
|
+
setCache(cache) {
|
|
55
|
+
this.cache = cache;
|
|
56
|
+
}
|
|
49
57
|
constructor({
|
|
50
58
|
url,
|
|
51
59
|
fetchParams,
|
|
@@ -59,23 +67,29 @@ class HoudiniClient {
|
|
|
59
67
|
);
|
|
60
68
|
}
|
|
61
69
|
this.throwOnError_operations = throwOnError?.operations ?? [];
|
|
62
|
-
|
|
70
|
+
let serverPort = globalThis.process?.env?.HOUDINI_PORT ?? "5173";
|
|
71
|
+
this.url = url ?? (globalThis.window ? "" : `https://localhost:${serverPort}`) + (0, import_lib.localApiEndpoint)((0, import_lib.getCurrentConfig)());
|
|
72
|
+
this.throwOnError = throwOnError;
|
|
73
|
+
this.fetchParams = fetchParams;
|
|
74
|
+
this.pipeline = pipeline;
|
|
75
|
+
this.extraPlugins = plugins;
|
|
76
|
+
}
|
|
77
|
+
get plugins() {
|
|
78
|
+
return (0, import_flatten.flatten)(
|
|
63
79
|
[].concat(
|
|
64
|
-
throwOnError ? [(0, import_plugins.throwOnError)(throwOnError)] : [],
|
|
65
|
-
(0, import_plugins.fetchParams)(fetchParams),
|
|
66
|
-
pipeline ?? [
|
|
67
|
-
import_plugins.query,
|
|
68
|
-
import_plugins.mutation,
|
|
69
|
-
import_plugins.fragment
|
|
80
|
+
this.throwOnError ? [(0, import_plugins.throwOnError)(this.throwOnError)] : [],
|
|
81
|
+
(0, import_plugins.fetchParams)(this.fetchParams),
|
|
82
|
+
this.pipeline ?? [
|
|
83
|
+
(0, import_plugins.query)(this.cache ?? import_cache.default),
|
|
84
|
+
(0, import_plugins.mutation)(this.cache ?? import_cache.default),
|
|
85
|
+
(0, import_plugins.fragment)(this.cache ?? import_cache.default)
|
|
70
86
|
].concat(
|
|
71
|
-
|
|
87
|
+
this.extraPlugins ?? [],
|
|
72
88
|
import_injectedPlugins.default,
|
|
73
89
|
(0, import_plugins.fetch)()
|
|
74
90
|
)
|
|
75
91
|
)
|
|
76
92
|
);
|
|
77
|
-
let serverPort = globalThis.process?.env?.HOUDINI_PORT ?? "5173";
|
|
78
|
-
this.url = url ?? (globalThis.window ? "" : `https://localhost:${serverPort}`) + (0, import_lib.localApiEndpoint)((0, import_lib.getCurrentConfig)());
|
|
79
93
|
}
|
|
80
94
|
observe({
|
|
81
95
|
enableCache = true,
|
|
@@ -87,6 +101,7 @@ class HoudiniClient {
|
|
|
87
101
|
plugins: createPluginHooks(this.plugins),
|
|
88
102
|
fetching,
|
|
89
103
|
enableCache,
|
|
104
|
+
cache: this.cache ?? void 0,
|
|
90
105
|
...rest
|
|
91
106
|
});
|
|
92
107
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const fragment: ClientPlugin;
|
|
1
|
+
import type { Cache } from '../../cache/cache';
|
|
2
|
+
export declare const fragment: (cache: Cache) => import("..").ClientPlugin;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,21 +15,16 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
19
|
var fragment_exports = {};
|
|
26
20
|
__export(fragment_exports, {
|
|
27
21
|
fragment: () => fragment
|
|
28
22
|
});
|
|
29
23
|
module.exports = __toCommonJS(fragment_exports);
|
|
30
|
-
var import_cache = __toESM(require("../../cache"), 1);
|
|
31
24
|
var import_deepEquals = require("../../lib/deepEquals");
|
|
32
25
|
var import_types = require("../../lib/types");
|
|
33
26
|
var import_utils = require("../utils");
|
|
34
|
-
const fragment = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Fragment, function() {
|
|
27
|
+
const fragment = (cache) => (0, import_utils.documentPlugin)(import_types.ArtifactKind.Fragment, function() {
|
|
35
28
|
let subscriptionSpec = null;
|
|
36
29
|
let lastReference = null;
|
|
37
30
|
return {
|
|
@@ -45,7 +38,7 @@ const fragment = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Frag
|
|
|
45
38
|
};
|
|
46
39
|
if (!ctx.cacheParams?.disableSubscriptions && (!(0, import_deepEquals.deepEquals)(lastReference, currentReference) || variablesChanged(ctx))) {
|
|
47
40
|
if (subscriptionSpec) {
|
|
48
|
-
|
|
41
|
+
cache.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
49
42
|
}
|
|
50
43
|
const variables = marshalVariables(ctx);
|
|
51
44
|
subscriptionSpec = {
|
|
@@ -65,14 +58,14 @@ const fragment = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Frag
|
|
|
65
58
|
});
|
|
66
59
|
}
|
|
67
60
|
};
|
|
68
|
-
|
|
61
|
+
cache.subscribe(subscriptionSpec, variables);
|
|
69
62
|
lastReference = currentReference;
|
|
70
63
|
}
|
|
71
64
|
next(ctx);
|
|
72
65
|
},
|
|
73
66
|
cleanup() {
|
|
74
67
|
if (subscriptionSpec) {
|
|
75
|
-
|
|
68
|
+
cache.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
76
69
|
}
|
|
77
70
|
}
|
|
78
71
|
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Cache } from '../../cache/cache';
|
|
2
|
+
export declare const mutation: (cache: Cache) => import("..").ClientPlugin;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,28 +15,23 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
19
|
var mutation_exports = {};
|
|
26
20
|
__export(mutation_exports, {
|
|
27
21
|
mutation: () => mutation
|
|
28
22
|
});
|
|
29
23
|
module.exports = __toCommonJS(mutation_exports);
|
|
30
|
-
var import_cache = __toESM(require("../../cache"), 1);
|
|
31
24
|
var import_scalars = require("../../lib/scalars");
|
|
32
25
|
var import_types = require("../../lib/types");
|
|
33
26
|
var import_utils = require("../utils");
|
|
34
|
-
const mutation = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Mutation, () => {
|
|
27
|
+
const mutation = (cache) => (0, import_utils.documentPlugin)(import_types.ArtifactKind.Mutation, () => {
|
|
35
28
|
return {
|
|
36
29
|
async start(ctx, { next, marshalVariables }) {
|
|
37
|
-
const layerOptimistic =
|
|
30
|
+
const layerOptimistic = cache._internal_unstable.storage.createLayer(true);
|
|
38
31
|
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
39
32
|
let toNotify = [];
|
|
40
33
|
if (optimisticResponse) {
|
|
41
|
-
toNotify =
|
|
34
|
+
toNotify = cache.write({
|
|
42
35
|
selection: ctx.artifact.selection,
|
|
43
36
|
data: await (0, import_scalars.marshalSelection)({
|
|
44
37
|
selection: ctx.artifact.selection,
|
|
@@ -58,7 +51,7 @@ const mutation = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Muta
|
|
|
58
51
|
},
|
|
59
52
|
afterNetwork(ctx, { resolve }) {
|
|
60
53
|
if (ctx.cacheParams?.layer) {
|
|
61
|
-
|
|
54
|
+
cache.clearLayer(ctx.cacheParams.layer.id);
|
|
62
55
|
}
|
|
63
56
|
resolve(ctx);
|
|
64
57
|
},
|
|
@@ -66,19 +59,19 @@ const mutation = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Muta
|
|
|
66
59
|
const hasErrors = value.errors && value.errors.length > 0;
|
|
67
60
|
if (hasErrors) {
|
|
68
61
|
if (ctx.cacheParams?.layer) {
|
|
69
|
-
|
|
62
|
+
cache.clearLayer(ctx.cacheParams.layer.id);
|
|
70
63
|
}
|
|
71
64
|
}
|
|
72
65
|
if (ctx.cacheParams?.layer) {
|
|
73
|
-
|
|
66
|
+
cache._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
74
67
|
}
|
|
75
68
|
resolve(ctx);
|
|
76
69
|
},
|
|
77
70
|
catch(ctx, { error }) {
|
|
78
71
|
if (ctx.cacheParams?.layer) {
|
|
79
72
|
const { layer } = ctx.cacheParams;
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
cache.clearLayer(layer.id);
|
|
74
|
+
cache._internal_unstable.storage.resolveLayer(layer.id);
|
|
82
75
|
}
|
|
83
76
|
throw error;
|
|
84
77
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const query: ClientPlugin;
|
|
1
|
+
import type { Cache } from '../../cache/cache';
|
|
2
|
+
export declare const query: (cache: Cache) => import("..").ClientPlugin;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,26 +15,35 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
19
|
var query_exports = {};
|
|
26
20
|
__export(query_exports, {
|
|
27
21
|
query: () => query
|
|
28
22
|
});
|
|
29
23
|
module.exports = __toCommonJS(query_exports);
|
|
30
|
-
var import_cache = __toESM(require("../../cache"), 1);
|
|
31
24
|
var import_types = require("../../lib/types");
|
|
32
25
|
var import_utils = require("../utils");
|
|
33
|
-
const query = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Query, function() {
|
|
26
|
+
const query = (cache) => (0, import_utils.documentPlugin)(import_types.ArtifactKind.Query, function() {
|
|
34
27
|
let subscriptionSpec = null;
|
|
35
28
|
let lastVariables = null;
|
|
36
29
|
return {
|
|
37
30
|
start(ctx, { next }) {
|
|
31
|
+
const runtimeScalarPayload = {
|
|
32
|
+
session: ctx.session
|
|
33
|
+
};
|
|
38
34
|
ctx.variables = {
|
|
39
35
|
...lastVariables,
|
|
36
|
+
...Object.fromEntries(
|
|
37
|
+
Object.entries(ctx.artifact.input?.runtimeScalars ?? {}).map(
|
|
38
|
+
([field, type]) => {
|
|
39
|
+
const runtimeScalar = ctx.config.features?.runtimeScalars?.[type];
|
|
40
|
+
if (!runtimeScalar) {
|
|
41
|
+
return [field, type];
|
|
42
|
+
}
|
|
43
|
+
return [field, runtimeScalar.resolve(runtimeScalarPayload)];
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
),
|
|
40
47
|
...ctx.variables
|
|
41
48
|
};
|
|
42
49
|
next(ctx);
|
|
@@ -44,7 +51,7 @@ const query = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Query,
|
|
|
44
51
|
end(ctx, { resolve, marshalVariables, variablesChanged }) {
|
|
45
52
|
if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
|
|
46
53
|
if (subscriptionSpec) {
|
|
47
|
-
|
|
54
|
+
cache.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
48
55
|
}
|
|
49
56
|
lastVariables = { ...marshalVariables(ctx) };
|
|
50
57
|
const variables = lastVariables;
|
|
@@ -64,13 +71,13 @@ const query = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Query,
|
|
|
64
71
|
});
|
|
65
72
|
}
|
|
66
73
|
};
|
|
67
|
-
|
|
74
|
+
cache.subscribe(subscriptionSpec, lastVariables);
|
|
68
75
|
}
|
|
69
76
|
resolve(ctx);
|
|
70
77
|
},
|
|
71
78
|
cleanup() {
|
|
72
79
|
if (subscriptionSpec) {
|
|
73
|
-
|
|
80
|
+
cache.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
74
81
|
lastVariables = null;
|
|
75
82
|
}
|
|
76
83
|
}
|
|
@@ -119,13 +119,23 @@ export type ConfigFile = {
|
|
|
119
119
|
*/
|
|
120
120
|
router?: RouterConfig;
|
|
121
121
|
/**
|
|
122
|
-
* A collection of flags to opt-into experimental features
|
|
122
|
+
* A collection of flags to opt-into experimental features are not yet stable and can break on any
|
|
123
|
+
* minor version.
|
|
123
124
|
*/
|
|
124
125
|
features?: {
|
|
125
|
-
|
|
126
|
+
/** Interact with the cache directly using an imperative API.*/
|
|
126
127
|
imperativeCache?: boolean;
|
|
128
|
+
runtimeScalars?: Record<string, {
|
|
129
|
+
type: string;
|
|
130
|
+
resolve: (args: RuntimeScalarPayload) => any;
|
|
131
|
+
}>;
|
|
132
|
+
/** [React Only] Emebed component references in query responses*/
|
|
133
|
+
componentFields?: boolean;
|
|
127
134
|
};
|
|
128
135
|
};
|
|
136
|
+
export type RuntimeScalarPayload = {
|
|
137
|
+
session?: App.Session | null | undefined;
|
|
138
|
+
};
|
|
129
139
|
type RouterConfig = {
|
|
130
140
|
auth?: AuthStrategy;
|
|
131
141
|
apiEndpoint?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConfigFile } from './config';
|
|
2
|
-
import type
|
|
2
|
+
import { type FragmentArtifact, type MutationArtifact, type QueryArtifact, type SubscriptionArtifact, type SubscriptionSelection } from './types';
|
|
3
3
|
export declare function marshalSelection({ selection, data, }: {
|
|
4
4
|
selection: SubscriptionSelection;
|
|
5
5
|
data: any;
|
|
@@ -26,6 +26,7 @@ __export(scalars_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(scalars_exports);
|
|
27
27
|
var import_config = require("./config");
|
|
28
28
|
var import_selection = require("./selection");
|
|
29
|
+
var import_types = require("./types");
|
|
29
30
|
async function marshalSelection({
|
|
30
31
|
selection,
|
|
31
32
|
data
|
|
@@ -41,6 +42,9 @@ async function marshalSelection({
|
|
|
41
42
|
return Object.fromEntries(
|
|
42
43
|
await Promise.all(
|
|
43
44
|
Object.entries(data).map(async ([fieldName, value]) => {
|
|
45
|
+
if (fieldName === import_types.fragmentKey) {
|
|
46
|
+
return [fieldName, value];
|
|
47
|
+
}
|
|
44
48
|
const { type, selection: selection2 } = targetSelection[fieldName];
|
|
45
49
|
if (!type) {
|
|
46
50
|
return [fieldName, value];
|
|
@@ -31,6 +31,9 @@ declare global {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
+
export type RuntimeScalarResolver = (args: {
|
|
35
|
+
session: App.Session;
|
|
36
|
+
}) => any;
|
|
34
37
|
export type Fragment<_Result> = {
|
|
35
38
|
readonly shape?: _Result;
|
|
36
39
|
};
|
|
@@ -72,6 +75,7 @@ export type InputObject = {
|
|
|
72
75
|
fields: Record<string, string>;
|
|
73
76
|
types: Record<string, Record<string, string>>;
|
|
74
77
|
defaults: Record<string, any>;
|
|
78
|
+
runtimeScalars: Record<string, string>;
|
|
75
79
|
};
|
|
76
80
|
export type BaseCompiledDocument<_Kind extends ArtifactKinds> = {
|
|
77
81
|
name: string;
|
|
@@ -363,6 +367,14 @@ export type PageManifest = {
|
|
|
363
367
|
layouts: string[];
|
|
364
368
|
/** The filepath of the unit */
|
|
365
369
|
path: string;
|
|
370
|
+
/**
|
|
371
|
+
* The name and type of every route paramter that this page can use.
|
|
372
|
+
* null indicates the type is unknown (not constrained by a query)
|
|
373
|
+
**/
|
|
374
|
+
params: Record<string, {
|
|
375
|
+
type: string;
|
|
376
|
+
wrappers: string[];
|
|
377
|
+
} | null>;
|
|
366
378
|
};
|
|
367
379
|
export type QueryManifest = {
|
|
368
380
|
/** the name of the query */
|
|
@@ -373,6 +385,9 @@ export type QueryManifest = {
|
|
|
373
385
|
loading: boolean;
|
|
374
386
|
/** The filepath of the unit */
|
|
375
387
|
path: string;
|
|
376
|
-
/** The
|
|
377
|
-
variables: string
|
|
388
|
+
/** The name and GraphQL type for the variables that this query cares about */
|
|
389
|
+
variables: Record<string, {
|
|
390
|
+
wrappers: string[];
|
|
391
|
+
type: string;
|
|
392
|
+
}>;
|
|
378
393
|
};
|
|
@@ -66,10 +66,9 @@ function _serverHandler({
|
|
|
66
66
|
return yoga(request);
|
|
67
67
|
}
|
|
68
68
|
const authResponse = await (0, import_session.handle_request)({
|
|
69
|
-
|
|
69
|
+
request,
|
|
70
70
|
config: config_file,
|
|
71
|
-
session_keys
|
|
72
|
-
headers: request.headers
|
|
71
|
+
session_keys
|
|
73
72
|
});
|
|
74
73
|
if (authResponse) {
|
|
75
74
|
return authResponse;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { ConfigFile } from '../lib';
|
|
2
2
|
type ServerHandlerArgs = {
|
|
3
|
-
|
|
3
|
+
request: Request;
|
|
4
4
|
config: ConfigFile;
|
|
5
5
|
session_keys: string[];
|
|
6
|
-
headers: Headers;
|
|
7
6
|
};
|
|
8
7
|
export declare function handle_request(args: ServerHandlerArgs): Promise<Response | undefined>;
|
|
9
8
|
export type Server = {
|
|
@@ -26,22 +26,36 @@ var import_cookies = require("./cookies");
|
|
|
26
26
|
var import_jwt = require("./jwt");
|
|
27
27
|
async function handle_request(args) {
|
|
28
28
|
const plugin_config = args.config.router ?? {};
|
|
29
|
-
const { pathname } = new URL(args.url);
|
|
29
|
+
const { pathname } = new URL(args.request.url);
|
|
30
30
|
if (plugin_config.auth && "redirect" in plugin_config.auth && pathname.startsWith(plugin_config.auth.redirect)) {
|
|
31
31
|
return await redirect_auth(args);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
async function redirect_auth(args) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
if (args.request.method === "GET") {
|
|
36
|
+
const { searchParams } = new URL(
|
|
37
|
+
args.request.url,
|
|
38
|
+
`http://${args.request.headers.get("host")}`
|
|
39
|
+
);
|
|
40
|
+
const { redirectTo, ...session } = Object.fromEntries(searchParams.entries());
|
|
41
|
+
const response = new Response("ok", {
|
|
42
|
+
status: 302,
|
|
43
|
+
headers: {
|
|
44
|
+
Location: redirectTo ?? "/"
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
await set_session(args, response, session);
|
|
48
|
+
return response;
|
|
49
|
+
}
|
|
50
|
+
if (args.request.method === "POST") {
|
|
51
|
+
const newValues = await args.request.json();
|
|
52
|
+
const existing = await get_session(args.request.headers, args.session_keys);
|
|
53
|
+
const response = new Response("ok", {
|
|
54
|
+
status: 200
|
|
55
|
+
});
|
|
56
|
+
await set_session(args, response, { ...existing, ...newValues });
|
|
57
|
+
return response;
|
|
58
|
+
}
|
|
45
59
|
}
|
|
46
60
|
const session_cookie_name = "__houdini__";
|
|
47
61
|
async function set_session(req, response, value) {
|
|
@@ -16,7 +16,9 @@ export type RouterPageManifest<_ComponentType> = {
|
|
|
16
16
|
default: QueryArtifact;
|
|
17
17
|
}>;
|
|
18
18
|
loading: boolean;
|
|
19
|
-
variables: string
|
|
19
|
+
variables: Record<string, {
|
|
20
|
+
type: string;
|
|
21
|
+
}>;
|
|
20
22
|
}>;
|
|
21
23
|
component: () => Promise<{
|
|
22
24
|
default: (props: any) => _ComponentType;
|