houdini 1.0.0-next.0 → 1.0.0-next.2
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/generate.d.ts +0 -1
- package/build/cmd-cjs/index.js +409 -2066
- package/build/cmd-esm/index.js +409 -2066
- package/build/codegen/generators/artifacts/fieldKey.d.ts +1 -1
- package/build/codegen/generators/artifacts/index.d.ts +1 -1
- package/build/codegen/generators/artifacts/indexFile.d.ts +1 -1
- package/build/codegen/generators/artifacts/inputs.d.ts +2 -2
- package/build/codegen/generators/artifacts/operations.d.ts +2 -2
- package/build/codegen/generators/artifacts/selection.d.ts +1 -1
- package/build/codegen/generators/artifacts/utils.d.ts +1 -1
- package/build/codegen/generators/definitions/enums.d.ts +1 -1
- package/build/codegen/generators/definitions/index.d.ts +1 -1
- package/build/codegen/generators/indexFile/index.d.ts +1 -1
- package/build/codegen/generators/persistedQueries/index.d.ts +1 -1
- package/build/codegen/generators/runtime/graphqlFunction.d.ts +2 -0
- package/build/codegen/generators/runtime/index.d.ts +1 -1
- package/build/codegen/generators/runtime/injectPlugins.d.ts +7 -0
- package/build/codegen/generators/runtime/pluginIndex.d.ts +5 -0
- package/build/codegen/generators/typescript/addReferencedInputTypes.d.ts +1 -1
- package/build/codegen/generators/typescript/imperativeCache.d.ts +1 -1
- package/build/codegen/generators/typescript/index.d.ts +1 -1
- package/build/codegen/generators/typescript/inlineType.d.ts +1 -1
- package/build/codegen/generators/typescript/typeReference.d.ts +1 -1
- package/build/codegen/generators/typescript/types.d.ts +1 -1
- package/build/codegen/index.d.ts +1 -1
- package/build/codegen/transforms/addID.d.ts +1 -1
- package/build/codegen/transforms/composeQueries.d.ts +2 -2
- package/build/codegen/transforms/fragmentVariables.d.ts +2 -2
- package/build/codegen/transforms/list.d.ts +1 -1
- package/build/codegen/transforms/paginate.d.ts +1 -1
- package/build/codegen/transforms/schema.d.ts +1 -1
- package/build/codegen/transforms/typename.d.ts +1 -1
- package/build/codegen/utils/commonjs.d.ts +2 -0
- package/build/codegen/utils/flattenSelections.d.ts +2 -2
- package/build/codegen/utils/moduleExport.d.ts +1 -1
- package/build/codegen/utils/objectIdentificationSelection.d.ts +1 -1
- package/build/codegen/validators/noIDAlias.d.ts +1 -1
- package/build/codegen/validators/typeCheck.d.ts +1 -1
- package/build/codegen-cjs/index.js +330 -1977
- package/build/codegen-esm/index.js +330 -1977
- package/build/lib/config.d.ts +8 -3
- package/build/lib/fs.d.ts +1 -1
- package/build/lib/graphql.d.ts +1 -1
- package/build/lib/imports.d.ts +1 -1
- package/build/lib/types.d.ts +3 -3
- package/build/lib/walk.d.ts +4 -4
- package/build/lib-cjs/index.js +145 -1846
- package/build/lib-esm/index.js +145 -1846
- package/build/runtime/cache/cache.d.ts +10 -8
- package/build/runtime/cache/gc.d.ts +1 -1
- package/build/runtime/cache/lists.d.ts +2 -2
- package/build/runtime/cache/schema.d.ts +2 -2
- package/build/runtime/cache/stuff.d.ts +2 -2
- package/build/runtime/cache/subscription.d.ts +19 -11
- package/build/runtime/client/documentStore.d.ts +87 -0
- package/build/runtime/client/index.d.ts +25 -0
- package/build/runtime/client/plugins/cache.d.ts +8 -0
- package/build/runtime/client/plugins/fetch.d.ts +37 -0
- package/build/runtime/client/plugins/fetchParams.d.ts +9 -0
- package/build/runtime/client/plugins/index.d.ts +7 -0
- package/build/runtime/client/plugins/injectedPlugins.d.ts +3 -0
- package/build/runtime/client/plugins/mutation.d.ts +1 -0
- package/build/runtime/client/plugins/query.d.ts +2 -0
- package/build/runtime/client/plugins/subscription.d.ts +18 -0
- package/build/runtime/client/plugins/throwOnError.d.ts +7 -0
- package/build/runtime/client/utils/documentPlugins.d.ts +3 -0
- package/build/runtime/client/utils/index.d.ts +1 -0
- package/build/runtime/imports/config.d.ts +3 -0
- package/build/runtime/index.d.ts +2 -1
- package/build/runtime/lib/config.d.ts +5 -3
- package/build/runtime/lib/index.d.ts +1 -2
- package/build/runtime/lib/scalars.d.ts +5 -4
- package/build/runtime/lib/selection.d.ts +1 -1
- package/build/runtime/lib/store.d.ts +19 -0
- package/build/runtime/lib/types.d.ts +22 -9
- package/build/runtime/public/cache.d.ts +2 -2
- package/build/runtime/public/list.d.ts +2 -2
- package/build/runtime/public/record.d.ts +1 -1
- package/build/runtime/public/tests/test.d.ts +1 -1
- package/build/runtime-cjs/cache/cache.d.ts +10 -8
- package/build/runtime-cjs/cache/cache.js +5 -11
- package/build/runtime-cjs/cache/gc.d.ts +1 -1
- package/build/runtime-cjs/cache/lists.d.ts +2 -2
- package/build/runtime-cjs/cache/lists.js +2 -2
- package/build/runtime-cjs/cache/schema.d.ts +2 -2
- package/build/runtime-cjs/cache/stuff.d.ts +2 -2
- package/build/runtime-cjs/cache/subscription.d.ts +19 -11
- package/build/runtime-cjs/cache/subscription.js +95 -56
- package/build/runtime-cjs/client/documentStore.d.ts +87 -0
- package/build/runtime-cjs/client/documentStore.js +360 -0
- package/build/runtime-cjs/client/index.d.ts +25 -0
- package/build/runtime-cjs/client/index.js +87 -0
- package/build/runtime-cjs/client/plugins/cache.d.ts +8 -0
- package/build/runtime-cjs/client/plugins/cache.js +99 -0
- package/build/runtime-cjs/client/plugins/fetch.d.ts +37 -0
- package/build/runtime-cjs/{lib/networkUtils.js → client/plugins/fetch.js} +95 -3
- package/build/runtime-cjs/client/plugins/fetchParams.d.ts +9 -0
- package/build/runtime-cjs/client/plugins/fetchParams.js +40 -0
- package/build/runtime-cjs/client/plugins/index.d.ts +7 -0
- package/build/runtime-cjs/client/plugins/index.js +24 -0
- package/build/runtime-cjs/client/plugins/injectedPlugins.d.ts +3 -0
- package/build/runtime-cjs/{lib/errors.js → client/plugins/injectedPlugins.js} +7 -15
- package/build/runtime-cjs/client/plugins/mutation.d.ts +1 -0
- package/build/runtime-cjs/client/plugins/mutation.js +86 -0
- package/build/runtime-cjs/client/plugins/query.d.ts +2 -0
- package/build/runtime-cjs/client/plugins/query.js +83 -0
- package/build/runtime-cjs/client/plugins/subscription.d.ts +18 -0
- package/build/runtime-cjs/client/plugins/subscription.js +98 -0
- package/build/runtime-cjs/client/plugins/throwOnError.d.ts +7 -0
- package/build/runtime-cjs/client/plugins/throwOnError.js +47 -0
- package/build/runtime-cjs/client/utils/documentPlugins.d.ts +3 -0
- package/build/runtime-cjs/client/utils/documentPlugins.js +56 -0
- package/build/runtime-cjs/client/utils/index.d.ts +1 -0
- package/build/runtime-cjs/client/utils/index.js +18 -0
- package/build/runtime-cjs/imports/config.d.ts +3 -0
- package/build/runtime-cjs/imports/config.js +26 -0
- package/build/runtime-cjs/index.d.ts +2 -1
- package/build/runtime-cjs/index.js +1 -0
- package/build/runtime-cjs/lib/config.d.ts +5 -3
- package/build/runtime-cjs/lib/config.js +5 -4
- package/build/runtime-cjs/lib/index.d.ts +1 -2
- package/build/runtime-cjs/lib/index.js +1 -2
- package/build/runtime-cjs/lib/scalars.d.ts +5 -4
- package/build/runtime-cjs/lib/scalars.js +20 -24
- package/build/runtime-cjs/lib/selection.d.ts +1 -1
- package/build/runtime-cjs/lib/store.d.ts +19 -0
- package/build/runtime-cjs/lib/store.js +81 -0
- package/build/runtime-cjs/lib/types.d.ts +22 -9
- package/build/runtime-cjs/public/cache.d.ts +2 -2
- package/build/runtime-cjs/public/list.d.ts +2 -2
- package/build/runtime-cjs/public/list.js +2 -2
- package/build/runtime-cjs/public/record.d.ts +1 -1
- package/build/runtime-cjs/public/record.js +4 -4
- package/build/runtime-cjs/public/tests/test.d.ts +1 -1
- package/build/runtime-esm/cache/cache.d.ts +10 -8
- package/build/runtime-esm/cache/cache.js +5 -11
- package/build/runtime-esm/cache/gc.d.ts +1 -1
- package/build/runtime-esm/cache/lists.d.ts +2 -2
- package/build/runtime-esm/cache/lists.js +2 -2
- package/build/runtime-esm/cache/schema.d.ts +2 -2
- package/build/runtime-esm/cache/stuff.d.ts +2 -2
- package/build/runtime-esm/cache/subscription.d.ts +19 -11
- package/build/runtime-esm/cache/subscription.js +95 -56
- package/build/runtime-esm/client/documentStore.d.ts +87 -0
- package/build/runtime-esm/client/documentStore.js +336 -0
- package/build/runtime-esm/client/index.d.ts +25 -0
- package/build/runtime-esm/client/index.js +58 -0
- package/build/runtime-esm/client/plugins/cache.d.ts +8 -0
- package/build/runtime-esm/client/plugins/cache.js +69 -0
- package/build/runtime-esm/client/plugins/fetch.d.ts +37 -0
- package/build/runtime-esm/client/plugins/fetch.js +151 -0
- package/build/runtime-esm/client/plugins/fetchParams.d.ts +9 -0
- package/build/runtime-esm/client/plugins/fetchParams.js +16 -0
- package/build/runtime-esm/client/plugins/index.d.ts +7 -0
- package/build/runtime-esm/client/plugins/index.js +7 -0
- package/build/runtime-esm/client/plugins/injectedPlugins.d.ts +3 -0
- package/build/runtime-esm/client/plugins/injectedPlugins.js +5 -0
- package/build/runtime-esm/client/plugins/mutation.d.ts +1 -0
- package/build/runtime-esm/client/plugins/mutation.js +56 -0
- package/build/runtime-esm/client/plugins/query.d.ts +2 -0
- package/build/runtime-esm/client/plugins/query.js +53 -0
- package/build/runtime-esm/client/plugins/subscription.d.ts +18 -0
- package/build/runtime-esm/client/plugins/subscription.js +74 -0
- package/build/runtime-esm/client/plugins/throwOnError.d.ts +7 -0
- package/build/runtime-esm/client/plugins/throwOnError.js +23 -0
- package/build/runtime-esm/client/utils/documentPlugins.d.ts +3 -0
- package/build/runtime-esm/client/utils/documentPlugins.js +32 -0
- package/build/runtime-esm/client/utils/index.d.ts +1 -0
- package/build/runtime-esm/client/utils/index.js +1 -0
- package/build/runtime-esm/imports/config.d.ts +3 -0
- package/build/runtime-esm/imports/config.js +4 -0
- package/build/runtime-esm/index.d.ts +2 -1
- package/build/runtime-esm/index.js +1 -0
- package/build/runtime-esm/lib/config.d.ts +5 -3
- package/build/runtime-esm/lib/config.js +5 -4
- package/build/runtime-esm/lib/index.d.ts +1 -2
- package/build/runtime-esm/lib/index.js +1 -2
- package/build/runtime-esm/lib/scalars.d.ts +5 -4
- package/build/runtime-esm/lib/scalars.js +20 -24
- package/build/runtime-esm/lib/selection.d.ts +1 -1
- package/build/runtime-esm/lib/store.d.ts +19 -0
- package/build/runtime-esm/lib/store.js +57 -0
- package/build/runtime-esm/lib/types.d.ts +22 -9
- package/build/runtime-esm/public/cache.d.ts +2 -2
- package/build/runtime-esm/public/list.d.ts +2 -2
- package/build/runtime-esm/public/list.js +1 -1
- package/build/runtime-esm/public/record.d.ts +1 -1
- package/build/runtime-esm/public/record.js +1 -1
- package/build/runtime-esm/public/tests/test.d.ts +1 -1
- package/build/test/index.d.ts +4 -3
- package/build/test-cjs/index.js +336 -1955
- package/build/test-esm/index.js +336 -1955
- package/build/vite/ast.d.ts +1 -1
- package/build/vite/houdini.d.ts +1 -1
- package/build/vite/imports.d.ts +3 -3
- package/build/vite/index.d.ts +1 -1
- package/build/vite/schema.d.ts +1 -1
- package/build/vite-cjs/index.js +396 -2010
- package/build/vite-esm/index.js +396 -2010
- package/package.json +1 -1
- package/build/runtime/lib/errors.d.ts +0 -3
- package/build/runtime/lib/network.d.ts +0 -79
- package/build/runtime/lib/networkUtils.d.ts +0 -8
- package/build/runtime-cjs/lib/errors.d.ts +0 -3
- package/build/runtime-cjs/lib/network.d.ts +0 -79
- package/build/runtime-cjs/lib/network.js +0 -200
- package/build/runtime-cjs/lib/networkUtils.d.ts +0 -8
- package/build/runtime-esm/lib/errors.d.ts +0 -3
- package/build/runtime-esm/lib/errors.js +0 -11
- package/build/runtime-esm/lib/network.d.ts +0 -79
- package/build/runtime-esm/lib/network.js +0 -170
- package/build/runtime-esm/lib/networkUtils.d.ts +0 -8
- package/build/runtime-esm/lib/networkUtils.js +0 -60
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { ConfigFile } from '../lib/config';
|
|
2
|
-
import { GraphQLObject, GraphQLValue, SubscriptionSelection, SubscriptionSpec } from '../lib/types';
|
|
1
|
+
import type { ConfigFile } from '../lib/config';
|
|
2
|
+
import type { GraphQLObject, GraphQLValue, SubscriptionSelection, SubscriptionSpec } from '../lib/types';
|
|
3
3
|
import { GarbageCollector } from './gc';
|
|
4
|
-
import { ListCollection
|
|
4
|
+
import type { ListCollection } from './lists';
|
|
5
|
+
import { ListManager } from './lists';
|
|
5
6
|
import { SchemaManager } from './schema';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
7
|
+
import type { Layer, LayerID } from './storage';
|
|
8
|
+
import { InMemoryStorage } from './storage';
|
|
9
|
+
import { type FieldSelection, InMemorySubscriptions } from './subscription';
|
|
8
10
|
export declare class Cache {
|
|
9
11
|
_internal_unstable: CacheInternal;
|
|
10
12
|
constructor(config?: ConfigFile);
|
|
@@ -59,10 +61,10 @@ declare class CacheInternal {
|
|
|
59
61
|
parent?: string;
|
|
60
62
|
root?: string;
|
|
61
63
|
layer: Layer;
|
|
62
|
-
toNotify?:
|
|
64
|
+
toNotify?: FieldSelection[];
|
|
63
65
|
applyUpdates?: boolean;
|
|
64
66
|
forceNotify?: boolean;
|
|
65
|
-
}):
|
|
67
|
+
}): FieldSelection[];
|
|
66
68
|
getSelection({ selection, parent, variables, stepsFromConnection, }: {
|
|
67
69
|
selection: SubscriptionSelection;
|
|
68
70
|
parent?: string;
|
|
@@ -94,7 +96,7 @@ declare class CacheInternal {
|
|
|
94
96
|
linkedType: string;
|
|
95
97
|
abstract: boolean;
|
|
96
98
|
variables: {};
|
|
97
|
-
specs:
|
|
99
|
+
specs: FieldSelection[];
|
|
98
100
|
applyUpdates: boolean;
|
|
99
101
|
fields: SubscriptionSelection;
|
|
100
102
|
layer: Layer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SubscriptionSelection, ListWhen, SubscriptionSpec } from '../lib/types';
|
|
2
|
-
import { Cache } from './cache';
|
|
1
|
+
import type { SubscriptionSelection, ListWhen, SubscriptionSpec } from '../lib/types';
|
|
2
|
+
import type { Cache } from './cache';
|
|
3
3
|
export declare class ListManager {
|
|
4
4
|
rootID: string;
|
|
5
5
|
cache: Cache;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GraphQLValue } from '../lib/types';
|
|
2
|
-
import { LinkedList } from './cache';
|
|
1
|
+
import type { GraphQLValue } from '../lib/types';
|
|
2
|
+
import type { LinkedList } from './cache';
|
|
3
3
|
export declare function flattenList<T>(source: LinkedList<T>): T[];
|
|
4
4
|
export declare function evaluateKey(key: string, variables?: {
|
|
5
5
|
[key: string]: GraphQLValue;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
1
|
+
import type { GraphQLValue, SubscriptionSelection, SubscriptionSpec } from '../lib/types';
|
|
2
|
+
import type { Cache } from './cache';
|
|
3
|
+
export type FieldSelection = [
|
|
4
|
+
SubscriptionSpec,
|
|
5
|
+
Required<SubscriptionSelection>['fields'] | undefined
|
|
6
|
+
];
|
|
4
7
|
export declare class InMemorySubscriptions {
|
|
5
8
|
private cache;
|
|
6
9
|
constructor(cache: Cache);
|
|
@@ -16,22 +19,27 @@ export declare class InMemorySubscriptions {
|
|
|
16
19
|
[key: string]: GraphQLValue;
|
|
17
20
|
};
|
|
18
21
|
}): void;
|
|
19
|
-
addFieldSubscription({ id, key,
|
|
22
|
+
addFieldSubscription({ id, key, selection, }: {
|
|
20
23
|
id: string;
|
|
21
24
|
key: string;
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
selection: FieldSelection;
|
|
26
|
+
}): void;
|
|
27
|
+
registerList({ list, id, key, parentType, selection, filters, variables, }: {
|
|
28
|
+
list: Required<Required<SubscriptionSelection>['fields'][string]>['list'];
|
|
29
|
+
selection: SubscriptionSelection;
|
|
30
|
+
id: string;
|
|
24
31
|
parentType: string;
|
|
25
|
-
|
|
32
|
+
key: string;
|
|
33
|
+
filters: Required<SubscriptionSelection>['fields'][string]['filters'];
|
|
34
|
+
variables: Record<string, any>;
|
|
26
35
|
}): void;
|
|
27
|
-
addMany({ parent,
|
|
36
|
+
addMany({ parent, variables, subscribers, parentType, }: {
|
|
28
37
|
parent: string;
|
|
29
|
-
selection: SubscriptionSelection;
|
|
30
38
|
variables: {};
|
|
31
|
-
subscribers:
|
|
39
|
+
subscribers: FieldSelection[];
|
|
32
40
|
parentType: string;
|
|
33
41
|
}): void;
|
|
34
|
-
get(id: string, field: string):
|
|
42
|
+
get(id: string, field: string): FieldSelection[];
|
|
35
43
|
remove(id: string, selection: SubscriptionSelection, targets: SubscriptionSpec[], variables: {}, visited?: string[]): void;
|
|
36
44
|
private removeSubscribers;
|
|
37
45
|
removeAllSubscribers(id: string, targets?: SubscriptionSpec[], visited?: string[]): void;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { HoudiniClient } from '.';
|
|
2
|
+
import type { Layer } from '../cache/storage';
|
|
3
|
+
import type { ConfigFile } from '../lib/config';
|
|
4
|
+
import { Writable } from '../lib/store';
|
|
5
|
+
import type { CachePolicy, DocumentArtifact, QueryResult, GraphQLObject, SubscriptionSpec } from '../lib/types';
|
|
6
|
+
export declare class DocumentStore<_Data extends GraphQLObject, _Input extends Record<string, any>> extends Writable<QueryResult<_Data, _Input>> {
|
|
7
|
+
#private;
|
|
8
|
+
constructor({ artifact, plugins, pipeline, client, cache, initialValue, fetching, }: {
|
|
9
|
+
artifact: DocumentArtifact;
|
|
10
|
+
plugins?: ClientPlugin[];
|
|
11
|
+
pipeline?: ClientPlugin[];
|
|
12
|
+
client: HoudiniClient;
|
|
13
|
+
cache?: boolean;
|
|
14
|
+
initialValue?: _Data | null;
|
|
15
|
+
fetching?: boolean;
|
|
16
|
+
});
|
|
17
|
+
send({ metadata, session, fetch, variables, policy, stuff, cacheParams, setup, }?: {
|
|
18
|
+
fetch?: Fetch;
|
|
19
|
+
variables?: Record<string, any> | null;
|
|
20
|
+
metadata?: App.Metadata | null;
|
|
21
|
+
session?: App.Session | null;
|
|
22
|
+
policy?: CachePolicy;
|
|
23
|
+
stuff?: Partial<App.Stuff>;
|
|
24
|
+
cacheParams?: ClientPluginContext['cacheParams'];
|
|
25
|
+
setup?: boolean;
|
|
26
|
+
}): Promise<QueryResult<_Data, _Input>>;
|
|
27
|
+
}
|
|
28
|
+
declare function marshalVariables<_Data extends GraphQLObject, _Input extends {}>(ctx: ClientPluginContext): Record<string, any>;
|
|
29
|
+
export type ClientPlugin = () => {
|
|
30
|
+
start?: ClientPluginEnterPhase;
|
|
31
|
+
beforeNetwork?: ClientPluginEnterPhase;
|
|
32
|
+
network?: ClientPluginEnterPhase;
|
|
33
|
+
afterNetwork?: ClientPluginExitPhase;
|
|
34
|
+
end?: ClientPluginExitPhase;
|
|
35
|
+
cleanup?(ctx: ClientPluginContext): void | Promise<void>;
|
|
36
|
+
catch?(ctx: ClientPluginContext, args: ClientPluginErrorHandlers): void | Promise<void>;
|
|
37
|
+
};
|
|
38
|
+
export type Fetch = typeof globalThis.fetch;
|
|
39
|
+
export type ClientPluginContext = {
|
|
40
|
+
config: ConfigFile;
|
|
41
|
+
text: string;
|
|
42
|
+
hash: string;
|
|
43
|
+
artifact: DocumentArtifact;
|
|
44
|
+
policy?: CachePolicy;
|
|
45
|
+
fetch?: Fetch;
|
|
46
|
+
variables?: Record<string, any>;
|
|
47
|
+
metadata?: App.Metadata | null;
|
|
48
|
+
session?: App.Session | null;
|
|
49
|
+
fetchParams?: RequestInit;
|
|
50
|
+
cacheParams?: {
|
|
51
|
+
layer?: Layer;
|
|
52
|
+
notifySubscribers?: SubscriptionSpec[];
|
|
53
|
+
forceNotify?: boolean;
|
|
54
|
+
disableWrite?: boolean;
|
|
55
|
+
disableRead?: boolean;
|
|
56
|
+
applyUpdates?: boolean;
|
|
57
|
+
};
|
|
58
|
+
stuff: App.Stuff;
|
|
59
|
+
};
|
|
60
|
+
type ClientPluginPhase<Handlers> = (ctx: ClientPluginContext, handlers: Handlers) => void | Promise<void>;
|
|
61
|
+
export type ClientPluginEnterPhase = ClientPluginPhase<ClientPluginEnterHandlers>;
|
|
62
|
+
export type ClientPluginExitPhase = ClientPluginPhase<ClientPluginExitHandlers>;
|
|
63
|
+
export type ClientPluginEnterHandlers = {
|
|
64
|
+
initialValue: QueryResult;
|
|
65
|
+
/** A reference to the houdini client to access any configuration values */
|
|
66
|
+
client: HoudiniClient;
|
|
67
|
+
/** Move onto the next step using the provided context. */
|
|
68
|
+
next(ctx: ClientPluginContext): void;
|
|
69
|
+
/** Terminate the current chain */
|
|
70
|
+
resolve(ctx: ClientPluginContext, data: QueryResult): void;
|
|
71
|
+
/** Update the stores state without resolving the promise */
|
|
72
|
+
updateState(updater: (old: QueryResult) => QueryResult): void;
|
|
73
|
+
/** Return true if the variables have changed */
|
|
74
|
+
variablesChanged: (ctx: ClientPluginContext) => boolean;
|
|
75
|
+
/** Returns the marshaled variables for the operation */
|
|
76
|
+
marshalVariables: typeof marshalVariables;
|
|
77
|
+
};
|
|
78
|
+
/** Exit handlers are the same as enter handles but don't need to resolve with a specific value */
|
|
79
|
+
export type ClientPluginExitHandlers = Omit<ClientPluginEnterHandlers, 'resolve'> & {
|
|
80
|
+
resolve: (ctx: ClientPluginContext, data?: QueryResult) => void;
|
|
81
|
+
value: QueryResult;
|
|
82
|
+
};
|
|
83
|
+
/** Exit handlers are the same as enter handles but don't need to resolve with a specific value */
|
|
84
|
+
export type ClientPluginErrorHandlers = ClientPluginEnterHandlers & {
|
|
85
|
+
error: unknown;
|
|
86
|
+
};
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference path="../../../../../houdini.d.ts" />
|
|
2
|
+
import type { DocumentArtifact, GraphQLObject } from '../lib/types';
|
|
3
|
+
import type { ClientPlugin } from './documentStore';
|
|
4
|
+
import { DocumentStore } from './documentStore';
|
|
5
|
+
import { type FetchParamFn, type ThrowOnErrorParams } from './plugins';
|
|
6
|
+
export { DocumentStore, type ClientPlugin } from './documentStore';
|
|
7
|
+
export { fetchPlugin, mutationPlugin, queryPlugin, subscriptionPlugin } from './plugins';
|
|
8
|
+
type ConstructorArgs = {
|
|
9
|
+
url: string;
|
|
10
|
+
fetchParams?: FetchParamFn;
|
|
11
|
+
plugins?: ClientPlugin[];
|
|
12
|
+
pipeline?: ClientPlugin[];
|
|
13
|
+
throwOnError?: ThrowOnErrorParams;
|
|
14
|
+
};
|
|
15
|
+
export declare class HoudiniClient {
|
|
16
|
+
#private;
|
|
17
|
+
url: string;
|
|
18
|
+
constructor({ url, fetchParams, plugins, pipeline, throwOnError }: ConstructorArgs);
|
|
19
|
+
observe<_Data extends GraphQLObject, _Input extends Record<string, any>>({ artifact, cache, initialValue, fetching, }: {
|
|
20
|
+
artifact: DocumentArtifact;
|
|
21
|
+
cache?: boolean;
|
|
22
|
+
initialValue?: _Data | null;
|
|
23
|
+
fetching?: boolean;
|
|
24
|
+
}): DocumentStore<_Data, _Input>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import cache from '../../cache';
|
|
2
|
+
import type { Cache } from '../../cache/cache';
|
|
3
|
+
import type { ClientPlugin } from '../documentStore';
|
|
4
|
+
export declare const cachePolicyPlugin: ({ enabled, setFetching, cache: localCache, }: {
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
setFetching: (val: boolean) => void;
|
|
7
|
+
cache?: Cache | undefined;
|
|
8
|
+
}) => ClientPlugin;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { RequestPayload } from '../../lib/types';
|
|
2
|
+
import type { ClientPlugin } from '../documentStore';
|
|
3
|
+
export declare const fetchPlugin: (target?: RequestHandler | string) => ClientPlugin;
|
|
4
|
+
export type FetchContext = {
|
|
5
|
+
fetch: typeof globalThis.fetch;
|
|
6
|
+
metadata?: App.Metadata | null;
|
|
7
|
+
session: App.Session | null;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* ## Tip 👇
|
|
11
|
+
*
|
|
12
|
+
* To define types for your metadata, create a file `src/app.d.ts` containing the followingI:
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* declare namespace App { *
|
|
16
|
+
* interface Metadata {}
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
export type RequestHandlerArgs = FetchContext & FetchParams;
|
|
22
|
+
export type RequestHandler<_Data = any> = (args: RequestHandlerArgs) => Promise<RequestPayload<_Data>>;
|
|
23
|
+
export type FetchParams = {
|
|
24
|
+
text: string;
|
|
25
|
+
hash: string;
|
|
26
|
+
variables: {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export declare function isExtractableFile(value: any): value is ExtractableFile;
|
|
31
|
+
type ExtractableFile = File | Blob;
|
|
32
|
+
/** @typedef {import("./isExtractableFile.mjs").default} isExtractableFile */
|
|
33
|
+
export declare function extractFiles(value: any): {
|
|
34
|
+
clone: any;
|
|
35
|
+
files: Map<any, any>;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DocumentArtifact } from '../../lib/types';
|
|
2
|
+
import type { ClientPlugin, ClientPluginContext } from '../documentStore';
|
|
3
|
+
export type FetchParamFn = (ctx: FetchParamsInput) => Required<ClientPluginContext>['fetchParams'];
|
|
4
|
+
export declare const fetchParamsPlugin: (fn?: FetchParamFn) => ClientPlugin;
|
|
5
|
+
export type FetchParamsInput = Pick<ClientPluginContext, 'config' | 'policy' | 'variables' | 'metadata' | 'session' | 'stuff'> & {
|
|
6
|
+
text: string;
|
|
7
|
+
hash: string;
|
|
8
|
+
artifact: DocumentArtifact;
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mutationPlugin: import("..").ClientPlugin;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { GraphQLObject } from '../../lib/types';
|
|
2
|
+
import type { ClientPluginContext } from '../documentStore';
|
|
3
|
+
export declare function subscriptionPlugin(factory: SubscriptionHandler): import("../documentStore").ClientPlugin;
|
|
4
|
+
export type SubscriptionHandler = (ctx: ClientPluginContext) => {
|
|
5
|
+
subscribe: (payload: {
|
|
6
|
+
query: string;
|
|
7
|
+
variables?: {};
|
|
8
|
+
}, handlers: {
|
|
9
|
+
next: (payload: {
|
|
10
|
+
data?: GraphQLObject;
|
|
11
|
+
errors?: readonly {
|
|
12
|
+
message: string;
|
|
13
|
+
}[];
|
|
14
|
+
}) => void;
|
|
15
|
+
error: (data: {}) => void;
|
|
16
|
+
complete: () => void;
|
|
17
|
+
}) => () => void;
|
|
18
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { QueryResult } from '../../lib';
|
|
2
|
+
import type { ClientPlugin } from '../documentStore';
|
|
3
|
+
export type ThrowOnErrorParams = {
|
|
4
|
+
operations: ('all' | 'query' | 'mutation' | 'subscription')[];
|
|
5
|
+
error?: (errors: NonNullable<QueryResult<any, any>['errors']>) => unknown;
|
|
6
|
+
};
|
|
7
|
+
export declare const throwOnErrorPlugin: ({ operations, error }: ThrowOnErrorParams) => ClientPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './documentPlugins';
|
package/build/runtime/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Cache as InternalCache } from './cache/cache';
|
|
1
|
+
import type { Cache as InternalCache } from './cache/cache';
|
|
2
2
|
import type { CacheTypeDef } from './generated';
|
|
3
3
|
import { Cache } from './public';
|
|
4
|
+
export * from './client';
|
|
4
5
|
export * from './lib';
|
|
5
6
|
export declare function graphql(str: string | TemplateStringsArray): any;
|
|
6
7
|
export declare const cache: Cache<CacheTypeDef>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { GraphQLSchema } from 'graphql';
|
|
2
|
-
import { CachePolicy } from './types';
|
|
1
|
+
import type { GraphQLSchema } from 'graphql';
|
|
2
|
+
import type { CachePolicy } from './types';
|
|
3
3
|
export declare function getMockConfig(): ConfigFile | null;
|
|
4
4
|
export declare function setMockConfig(config: ConfigFile | null): void;
|
|
5
5
|
export declare function defaultConfigValues(file: ConfigFile): ConfigFile;
|
|
6
6
|
export declare function keyFieldsForType(configFile: ConfigFile, type: string): string[];
|
|
7
7
|
export declare function computeID(configFile: ConfigFile, type: string, data: any): string;
|
|
8
|
-
export declare function getCurrentConfig():
|
|
8
|
+
export declare function getCurrentConfig(): ConfigFile;
|
|
9
9
|
export type ConfigFile = {
|
|
10
10
|
/**
|
|
11
11
|
* A glob pointing to all files that houdini should consider. Note, this must include .js files
|
|
@@ -140,4 +140,6 @@ export type ScalarSpec = {
|
|
|
140
140
|
};
|
|
141
141
|
export interface HoudiniPluginConfig {
|
|
142
142
|
}
|
|
143
|
+
export interface HoudiniClientPluginConfig {
|
|
144
|
+
}
|
|
143
145
|
export {};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { ConfigFile } from './config';
|
|
2
|
-
import { MutationArtifact, QueryArtifact, SubscriptionArtifact, SubscriptionSelection } from './types';
|
|
1
|
+
import type { ConfigFile } from './config';
|
|
2
|
+
import type { MutationArtifact, QueryArtifact, SubscriptionArtifact, SubscriptionSelection } from './types';
|
|
3
3
|
export declare function marshalSelection({ selection, data, }: {
|
|
4
4
|
selection: SubscriptionSelection;
|
|
5
5
|
data: any;
|
|
6
6
|
}): Promise<{} | null | undefined>;
|
|
7
|
-
export declare function marshalInputs<T>({ artifact, input, rootType, }: {
|
|
7
|
+
export declare function marshalInputs<T>({ artifact, input, config, rootType, }: {
|
|
8
8
|
artifact: QueryArtifact | MutationArtifact | SubscriptionArtifact;
|
|
9
9
|
input: unknown;
|
|
10
10
|
rootType?: string;
|
|
11
|
-
|
|
11
|
+
config: ConfigFile;
|
|
12
|
+
}): {} | null | undefined;
|
|
12
13
|
export declare function unmarshalSelection(config: ConfigFile, selection: SubscriptionSelection, data: any): {} | null | undefined;
|
|
13
14
|
export declare function isScalar(config: ConfigFile, type: string): boolean;
|
|
14
15
|
export declare function parseScalar(config: ConfigFile, type: string, value: string): string | number | boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SubscriptionSelection } from './types';
|
|
1
|
+
import type { SubscriptionSelection } from './types';
|
|
2
2
|
export declare function getFieldsForType(selection: SubscriptionSelection, __typename: string | undefined | null): Required<SubscriptionSelection>['fields'];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare class Writable<T> {
|
|
2
|
+
#private;
|
|
3
|
+
state: T;
|
|
4
|
+
constructor(value: T, start?: StartStopNotifier<T>);
|
|
5
|
+
set(new_value: T): void;
|
|
6
|
+
update(fn: Updater<T>): void;
|
|
7
|
+
subscribe(run: Subscriber<T>, invalidate?: Invalidator<T>): Unsubscriber;
|
|
8
|
+
}
|
|
9
|
+
/** Start and stop notification callbacks. */
|
|
10
|
+
type StartStopNotifier<T> = (set: Subscriber<T>) => Unsubscriber | void;
|
|
11
|
+
/** Callback to inform of a value updates. */
|
|
12
|
+
export type Subscriber<T> = (value: T) => void;
|
|
13
|
+
/** Unsubscribes from value updates. */
|
|
14
|
+
export type Unsubscriber = () => void;
|
|
15
|
+
/** Callback to update a value. */
|
|
16
|
+
type Updater<T> = (value: T) => T;
|
|
17
|
+
/** Cleanup logic callback. */
|
|
18
|
+
type Invalidator<T> = (value?: T) => void;
|
|
19
|
+
export {};
|
|
@@ -4,6 +4,22 @@ export declare enum CachePolicy {
|
|
|
4
4
|
NetworkOnly = "NetworkOnly",
|
|
5
5
|
CacheAndNetwork = "CacheAndNetwork"
|
|
6
6
|
}
|
|
7
|
+
declare global {
|
|
8
|
+
namespace App {
|
|
9
|
+
interface Session {
|
|
10
|
+
}
|
|
11
|
+
interface Metadata {
|
|
12
|
+
}
|
|
13
|
+
interface Stuff {
|
|
14
|
+
inputs: {
|
|
15
|
+
init: boolean;
|
|
16
|
+
marshaled: Record<string, any>;
|
|
17
|
+
changed: boolean;
|
|
18
|
+
};
|
|
19
|
+
optimisticResponse?: GraphQLObject;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
7
23
|
export type Fragment<_Result> = {
|
|
8
24
|
readonly shape?: _Result;
|
|
9
25
|
};
|
|
@@ -65,6 +81,7 @@ export type BaseCompiledDocument = {
|
|
|
65
81
|
paginated: boolean;
|
|
66
82
|
direction?: 'forward' | 'backwards';
|
|
67
83
|
};
|
|
84
|
+
pluginsData?: Record<string, any>;
|
|
68
85
|
};
|
|
69
86
|
export type HoudiniFetchContext = {
|
|
70
87
|
variables: () => {};
|
|
@@ -150,7 +167,7 @@ export type FetchQueryResult<_Data> = {
|
|
|
150
167
|
source: DataSource | null;
|
|
151
168
|
partial: boolean;
|
|
152
169
|
};
|
|
153
|
-
export type QueryResult<_Data, _Input
|
|
170
|
+
export type QueryResult<_Data = GraphQLObject, _Input = Record<string, any>> = {
|
|
154
171
|
data: _Data | null;
|
|
155
172
|
errors: {
|
|
156
173
|
message: string;
|
|
@@ -158,16 +175,12 @@ export type QueryResult<_Data, _Input, _Extra = {}> = {
|
|
|
158
175
|
fetching: boolean;
|
|
159
176
|
partial: boolean;
|
|
160
177
|
source: DataSource | null;
|
|
161
|
-
variables: _Input;
|
|
162
|
-
}
|
|
163
|
-
export type RequestPayload<
|
|
164
|
-
data:
|
|
178
|
+
variables: _Input | null;
|
|
179
|
+
};
|
|
180
|
+
export type RequestPayload<GraphQLObject = any> = {
|
|
181
|
+
data: GraphQLObject | null;
|
|
165
182
|
errors: {
|
|
166
183
|
message: string;
|
|
167
184
|
}[] | null;
|
|
168
185
|
};
|
|
169
|
-
export type RequestPayloadMagic<_Data = any> = {
|
|
170
|
-
ssr: boolean;
|
|
171
|
-
body: RequestPayload<_Data>;
|
|
172
|
-
};
|
|
173
186
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Cache as _Cache } from '../cache/cache';
|
|
2
|
-
import { SchemaManager, TypeInfo } from '../cache/schema';
|
|
1
|
+
import type { Cache as _Cache } from '../cache/cache';
|
|
2
|
+
import type { SchemaManager, TypeInfo } from '../cache/schema';
|
|
3
3
|
import { ListCollection } from './list';
|
|
4
4
|
import { Record } from './record';
|
|
5
5
|
import type { CacheTypeDef, IDFields, TypeNames, ValidLists } from './types';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Cache } from './cache';
|
|
2
|
-
import { CacheTypeDef, ListType, ValidLists, ListFilters } from './types';
|
|
1
|
+
import type { Cache } from './cache';
|
|
2
|
+
import type { CacheTypeDef, ListType, ValidLists, ListFilters } from './types';
|
|
3
3
|
export declare class ListCollection<Def extends CacheTypeDef, ListName extends ValidLists<Def>> {
|
|
4
4
|
#private;
|
|
5
5
|
constructor({ parentID, allLists, when, cache, name, }: {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { ConfigFile } from '../lib/config';
|
|
2
|
-
import { GraphQLObject, GraphQLValue, SubscriptionSelection, SubscriptionSpec } from '../lib/types';
|
|
1
|
+
import type { ConfigFile } from '../lib/config';
|
|
2
|
+
import type { GraphQLObject, GraphQLValue, SubscriptionSelection, SubscriptionSpec } from '../lib/types';
|
|
3
3
|
import { GarbageCollector } from './gc';
|
|
4
|
-
import { ListCollection
|
|
4
|
+
import type { ListCollection } from './lists';
|
|
5
|
+
import { ListManager } from './lists';
|
|
5
6
|
import { SchemaManager } from './schema';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
7
|
+
import type { Layer, LayerID } from './storage';
|
|
8
|
+
import { InMemoryStorage } from './storage';
|
|
9
|
+
import { type FieldSelection, InMemorySubscriptions } from './subscription';
|
|
8
10
|
export declare class Cache {
|
|
9
11
|
_internal_unstable: CacheInternal;
|
|
10
12
|
constructor(config?: ConfigFile);
|
|
@@ -59,10 +61,10 @@ declare class CacheInternal {
|
|
|
59
61
|
parent?: string;
|
|
60
62
|
root?: string;
|
|
61
63
|
layer: Layer;
|
|
62
|
-
toNotify?:
|
|
64
|
+
toNotify?: FieldSelection[];
|
|
63
65
|
applyUpdates?: boolean;
|
|
64
66
|
forceNotify?: boolean;
|
|
65
|
-
}):
|
|
67
|
+
}): FieldSelection[];
|
|
66
68
|
getSelection({ selection, parent, variables, stepsFromConnection, }: {
|
|
67
69
|
selection: SubscriptionSelection;
|
|
68
70
|
parent?: string;
|
|
@@ -94,7 +96,7 @@ declare class CacheInternal {
|
|
|
94
96
|
linkedType: string;
|
|
95
97
|
abstract: boolean;
|
|
96
98
|
variables: {};
|
|
97
|
-
specs:
|
|
99
|
+
specs: FieldSelection[];
|
|
98
100
|
applyUpdates: boolean;
|
|
99
101
|
fields: SubscriptionSelection;
|
|
100
102
|
layer: Layer;
|
|
@@ -52,7 +52,7 @@ class Cache {
|
|
|
52
52
|
...args
|
|
53
53
|
}) {
|
|
54
54
|
const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
|
|
55
|
-
const subscribers = this._internal_unstable.writeSelection({ ...args, layer });
|
|
55
|
+
const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
|
|
56
56
|
const notified = [];
|
|
57
57
|
for (const spec of subscribers.concat(notifySubscribers)) {
|
|
58
58
|
if (!notified.includes(spec.set)) {
|
|
@@ -190,6 +190,7 @@ class CacheInternal {
|
|
|
190
190
|
link: !!fieldSelection
|
|
191
191
|
});
|
|
192
192
|
const currentSubscribers = this.subscriptions.get(parent, key);
|
|
193
|
+
const specs = currentSubscribers.map((sub) => sub[0]);
|
|
193
194
|
const { value: previousValue, displayLayers } = this.storage.get(parent, key);
|
|
194
195
|
const displayLayer = layer.isDisplayLayer(displayLayers);
|
|
195
196
|
if (displayLayer) {
|
|
@@ -215,7 +216,7 @@ class CacheInternal {
|
|
|
215
216
|
}
|
|
216
217
|
const previousLinks = (0, import_stuff.flattenList)([previousValue]);
|
|
217
218
|
for (const link of previousLinks) {
|
|
218
|
-
this.subscriptions.remove(link, fieldSelection,
|
|
219
|
+
this.subscriptions.remove(link, fieldSelection, specs, variables);
|
|
219
220
|
}
|
|
220
221
|
layer.writeLink(parent, key, null);
|
|
221
222
|
toNotify.push(...currentSubscribers);
|
|
@@ -239,16 +240,10 @@ class CacheInternal {
|
|
|
239
240
|
layer.writeLink(parent, key, linkedID);
|
|
240
241
|
if (linkedID && displayLayer && (linkChange || forceNotify)) {
|
|
241
242
|
if (previousValue && typeof previousValue === "string") {
|
|
242
|
-
this.subscriptions.remove(
|
|
243
|
-
previousValue,
|
|
244
|
-
fieldSelection,
|
|
245
|
-
currentSubscribers,
|
|
246
|
-
variables
|
|
247
|
-
);
|
|
243
|
+
this.subscriptions.remove(previousValue, fieldSelection, specs, variables);
|
|
248
244
|
}
|
|
249
245
|
this.subscriptions.addMany({
|
|
250
246
|
parent: linkedID,
|
|
251
|
-
selection: fieldSelection,
|
|
252
247
|
subscribers: currentSubscribers,
|
|
253
248
|
variables,
|
|
254
249
|
parentType: linkedType
|
|
@@ -343,7 +338,7 @@ class CacheInternal {
|
|
|
343
338
|
if (linkedIDs.includes(lostID) || !lostID) {
|
|
344
339
|
continue;
|
|
345
340
|
}
|
|
346
|
-
this.subscriptions.remove(lostID, fieldSelection,
|
|
341
|
+
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
347
342
|
}
|
|
348
343
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
349
344
|
layer.writeLink(parent, key, linkedIDs);
|
|
@@ -354,7 +349,6 @@ class CacheInternal {
|
|
|
354
349
|
}
|
|
355
350
|
this.subscriptions.addMany({
|
|
356
351
|
parent: id,
|
|
357
|
-
selection: fieldSelection,
|
|
358
352
|
subscribers: currentSubscribers,
|
|
359
353
|
variables,
|
|
360
354
|
parentType: linkedType
|