houdini 1.0.0-next.2 → 1.0.0-next.21
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/README.md +4 -1
- package/build/cmd-cjs/index.js +5366 -2772
- package/build/cmd-esm/index.js +5340 -2746
- package/build/codegen/generators/artifacts/index.d.ts +2 -2
- package/build/codegen/generators/artifacts/indexFile.d.ts +2 -2
- package/build/codegen/generators/artifacts/selection.d.ts +5 -5
- package/build/codegen/generators/artifacts/utils.d.ts +0 -1
- package/build/codegen/generators/indexFile/index.d.ts +2 -2
- package/build/codegen/generators/persistedQueries/index.d.ts +2 -2
- package/build/codegen/generators/runtime/graphqlFunction.d.ts +2 -2
- package/build/codegen/generators/runtime/index.d.ts +2 -2
- package/build/codegen/generators/runtime/runtimeConfig.d.ts +7 -0
- package/build/codegen/generators/typescript/documentTypes.d.ts +2 -0
- package/build/codegen/generators/typescript/imperativeTypeDef.d.ts +2 -0
- package/build/codegen/generators/typescript/index.d.ts +2 -2
- package/build/codegen/generators/typescript/typeReference.d.ts +4 -2
- package/build/codegen/generators/typescript/types.d.ts +0 -1
- package/build/codegen/index.d.ts +2 -2
- package/build/codegen/transforms/addID.d.ts +2 -2
- package/build/codegen/transforms/composeQueries.d.ts +4 -4
- package/build/codegen/transforms/fragmentVariables.d.ts +3 -2
- package/build/codegen/transforms/list.d.ts +2 -2
- package/build/codegen/transforms/paginate.d.ts +2 -2
- package/build/codegen/transforms/schema.d.ts +2 -2
- package/build/codegen/transforms/typename.d.ts +2 -2
- package/build/codegen/utils/flattenSelections.d.ts +1 -1
- package/build/codegen/validators/noIDAlias.d.ts +2 -2
- package/build/codegen/validators/plugins.d.ts +2 -2
- package/build/codegen/validators/typeCheck.d.ts +2 -2
- package/build/codegen/validators/uniqueNames.d.ts +2 -2
- package/build/codegen-cjs/index.js +4694 -2137
- package/build/codegen-esm/index.js +4682 -2125
- package/build/lib/config.d.ts +15 -96
- package/build/lib/deepMerge.d.ts +1 -0
- package/build/lib/graphql.d.ts +5 -2
- package/build/lib/index.d.ts +2 -0
- package/build/lib/path.d.ts +1 -1
- package/build/lib/pipeline.d.ts +1 -1
- package/build/lib/plugin.d.ts +2 -0
- package/build/lib/types.d.ts +257 -6
- package/build/lib/walk.d.ts +4 -1
- package/build/lib-cjs/index.js +4108 -928
- package/build/lib-esm/index.js +4078 -907
- package/build/runtime/cache/cache.d.ts +28 -11
- package/build/runtime/cache/lists.d.ts +1 -0
- package/build/runtime/cache/staleManager.d.ts +30 -0
- package/build/runtime/cache/storage.d.ts +23 -20
- package/build/runtime/cache/stuff.d.ts +0 -2
- package/build/runtime/cache/subscription.d.ts +2 -1
- package/build/runtime/client/documentStore.d.ts +20 -17
- package/build/runtime/client/index.d.ts +13 -11
- package/build/runtime/client/plugins/cache.d.ts +1 -1
- package/build/runtime/client/plugins/fetch.d.ts +1 -1
- package/build/runtime/client/plugins/fetchParams.d.ts +2 -2
- package/build/runtime/client/plugins/injectedPlugins.d.ts +2 -1
- package/build/runtime/client/plugins/mutation.d.ts +1 -1
- package/build/runtime/client/plugins/query.d.ts +1 -1
- package/build/runtime/client/plugins/subscription.d.ts +2 -3
- package/build/runtime/client/plugins/throwOnError.d.ts +1 -1
- package/build/runtime/client/utils/documentPlugins.d.ts +3 -3
- package/build/runtime/generated.d.ts +1 -0
- package/build/runtime/imports/pluginConfig.d.ts +3 -0
- package/build/runtime/index.d.ts +1 -1
- package/build/runtime/lib/config.d.ts +27 -24
- package/build/runtime/lib/flatten.d.ts +2 -0
- package/build/runtime/lib/index.d.ts +1 -0
- package/build/runtime/lib/key.d.ts +6 -0
- package/build/runtime/lib/scalars.d.ts +3 -3
- package/build/runtime/lib/types.d.ts +47 -47
- package/build/runtime/public/cache.d.ts +26 -6
- package/build/runtime/public/record.d.ts +26 -17
- package/build/runtime/public/tests/test.d.ts +52 -10
- package/build/runtime/public/types.d.ts +8 -0
- package/build/runtime-cjs/cache/cache.d.ts +28 -11
- package/build/runtime-cjs/cache/cache.js +97 -22
- package/build/runtime-cjs/cache/gc.js +9 -0
- package/build/runtime-cjs/cache/lists.d.ts +1 -0
- package/build/runtime-cjs/cache/lists.js +9 -6
- package/build/runtime-cjs/cache/staleManager.d.ts +30 -0
- package/build/runtime-cjs/cache/staleManager.js +95 -0
- package/build/runtime-cjs/cache/storage.d.ts +23 -20
- package/build/runtime-cjs/cache/storage.js +11 -13
- package/build/runtime-cjs/cache/stuff.d.ts +0 -2
- package/build/runtime-cjs/cache/stuff.js +2 -19
- package/build/runtime-cjs/cache/subscription.d.ts +2 -1
- package/build/runtime-cjs/cache/subscription.js +11 -7
- package/build/runtime-cjs/client/documentStore.d.ts +20 -17
- package/build/runtime-cjs/client/documentStore.js +13 -9
- package/build/runtime-cjs/client/index.d.ts +13 -11
- package/build/runtime-cjs/client/index.js +48 -19
- package/build/runtime-cjs/client/plugins/cache.d.ts +1 -1
- package/build/runtime-cjs/client/plugins/cache.js +12 -10
- package/build/runtime-cjs/client/plugins/fetch.d.ts +1 -1
- package/build/runtime-cjs/client/plugins/fetch.js +10 -9
- package/build/runtime-cjs/client/plugins/fetchParams.d.ts +2 -2
- package/build/runtime-cjs/client/plugins/fetchParams.js +9 -4
- package/build/runtime-cjs/client/plugins/injectedPlugins.d.ts +2 -1
- package/build/runtime-cjs/client/plugins/mutation.d.ts +1 -1
- package/build/runtime-cjs/client/plugins/mutation.js +3 -3
- package/build/runtime-cjs/client/plugins/query.d.ts +1 -1
- package/build/runtime-cjs/client/plugins/query.js +5 -5
- package/build/runtime-cjs/client/plugins/subscription.d.ts +2 -3
- package/build/runtime-cjs/client/plugins/subscription.js +7 -5
- package/build/runtime-cjs/client/plugins/throwOnError.d.ts +1 -1
- package/build/runtime-cjs/client/plugins/throwOnError.js +3 -3
- package/build/runtime-cjs/client/utils/documentPlugins.d.ts +3 -3
- package/build/runtime-cjs/generated.d.ts +1 -0
- package/build/runtime-cjs/imports/pluginConfig.d.ts +3 -0
- package/build/runtime-cjs/imports/pluginConfig.js +27 -0
- package/build/runtime-cjs/index.d.ts +1 -1
- package/build/runtime-cjs/lib/config.d.ts +27 -24
- package/build/runtime-cjs/lib/config.js +11 -1
- package/build/runtime-cjs/lib/flatten.d.ts +2 -0
- package/build/runtime-cjs/lib/flatten.js +41 -0
- package/build/runtime-cjs/lib/index.d.ts +1 -0
- package/build/runtime-cjs/lib/index.js +1 -0
- package/build/runtime-cjs/lib/key.d.ts +6 -0
- package/build/runtime-cjs/lib/key.js +41 -0
- package/build/runtime-cjs/lib/scalars.d.ts +3 -3
- package/build/runtime-cjs/lib/scalars.js +13 -2
- package/build/runtime-cjs/lib/types.d.ts +47 -47
- package/build/runtime-cjs/lib/types.js +26 -30
- package/build/runtime-cjs/public/cache.d.ts +26 -6
- package/build/runtime-cjs/public/cache.js +32 -32
- package/build/runtime-cjs/public/list.js +6 -28
- package/build/runtime-cjs/public/record.d.ts +26 -17
- package/build/runtime-cjs/public/record.js +27 -187
- package/build/runtime-cjs/public/tests/test.d.ts +52 -10
- package/build/runtime-cjs/public/tests/test.js +27 -2
- package/build/runtime-cjs/public/types.d.ts +8 -0
- package/build/runtime-esm/cache/cache.d.ts +28 -11
- package/build/runtime-esm/cache/cache.js +99 -24
- package/build/runtime-esm/cache/gc.js +9 -0
- package/build/runtime-esm/cache/lists.d.ts +1 -0
- package/build/runtime-esm/cache/lists.js +9 -6
- package/build/runtime-esm/cache/staleManager.d.ts +30 -0
- package/build/runtime-esm/cache/staleManager.js +71 -0
- package/build/runtime-esm/cache/storage.d.ts +23 -20
- package/build/runtime-esm/cache/storage.js +11 -13
- package/build/runtime-esm/cache/stuff.d.ts +0 -2
- package/build/runtime-esm/cache/stuff.js +1 -17
- package/build/runtime-esm/cache/subscription.d.ts +2 -1
- package/build/runtime-esm/cache/subscription.js +12 -8
- package/build/runtime-esm/client/documentStore.d.ts +20 -17
- package/build/runtime-esm/client/documentStore.js +14 -10
- package/build/runtime-esm/client/index.d.ts +13 -11
- package/build/runtime-esm/client/index.js +49 -21
- package/build/runtime-esm/client/plugins/cache.d.ts +1 -1
- package/build/runtime-esm/client/plugins/cache.js +11 -9
- package/build/runtime-esm/client/plugins/fetch.d.ts +1 -1
- package/build/runtime-esm/client/plugins/fetch.js +9 -8
- package/build/runtime-esm/client/plugins/fetchParams.d.ts +2 -2
- package/build/runtime-esm/client/plugins/fetchParams.js +8 -3
- package/build/runtime-esm/client/plugins/injectedPlugins.d.ts +2 -1
- package/build/runtime-esm/client/plugins/mutation.d.ts +1 -1
- package/build/runtime-esm/client/plugins/mutation.js +2 -2
- package/build/runtime-esm/client/plugins/query.d.ts +1 -1
- package/build/runtime-esm/client/plugins/query.js +4 -4
- package/build/runtime-esm/client/plugins/subscription.d.ts +2 -3
- package/build/runtime-esm/client/plugins/subscription.js +6 -4
- package/build/runtime-esm/client/plugins/throwOnError.d.ts +1 -1
- package/build/runtime-esm/client/plugins/throwOnError.js +2 -2
- package/build/runtime-esm/client/utils/documentPlugins.d.ts +3 -3
- package/build/runtime-esm/generated.d.ts +1 -0
- package/build/runtime-esm/imports/pluginConfig.d.ts +3 -0
- package/build/runtime-esm/imports/pluginConfig.js +5 -0
- package/build/runtime-esm/index.d.ts +1 -1
- package/build/runtime-esm/lib/config.d.ts +27 -24
- package/build/runtime-esm/lib/config.js +11 -1
- package/build/runtime-esm/lib/flatten.d.ts +2 -0
- package/build/runtime-esm/lib/flatten.js +17 -0
- package/build/runtime-esm/lib/index.d.ts +1 -0
- package/build/runtime-esm/lib/index.js +1 -0
- package/build/runtime-esm/lib/key.d.ts +6 -0
- package/build/runtime-esm/lib/key.js +17 -0
- package/build/runtime-esm/lib/scalars.d.ts +3 -3
- package/build/runtime-esm/lib/scalars.js +13 -2
- package/build/runtime-esm/lib/types.d.ts +47 -47
- package/build/runtime-esm/lib/types.js +26 -30
- package/build/runtime-esm/public/cache.d.ts +26 -6
- package/build/runtime-esm/public/cache.js +31 -30
- package/build/runtime-esm/public/list.js +6 -28
- package/build/runtime-esm/public/record.d.ts +26 -17
- package/build/runtime-esm/public/record.js +26 -183
- package/build/runtime-esm/public/tests/test.d.ts +52 -10
- package/build/runtime-esm/public/tests/test.js +26 -1
- package/build/runtime-esm/public/types.d.ts +8 -0
- package/build/test/index.d.ts +3 -3
- package/build/test-cjs/index.js +5007 -2465
- package/build/test-esm/index.js +4995 -2453
- package/build/vite/houdini.d.ts +2 -0
- package/build/vite-cjs/index.js +5344 -2744
- package/build/vite-esm/index.js +5319 -2719
- package/package.json +6 -5
- package/build/codegen/generators/typescript/imperativeCache.d.ts +0 -2
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { ConfigFile } from '../lib/config';
|
|
2
|
-
import type { GraphQLObject, GraphQLValue, SubscriptionSelection, SubscriptionSpec } from '../lib/types';
|
|
2
|
+
import type { GraphQLObject, GraphQLValue, NestedList, SubscriptionSelection, SubscriptionSpec } from '../lib/types';
|
|
3
3
|
import { GarbageCollector } from './gc';
|
|
4
4
|
import type { ListCollection } from './lists';
|
|
5
5
|
import { ListManager } from './lists';
|
|
6
6
|
import { SchemaManager } from './schema';
|
|
7
|
+
import { StaleManager } from './staleManager';
|
|
7
8
|
import type { Layer, LayerID } from './storage';
|
|
8
9
|
import { InMemoryStorage } from './storage';
|
|
9
|
-
import { type FieldSelection
|
|
10
|
+
import { InMemorySubscriptions, type FieldSelection } from './subscription';
|
|
10
11
|
export declare class Cache {
|
|
11
12
|
_internal_unstable: CacheInternal;
|
|
12
13
|
constructor(config?: ConfigFile);
|
|
@@ -18,19 +19,31 @@ export declare class Cache {
|
|
|
18
19
|
variables?: {};
|
|
19
20
|
parent?: string;
|
|
20
21
|
layer?: LayerID | null;
|
|
21
|
-
applyUpdates?:
|
|
22
|
+
applyUpdates?: string[];
|
|
22
23
|
notifySubscribers?: SubscriptionSpec[];
|
|
23
24
|
forceNotify?: boolean;
|
|
25
|
+
forceStale?: boolean;
|
|
24
26
|
}): SubscriptionSpec[];
|
|
25
27
|
read(...args: Parameters<CacheInternal['getSelection']>): {
|
|
26
28
|
data: GraphQLObject | null;
|
|
27
29
|
partial: boolean;
|
|
30
|
+
stale: boolean;
|
|
28
31
|
};
|
|
29
32
|
subscribe(spec: SubscriptionSpec, variables?: {}): void;
|
|
30
33
|
unsubscribe(spec: SubscriptionSpec, variables?: {}): void;
|
|
31
34
|
list(name: string, parentID?: string, allLists?: boolean): ListCollection;
|
|
32
35
|
delete(id: string): void;
|
|
33
36
|
setConfig(config: ConfigFile): void;
|
|
37
|
+
markTypeStale(options?: {
|
|
38
|
+
type: string;
|
|
39
|
+
field?: string;
|
|
40
|
+
when?: {};
|
|
41
|
+
}): void;
|
|
42
|
+
markRecordStale(id: string, options: {
|
|
43
|
+
field?: string;
|
|
44
|
+
when?: {};
|
|
45
|
+
}): void;
|
|
46
|
+
getFieldTime(id: string, field: string): number | null | undefined;
|
|
34
47
|
}
|
|
35
48
|
declare class CacheInternal {
|
|
36
49
|
private _disabled;
|
|
@@ -40,17 +53,19 @@ declare class CacheInternal {
|
|
|
40
53
|
lists: ListManager;
|
|
41
54
|
cache: Cache;
|
|
42
55
|
lifetimes: GarbageCollector;
|
|
56
|
+
staleManager: StaleManager;
|
|
43
57
|
schema: SchemaManager;
|
|
44
|
-
constructor({ storage, subscriptions, lists, cache, lifetimes, schema, }: {
|
|
58
|
+
constructor({ storage, subscriptions, lists, cache, lifetimes, staleManager, schema, }: {
|
|
45
59
|
storage: InMemoryStorage;
|
|
46
60
|
subscriptions: InMemorySubscriptions;
|
|
47
61
|
lists: ListManager;
|
|
48
62
|
cache: Cache;
|
|
49
63
|
lifetimes: GarbageCollector;
|
|
64
|
+
staleManager: StaleManager;
|
|
50
65
|
schema: SchemaManager;
|
|
51
66
|
});
|
|
52
67
|
setConfig(config: ConfigFile): void;
|
|
53
|
-
writeSelection({ data, selection, variables, parent, applyUpdates, layer, toNotify, forceNotify, }: {
|
|
68
|
+
writeSelection({ data, selection, variables, parent, applyUpdates, layer, toNotify, forceNotify, forceStale, }: {
|
|
54
69
|
data: {
|
|
55
70
|
[key: string]: GraphQLValue;
|
|
56
71
|
};
|
|
@@ -62,8 +77,9 @@ declare class CacheInternal {
|
|
|
62
77
|
root?: string;
|
|
63
78
|
layer: Layer;
|
|
64
79
|
toNotify?: FieldSelection[];
|
|
65
|
-
applyUpdates?:
|
|
80
|
+
applyUpdates?: string[];
|
|
66
81
|
forceNotify?: boolean;
|
|
82
|
+
forceStale?: boolean;
|
|
67
83
|
}): FieldSelection[];
|
|
68
84
|
getSelection({ selection, parent, variables, stepsFromConnection, }: {
|
|
69
85
|
selection: SubscriptionSelection;
|
|
@@ -73,6 +89,7 @@ declare class CacheInternal {
|
|
|
73
89
|
}): {
|
|
74
90
|
data: GraphQLObject | null;
|
|
75
91
|
partial: boolean;
|
|
92
|
+
stale: boolean;
|
|
76
93
|
hasData: boolean;
|
|
77
94
|
};
|
|
78
95
|
id(type: string, data: {} | null): string | null;
|
|
@@ -82,11 +99,12 @@ declare class CacheInternal {
|
|
|
82
99
|
hydrateNestedList({ fields, variables, linkedList, stepsFromConnection, }: {
|
|
83
100
|
fields: SubscriptionSelection;
|
|
84
101
|
variables?: {};
|
|
85
|
-
linkedList:
|
|
102
|
+
linkedList: NestedList;
|
|
86
103
|
stepsFromConnection: number | null;
|
|
87
104
|
}): {
|
|
88
|
-
data:
|
|
105
|
+
data: NestedList<GraphQLValue>;
|
|
89
106
|
partial: boolean;
|
|
107
|
+
stale: boolean;
|
|
90
108
|
hasData: boolean;
|
|
91
109
|
};
|
|
92
110
|
extractNestedListIDs({ value, abstract, recordID, key, linkedType, fields, variables, applyUpdates, specs, layer, forceNotify, }: {
|
|
@@ -97,16 +115,15 @@ declare class CacheInternal {
|
|
|
97
115
|
abstract: boolean;
|
|
98
116
|
variables: {};
|
|
99
117
|
specs: FieldSelection[];
|
|
100
|
-
applyUpdates
|
|
118
|
+
applyUpdates?: string[];
|
|
101
119
|
fields: SubscriptionSelection;
|
|
102
120
|
layer: Layer;
|
|
103
121
|
forceNotify?: boolean;
|
|
104
122
|
}): {
|
|
105
|
-
nestedIDs:
|
|
123
|
+
nestedIDs: NestedList;
|
|
106
124
|
newIDs: (string | null)[];
|
|
107
125
|
};
|
|
108
126
|
collectGarbage(): void;
|
|
109
127
|
}
|
|
110
128
|
export declare const rootID = "_ROOT_";
|
|
111
|
-
export type LinkedList<_Result = string> = (_Result | null | LinkedList<_Result>)[];
|
|
112
129
|
export {};
|
|
@@ -55,6 +55,7 @@ export declare class List {
|
|
|
55
55
|
export declare class ListCollection {
|
|
56
56
|
lists: List[];
|
|
57
57
|
constructor(lists: List[]);
|
|
58
|
+
get selection(): SubscriptionSelection;
|
|
58
59
|
append(...args: Parameters<List['append']>): void;
|
|
59
60
|
prepend(...args: Parameters<List['prepend']>): void;
|
|
60
61
|
addToList(...args: Parameters<List['addToList']>): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Cache } from './cache';
|
|
2
|
+
export declare class StaleManager {
|
|
3
|
+
#private;
|
|
4
|
+
cache: Cache;
|
|
5
|
+
private fieldsTime;
|
|
6
|
+
constructor(cache: Cache);
|
|
7
|
+
/**
|
|
8
|
+
* get the FieldTime info
|
|
9
|
+
* @param id User:1
|
|
10
|
+
* @param field firstName
|
|
11
|
+
*/
|
|
12
|
+
getFieldTime(id: string, field: string): number | undefined | null;
|
|
13
|
+
/**
|
|
14
|
+
* set the date to a field
|
|
15
|
+
* @param id User:1
|
|
16
|
+
* @param field firstName
|
|
17
|
+
*/
|
|
18
|
+
setFieldTimeToNow(id: string, field: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* set null to a field (stale)
|
|
21
|
+
* @param id User:1
|
|
22
|
+
* @param field firstName
|
|
23
|
+
*/
|
|
24
|
+
markFieldStale(id: string, field: string): void;
|
|
25
|
+
markAllStale(): void;
|
|
26
|
+
markRecordStale(id: string): void;
|
|
27
|
+
markTypeStale(type: string): void;
|
|
28
|
+
markTypeFieldStale(type: string, field: string, when?: {}): void;
|
|
29
|
+
delete(id: string, field: string): void;
|
|
30
|
+
}
|
|
@@ -7,7 +7,7 @@ export declare class InMemoryStorage {
|
|
|
7
7
|
get layerCount(): number;
|
|
8
8
|
get nextRank(): number;
|
|
9
9
|
createLayer(optimistic?: boolean): Layer;
|
|
10
|
-
insert(id: string, field: string, location:
|
|
10
|
+
insert(id: string, field: string, location: OperationLocations, target: string): void;
|
|
11
11
|
remove(id: string, field: string, target: string): void;
|
|
12
12
|
delete(id: string): void;
|
|
13
13
|
deleteField(id: string, field: string): void;
|
|
@@ -21,7 +21,7 @@ export declare class InMemoryStorage {
|
|
|
21
21
|
kind: 'link' | 'scalar' | 'unknown';
|
|
22
22
|
displayLayers: number[];
|
|
23
23
|
};
|
|
24
|
-
writeLink(id: string, field: string, value: string |
|
|
24
|
+
writeLink(id: string, field: string, value: string | NestedList): number;
|
|
25
25
|
writeField(id: string, field: string, value: GraphQLValue): number;
|
|
26
26
|
resolveLayer(id: number): void;
|
|
27
27
|
get topLayer(): Layer;
|
|
@@ -37,7 +37,7 @@ export declare class Layer {
|
|
|
37
37
|
get(id: string, field: string): [GraphQLField, 'link' | 'scalar'];
|
|
38
38
|
getOperations(id: string, field: string): Operation[] | undefined;
|
|
39
39
|
writeField(id: string, field: string, value: GraphQLField): LayerID;
|
|
40
|
-
writeLink(id: string, field: string, value: null | string |
|
|
40
|
+
writeLink(id: string, field: string, value: null | string | NestedList): LayerID;
|
|
41
41
|
isDisplayLayer(displayLayers: number[]): boolean;
|
|
42
42
|
clear(): void;
|
|
43
43
|
replaceID({ from, to }: {
|
|
@@ -47,19 +47,19 @@ export declare class Layer {
|
|
|
47
47
|
removeUndefinedFields(): void;
|
|
48
48
|
delete(id: string): void;
|
|
49
49
|
deleteField(id: string, field: string): void;
|
|
50
|
-
insert(id: string, field: string, where:
|
|
50
|
+
insert(id: string, field: string, where: OperationLocations, target: string): void;
|
|
51
51
|
remove(id: string, field: string, target: string): void;
|
|
52
52
|
writeLayer(layer: Layer): void;
|
|
53
53
|
private addFieldOperation;
|
|
54
54
|
}
|
|
55
|
-
type GraphQLField = GraphQLValue |
|
|
55
|
+
type GraphQLField = GraphQLValue | NestedList;
|
|
56
56
|
type EntityMap<_Value> = {
|
|
57
57
|
[id: string]: {
|
|
58
58
|
[field: string]: _Value;
|
|
59
59
|
};
|
|
60
60
|
};
|
|
61
61
|
type EntityFieldMap = EntityMap<GraphQLField>;
|
|
62
|
-
type LinkMap = EntityMap<string | null |
|
|
62
|
+
type LinkMap = EntityMap<string | null | NestedList>;
|
|
63
63
|
type OperationMap = {
|
|
64
64
|
[id: string]: {
|
|
65
65
|
deleted?: boolean;
|
|
@@ -69,30 +69,33 @@ type OperationMap = {
|
|
|
69
69
|
};
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
|
-
type
|
|
72
|
+
type NestedList<_Result = string> = (_Result | null | NestedList<_Result>)[];
|
|
73
73
|
type InsertOperation = {
|
|
74
|
-
kind:
|
|
75
|
-
location:
|
|
74
|
+
kind: 'insert';
|
|
75
|
+
location: OperationLocations;
|
|
76
76
|
id: string;
|
|
77
77
|
};
|
|
78
78
|
type RemoveOperation = {
|
|
79
|
-
kind:
|
|
79
|
+
kind: 'remove';
|
|
80
80
|
id: string;
|
|
81
81
|
};
|
|
82
82
|
type DeleteOperation = {
|
|
83
|
-
kind:
|
|
83
|
+
kind: 'delete';
|
|
84
84
|
target: string;
|
|
85
85
|
};
|
|
86
86
|
type ListOperation = InsertOperation | RemoveOperation;
|
|
87
87
|
type Operation = ListOperation | DeleteOperation;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
88
|
+
type ValuesOf<Target> = Target[keyof Target];
|
|
89
|
+
export declare const OperationLocation: {
|
|
90
|
+
readonly start: "start";
|
|
91
|
+
readonly end: "end";
|
|
92
|
+
};
|
|
93
|
+
export type OperationLocations = ValuesOf<typeof OperationLocation>;
|
|
94
|
+
export declare const OperationKind: {
|
|
95
|
+
readonly delete: "delete";
|
|
96
|
+
readonly insert: "insert";
|
|
97
|
+
readonly remove: "remove";
|
|
98
|
+
};
|
|
99
|
+
export type OperationKinds = ValuesOf<typeof OperationKind>;
|
|
97
100
|
export type LayerID = number;
|
|
98
101
|
export {};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { GraphQLValue } from '../lib/types';
|
|
2
|
-
import type { LinkedList } from './cache';
|
|
3
|
-
export declare function flattenList<T>(source: LinkedList<T>): T[];
|
|
4
2
|
export declare function evaluateKey(key: string, variables?: {
|
|
5
3
|
[key: string]: GraphQLValue;
|
|
6
4
|
}): string;
|
|
@@ -19,10 +19,11 @@ export declare class InMemorySubscriptions {
|
|
|
19
19
|
[key: string]: GraphQLValue;
|
|
20
20
|
};
|
|
21
21
|
}): void;
|
|
22
|
-
addFieldSubscription({ id, key, selection, }: {
|
|
22
|
+
addFieldSubscription({ id, key, selection, type, }: {
|
|
23
23
|
id: string;
|
|
24
24
|
key: string;
|
|
25
25
|
selection: FieldSelection;
|
|
26
|
+
type: string;
|
|
26
27
|
}): void;
|
|
27
28
|
registerList({ list, id, key, parentType, selection, filters, variables, }: {
|
|
28
29
|
list: Required<Required<SubscriptionSelection>['fields'][string]>['list'];
|
|
@@ -2,31 +2,23 @@ import type { HoudiniClient } from '.';
|
|
|
2
2
|
import type { Layer } from '../cache/storage';
|
|
3
3
|
import type { ConfigFile } from '../lib/config';
|
|
4
4
|
import { Writable } from '../lib/store';
|
|
5
|
-
import type {
|
|
5
|
+
import type { DocumentArtifact, QueryResult, GraphQLObject, SubscriptionSpec, CachePolicies } from '../lib/types';
|
|
6
6
|
export declare class DocumentStore<_Data extends GraphQLObject, _Input extends Record<string, any>> extends Writable<QueryResult<_Data, _Input>> {
|
|
7
7
|
#private;
|
|
8
8
|
constructor({ artifact, plugins, pipeline, client, cache, initialValue, fetching, }: {
|
|
9
9
|
artifact: DocumentArtifact;
|
|
10
|
-
plugins?:
|
|
11
|
-
pipeline?:
|
|
12
|
-
client: HoudiniClient;
|
|
10
|
+
plugins?: ClientHooks[];
|
|
11
|
+
pipeline?: ClientHooks[];
|
|
12
|
+
client: HoudiniClient | null;
|
|
13
13
|
cache?: boolean;
|
|
14
14
|
initialValue?: _Data | null;
|
|
15
15
|
fetching?: boolean;
|
|
16
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>>;
|
|
17
|
+
send({ metadata, session, fetch, variables, policy, stuff, cacheParams, setup, silenceEcho, }?: SendParams): Promise<QueryResult<_Data, _Input>>;
|
|
27
18
|
}
|
|
28
19
|
declare function marshalVariables<_Data extends GraphQLObject, _Input extends {}>(ctx: ClientPluginContext): Record<string, any>;
|
|
29
|
-
export type ClientPlugin = () =>
|
|
20
|
+
export type ClientPlugin = () => ClientHooks | null | (ClientHooks | ClientPlugin | null)[];
|
|
21
|
+
export type ClientHooks = {
|
|
30
22
|
start?: ClientPluginEnterPhase;
|
|
31
23
|
beforeNetwork?: ClientPluginEnterPhase;
|
|
32
24
|
network?: ClientPluginEnterPhase;
|
|
@@ -41,7 +33,7 @@ export type ClientPluginContext = {
|
|
|
41
33
|
text: string;
|
|
42
34
|
hash: string;
|
|
43
35
|
artifact: DocumentArtifact;
|
|
44
|
-
policy?:
|
|
36
|
+
policy?: CachePolicies;
|
|
45
37
|
fetch?: Fetch;
|
|
46
38
|
variables?: Record<string, any>;
|
|
47
39
|
metadata?: App.Metadata | null;
|
|
@@ -53,7 +45,7 @@ export type ClientPluginContext = {
|
|
|
53
45
|
forceNotify?: boolean;
|
|
54
46
|
disableWrite?: boolean;
|
|
55
47
|
disableRead?: boolean;
|
|
56
|
-
applyUpdates?:
|
|
48
|
+
applyUpdates?: string[];
|
|
57
49
|
};
|
|
58
50
|
stuff: App.Stuff;
|
|
59
51
|
};
|
|
@@ -84,4 +76,15 @@ export type ClientPluginExitHandlers = Omit<ClientPluginEnterHandlers, 'resolve'
|
|
|
84
76
|
export type ClientPluginErrorHandlers = ClientPluginEnterHandlers & {
|
|
85
77
|
error: unknown;
|
|
86
78
|
};
|
|
79
|
+
export type SendParams = {
|
|
80
|
+
fetch?: Fetch;
|
|
81
|
+
variables?: Record<string, any> | null;
|
|
82
|
+
metadata?: App.Metadata | null;
|
|
83
|
+
session?: App.Session | null;
|
|
84
|
+
policy?: CachePolicies;
|
|
85
|
+
stuff?: Partial<App.Stuff>;
|
|
86
|
+
cacheParams?: ClientPluginContext['cacheParams'];
|
|
87
|
+
setup?: boolean;
|
|
88
|
+
silenceEcho?: boolean;
|
|
89
|
+
};
|
|
87
90
|
export {};
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
/// <reference path="../../../../../houdini.d.ts" />
|
|
2
|
-
import type { DocumentArtifact, GraphQLObject } from '../lib/types';
|
|
3
|
-
import type { ClientPlugin } from './documentStore';
|
|
2
|
+
import type { DocumentArtifact, GraphQLObject, NestedList } from '../lib/types';
|
|
3
|
+
import type { ClientPlugin, ClientHooks } from './documentStore';
|
|
4
4
|
import { DocumentStore } from './documentStore';
|
|
5
5
|
import { type FetchParamFn, type ThrowOnErrorParams } from './plugins';
|
|
6
6
|
export { DocumentStore, type ClientPlugin } from './documentStore';
|
|
7
|
-
export {
|
|
7
|
+
export { fetch, mutation, query, subscription } from './plugins';
|
|
8
8
|
type ConstructorArgs = {
|
|
9
9
|
url: string;
|
|
10
10
|
fetchParams?: FetchParamFn;
|
|
11
|
-
plugins?: ClientPlugin
|
|
12
|
-
pipeline?: ClientPlugin
|
|
11
|
+
plugins?: NestedList<ClientPlugin>;
|
|
12
|
+
pipeline?: NestedList<ClientPlugin>;
|
|
13
13
|
throwOnError?: ThrowOnErrorParams;
|
|
14
14
|
};
|
|
15
|
+
export type ObserveParams<_Data extends GraphQLObject, _Artifact extends DocumentArtifact = DocumentArtifact> = {
|
|
16
|
+
artifact: _Artifact;
|
|
17
|
+
cache?: boolean;
|
|
18
|
+
initialValue?: _Data | null;
|
|
19
|
+
fetching?: boolean;
|
|
20
|
+
};
|
|
15
21
|
export declare class HoudiniClient {
|
|
16
22
|
#private;
|
|
17
23
|
url: string;
|
|
18
24
|
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
|
+
observe<_Data extends GraphQLObject, _Input extends Record<string, any>>({ artifact, cache, initialValue, fetching, }: ObserveParams<_Data>): DocumentStore<_Data, _Input>;
|
|
25
26
|
}
|
|
27
|
+
export declare function createPluginHooks(plugins: ClientPlugin[]): ClientHooks[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import cache from '../../cache';
|
|
2
2
|
import type { Cache } from '../../cache/cache';
|
|
3
3
|
import type { ClientPlugin } from '../documentStore';
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const cachePolicy: ({ enabled, setFetching, cache: localCache, }: {
|
|
5
5
|
enabled: boolean;
|
|
6
6
|
setFetching: (val: boolean) => void;
|
|
7
7
|
cache?: Cache | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RequestPayload } from '../../lib/types';
|
|
2
2
|
import type { ClientPlugin } from '../documentStore';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const fetch: (target?: RequestHandler | string) => ClientPlugin;
|
|
4
4
|
export type FetchContext = {
|
|
5
5
|
fetch: typeof globalThis.fetch;
|
|
6
6
|
metadata?: App.Metadata | null;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { DocumentArtifact } from '../../lib/types';
|
|
2
2
|
import type { ClientPlugin, ClientPluginContext } from '../documentStore';
|
|
3
3
|
export type FetchParamFn = (ctx: FetchParamsInput) => Required<ClientPluginContext>['fetchParams'];
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const fetchParams: (fn?: FetchParamFn) => ClientPlugin;
|
|
5
5
|
export type FetchParamsInput = Pick<ClientPluginContext, 'config' | 'policy' | 'variables' | 'metadata' | 'session' | 'stuff'> & {
|
|
6
6
|
text: string;
|
|
7
7
|
hash: string;
|
|
8
|
-
|
|
8
|
+
document: DocumentArtifact;
|
|
9
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const mutation: import("..").ClientPlugin;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ClientPlugin } from '../documentStore';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const query: ClientPlugin;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import type { GraphQLObject } from '../../lib/types';
|
|
2
1
|
import type { ClientPluginContext } from '../documentStore';
|
|
3
|
-
export declare function
|
|
2
|
+
export declare function subscription(factory: SubscriptionHandler): import("../documentStore").ClientPlugin;
|
|
4
3
|
export type SubscriptionHandler = (ctx: ClientPluginContext) => {
|
|
5
4
|
subscribe: (payload: {
|
|
6
5
|
query: string;
|
|
7
6
|
variables?: {};
|
|
8
7
|
}, handlers: {
|
|
9
8
|
next: (payload: {
|
|
10
|
-
data?:
|
|
9
|
+
data?: {} | null;
|
|
11
10
|
errors?: readonly {
|
|
12
11
|
message: string;
|
|
13
12
|
}[];
|
|
@@ -4,4 +4,4 @@ export type ThrowOnErrorParams = {
|
|
|
4
4
|
operations: ('all' | 'query' | 'mutation' | 'subscription')[];
|
|
5
5
|
error?: (errors: NonNullable<QueryResult<any, any>['errors']>) => unknown;
|
|
6
6
|
};
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const throwOnError: ({ operations, error }: ThrowOnErrorParams) => ClientPlugin;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ClientPlugin } from '../documentStore';
|
|
3
|
-
export declare const documentPlugin: (kind:
|
|
1
|
+
import type { ArtifactKinds } from '../../lib/types';
|
|
2
|
+
import type { ClientPlugin, ClientHooks } from '../documentStore';
|
|
3
|
+
export declare const documentPlugin: (kind: ArtifactKinds, source: () => ClientHooks) => ClientPlugin;
|
package/build/runtime/index.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ import type { CacheTypeDef } from './generated';
|
|
|
3
3
|
import { Cache } from './public';
|
|
4
4
|
export * from './client';
|
|
5
5
|
export * from './lib';
|
|
6
|
-
export declare function graphql(str:
|
|
6
|
+
export declare function graphql<_Payload>(str: TemplateStringsArray): _Payload;
|
|
7
7
|
export declare const cache: Cache<CacheTypeDef>;
|
|
8
8
|
export declare function getCache(): InternalCache;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GraphQLSchema } from 'graphql';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CachePolicies } 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;
|
|
@@ -31,10 +31,6 @@ export type ConfigFile = {
|
|
|
31
31
|
* FYI: `schemaPath` or `schema` should be defined
|
|
32
32
|
*/
|
|
33
33
|
schema?: string | GraphQLSchema;
|
|
34
|
-
/**
|
|
35
|
-
* A url to use to pull the schema. For more information: https://www.houdinigraphql.com/api/cli#generate
|
|
36
|
-
*/
|
|
37
|
-
apiUrl?: string | ((env: Record<string, string | undefined>) => string);
|
|
38
34
|
/**
|
|
39
35
|
* An object describing custom scalars for your project. For more information: https://www.houdinigraphql.com/api/config#custom-scalars
|
|
40
36
|
*/
|
|
@@ -43,11 +39,6 @@ export type ConfigFile = {
|
|
|
43
39
|
* A path that the generator will use to write schema.graphql and documents.gql files containing all of the internal fragment and directive definitions used in the project.
|
|
44
40
|
*/
|
|
45
41
|
definitionsPath?: string;
|
|
46
|
-
/**
|
|
47
|
-
* One of "kit" or "svelte". Used to tell the preprocessor what kind of loading paradigm to generate for you. (default: `kit`)
|
|
48
|
-
* @deprecated please follow the steps here: http://www.houdinigraphql.com/guides/release-notes#0170
|
|
49
|
-
*/
|
|
50
|
-
framework?: 'kit' | 'svelte';
|
|
51
42
|
/**
|
|
52
43
|
* One of "esm" or "commonjs". Tells the artifact generator what kind of modules to create. (default: `esm`)
|
|
53
44
|
*/
|
|
@@ -59,11 +50,15 @@ export type ConfigFile = {
|
|
|
59
50
|
/**
|
|
60
51
|
* The default cache policy to use for queries. For more information: https://www.houdinigraphql.com/guides/caching-data
|
|
61
52
|
*/
|
|
62
|
-
defaultCachePolicy?:
|
|
53
|
+
defaultCachePolicy?: CachePolicies;
|
|
63
54
|
/**
|
|
64
55
|
* Specifies whether or not the cache should always use partial data. For more information: https://www.houdinigraphql.com/guides/caching-data#partial-data
|
|
65
56
|
*/
|
|
66
57
|
defaultPartial?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Specifies after how long a data goes stale in miliseconds. (default: `undefined`)
|
|
60
|
+
*/
|
|
61
|
+
defaultLifetime?: number;
|
|
67
62
|
/**
|
|
68
63
|
* Specifies whether mutations should append or prepend list. For more information: https://www.houdinigraphql.com/api/graphql (default: `append`)
|
|
69
64
|
*/
|
|
@@ -90,20 +85,9 @@ export type ConfigFile = {
|
|
|
90
85
|
*/
|
|
91
86
|
defaultFragmentMasking?: 'enable' | 'disable';
|
|
92
87
|
/**
|
|
93
|
-
*
|
|
94
|
-
* during development in order to keep it's definition of your schema up to date. The schemaPollingInterval
|
|
95
|
-
* config value sets the amount of time between each request in milliseconds (default 2 seconds).
|
|
96
|
-
* To limit the schema introspection to just on the start of the server, set schemaPollingInterval to 0.
|
|
97
|
-
* To disable the schema introspection, set schemaPollingInterval to null.
|
|
98
|
-
*/
|
|
99
|
-
schemaPollInterval?: number | null;
|
|
100
|
-
/**
|
|
101
|
-
* An object containing the environment variables you want passed onto the api when polling for a new schema.
|
|
102
|
-
* The keys dictate the header names. If the value is a string, the corresponding environment variable will be used
|
|
103
|
-
* directly. If the value is a function, the current environment will be passed to your function so you can perform any
|
|
104
|
-
* logic you need
|
|
88
|
+
* Configure the dev environment to watch a remote schema for changes
|
|
105
89
|
*/
|
|
106
|
-
|
|
90
|
+
watchSchema?: WatchSchemaConfig;
|
|
107
91
|
/**
|
|
108
92
|
* An object describing the plugins enabled for the project
|
|
109
93
|
*/
|
|
@@ -133,6 +117,25 @@ export type TypeConfig = {
|
|
|
133
117
|
};
|
|
134
118
|
};
|
|
135
119
|
};
|
|
120
|
+
export type WatchSchemaConfig = {
|
|
121
|
+
/**
|
|
122
|
+
* A url to use to pull the schema. For more information: https://www.houdinigraphql.com/api/cli#generate
|
|
123
|
+
*/
|
|
124
|
+
url: string | ((env: Record<string, string | undefined>) => string);
|
|
125
|
+
/**
|
|
126
|
+
* sets the amount of time between each request in milliseconds (default 2 seconds).
|
|
127
|
+
* To limit the schema introspection to just on the start of the server, set interval to 0.
|
|
128
|
+
* To disable the schema introspection, set interval to null.
|
|
129
|
+
*/
|
|
130
|
+
interval?: number | null;
|
|
131
|
+
/**
|
|
132
|
+
* An object containing the environment variables you want passed onto the api when polling for a new schema.
|
|
133
|
+
* The keys dictate the header names. If the value is a string, the corresponding environment variable will be used
|
|
134
|
+
* directly. If the value is a function, the current environment will be passed to your function so you can perform any
|
|
135
|
+
* logic you need
|
|
136
|
+
*/
|
|
137
|
+
headers?: Record<string, string | ((env: Record<string, string | undefined>) => string)> | ((env: Record<string, string | undefined>) => Record<string, string>);
|
|
138
|
+
};
|
|
136
139
|
export type ScalarSpec = {
|
|
137
140
|
type: string;
|
|
138
141
|
marshal?: (val: any) => any;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { ConfigFile } from './config';
|
|
2
|
-
import type { MutationArtifact, QueryArtifact, SubscriptionArtifact, SubscriptionSelection } from './types';
|
|
2
|
+
import type { FragmentArtifact, 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
7
|
export declare function marshalInputs<T>({ artifact, input, config, rootType, }: {
|
|
8
|
-
artifact: QueryArtifact | MutationArtifact | SubscriptionArtifact;
|
|
8
|
+
artifact: QueryArtifact | MutationArtifact | SubscriptionArtifact | FragmentArtifact;
|
|
9
9
|
input: unknown;
|
|
10
10
|
rootType?: string;
|
|
11
11
|
config: ConfigFile;
|
|
12
12
|
}): {} | null | undefined;
|
|
13
13
|
export declare function unmarshalSelection(config: ConfigFile, selection: SubscriptionSelection, data: any): {} | null | undefined;
|
|
14
14
|
export declare function isScalar(config: ConfigFile, type: string): boolean;
|
|
15
|
-
export declare function parseScalar(config: ConfigFile, type: string, value
|
|
15
|
+
export declare function parseScalar(config: ConfigFile, type: string, value?: string): string | number | boolean | undefined;
|