houdini 1.0.0-next.2 → 1.0.0-next.3
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 +1380 -1190
- package/build/cmd-esm/index.js +1380 -1190
- package/build/codegen/generators/typescript/documentTypes.d.ts +2 -0
- package/build/codegen/generators/typescript/{imperativeCache.d.ts → imperativeTypeDef.d.ts} +1 -1
- package/build/codegen/transforms/fragmentVariables.d.ts +1 -0
- package/build/codegen-cjs/index.js +1225 -1037
- package/build/codegen-esm/index.js +1225 -1037
- package/build/lib/config.d.ts +1 -1
- package/build/lib/walk.d.ts +4 -1
- package/build/lib-cjs/index.js +10 -10
- package/build/lib-esm/index.js +10 -10
- package/build/runtime/cache/lists.d.ts +1 -0
- package/build/runtime/generated.d.ts +1 -0
- package/build/runtime/index.d.ts +1 -1
- package/build/runtime/lib/config.d.ts +21 -22
- package/build/runtime/lib/scalars.d.ts +2 -2
- package/build/runtime/public/cache.d.ts +19 -6
- package/build/runtime/public/record.d.ts +17 -17
- package/build/runtime/public/tests/test.d.ts +43 -0
- package/build/runtime/public/types.d.ts +8 -0
- package/build/runtime-cjs/cache/lists.d.ts +1 -0
- package/build/runtime-cjs/cache/lists.js +3 -0
- package/build/runtime-cjs/generated.d.ts +1 -0
- package/build/runtime-cjs/index.d.ts +1 -1
- package/build/runtime-cjs/lib/config.d.ts +21 -22
- package/build/runtime-cjs/lib/scalars.d.ts +2 -2
- package/build/runtime-cjs/public/cache.d.ts +19 -6
- package/build/runtime-cjs/public/cache.js +29 -32
- package/build/runtime-cjs/public/list.js +6 -28
- package/build/runtime-cjs/public/record.d.ts +17 -17
- package/build/runtime-cjs/public/record.js +22 -188
- package/build/runtime-cjs/public/tests/test.d.ts +43 -0
- 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/lists.d.ts +1 -0
- package/build/runtime-esm/cache/lists.js +3 -0
- package/build/runtime-esm/generated.d.ts +1 -0
- package/build/runtime-esm/index.d.ts +1 -1
- package/build/runtime-esm/lib/config.d.ts +21 -22
- package/build/runtime-esm/lib/scalars.d.ts +2 -2
- package/build/runtime-esm/public/cache.d.ts +19 -6
- package/build/runtime-esm/public/cache.js +28 -30
- package/build/runtime-esm/public/list.js +6 -28
- package/build/runtime-esm/public/record.d.ts +17 -17
- package/build/runtime-esm/public/record.js +21 -184
- package/build/runtime-esm/public/tests/test.d.ts +43 -0
- package/build/runtime-esm/public/tests/test.js +26 -1
- package/build/runtime-esm/public/types.d.ts +8 -0
- package/build/test-cjs/index.js +1233 -1046
- package/build/test-esm/index.js +1233 -1046
- package/build/vite-cjs/index.js +1234 -1046
- package/build/vite-esm/index.js +1234 -1046
- package/package.json +1 -1
package/build/lib/config.d.ts
CHANGED
|
@@ -81,7 +81,7 @@ export declare class Config {
|
|
|
81
81
|
pluginRuntimeDirectory(name: string): string;
|
|
82
82
|
get pluginRootDirectory(): string;
|
|
83
83
|
pluginDirectory(name: string): string;
|
|
84
|
-
get
|
|
84
|
+
get loadDirective(): string;
|
|
85
85
|
get maskEnableDirective(): string;
|
|
86
86
|
get maskDisableDirective(): string;
|
|
87
87
|
get listDirective(): string;
|
package/build/lib/walk.d.ts
CHANGED
|
@@ -17,7 +17,10 @@ export type EmbeddedGraphqlDocument = {
|
|
|
17
17
|
parent: BaseNode;
|
|
18
18
|
};
|
|
19
19
|
type GraphqlTagWalker = {
|
|
20
|
-
where?: (tag: graphql.DocumentNode
|
|
20
|
+
where?: (tag: graphql.DocumentNode, ast: {
|
|
21
|
+
node: BaseNode;
|
|
22
|
+
parent: BaseNode;
|
|
23
|
+
}) => boolean;
|
|
21
24
|
dependency?: (fp: string) => void;
|
|
22
25
|
tag: (tag: EmbeddedGraphqlDocument) => void | Promise<void>;
|
|
23
26
|
};
|
package/build/lib-cjs/index.js
CHANGED
|
@@ -63140,8 +63140,7 @@ var Config = class {
|
|
|
63140
63140
|
types: types4 = {},
|
|
63141
63141
|
logLevel,
|
|
63142
63142
|
defaultFragmentMasking = "enable",
|
|
63143
|
-
|
|
63144
|
-
schemaPollHeaders = {},
|
|
63143
|
+
watchSchema,
|
|
63145
63144
|
projectDir
|
|
63146
63145
|
} = this.configFile;
|
|
63147
63146
|
if (typeof schema === "string") {
|
|
@@ -63174,8 +63173,8 @@ var Config = class {
|
|
|
63174
63173
|
this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
|
|
63175
63174
|
this.defaultFragmentMasking = defaultFragmentMasking;
|
|
63176
63175
|
this.routesDir = join2(this.projectRoot, "src", "routes");
|
|
63177
|
-
this.schemaPollInterval =
|
|
63178
|
-
this.schemaPollHeaders =
|
|
63176
|
+
this.schemaPollInterval = watchSchema?.interval ?? 2e3;
|
|
63177
|
+
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
63179
63178
|
this.rootDir = join2(this.projectRoot, "$houdini");
|
|
63180
63179
|
if (defaultKeys) {
|
|
63181
63180
|
this.defaultKeys = defaultKeys;
|
|
@@ -63188,11 +63187,12 @@ var Config = class {
|
|
|
63188
63187
|
}
|
|
63189
63188
|
}
|
|
63190
63189
|
async apiURL() {
|
|
63191
|
-
|
|
63190
|
+
const apiURL = this.configFile.watchSchema?.url;
|
|
63191
|
+
if (!apiURL) {
|
|
63192
63192
|
return "";
|
|
63193
63193
|
}
|
|
63194
63194
|
const env = await this.getEnv();
|
|
63195
|
-
return this.processEnvValues(env,
|
|
63195
|
+
return this.processEnvValues(env, apiURL);
|
|
63196
63196
|
}
|
|
63197
63197
|
get include() {
|
|
63198
63198
|
if (this.configFile.include) {
|
|
@@ -63396,8 +63396,8 @@ var Config = class {
|
|
|
63396
63396
|
pluginDirectory(name) {
|
|
63397
63397
|
return join2(this.pluginRootDirectory, name);
|
|
63398
63398
|
}
|
|
63399
|
-
get
|
|
63400
|
-
return "
|
|
63399
|
+
get loadDirective() {
|
|
63400
|
+
return "load";
|
|
63401
63401
|
}
|
|
63402
63402
|
get maskEnableDirective() {
|
|
63403
63403
|
return "mask_enable";
|
|
@@ -63514,7 +63514,7 @@ var Config = class {
|
|
|
63514
63514
|
this.withDirective,
|
|
63515
63515
|
this.paginateDirective,
|
|
63516
63516
|
this.cacheDirective,
|
|
63517
|
-
this.
|
|
63517
|
+
this.loadDirective,
|
|
63518
63518
|
this.maskEnableDirective,
|
|
63519
63519
|
this.maskDisableDirective
|
|
63520
63520
|
].includes(name.value) || this.isDeleteDirective(name.value);
|
|
@@ -64124,7 +64124,7 @@ async function find_graphql(config, parsedScript, walker) {
|
|
|
64124
64124
|
return;
|
|
64125
64125
|
}
|
|
64126
64126
|
const parsedTag = graphql4.parse(documentString);
|
|
64127
|
-
if (walker.where && !walker.where(parsedTag)) {
|
|
64127
|
+
if (walker.where && !walker.where(parsedTag, { node, parent })) {
|
|
64128
64128
|
return;
|
|
64129
64129
|
}
|
|
64130
64130
|
const definition = config.extractDefinition(parsedTag);
|
package/build/lib-esm/index.js
CHANGED
|
@@ -63097,8 +63097,7 @@ var Config = class {
|
|
|
63097
63097
|
types: types4 = {},
|
|
63098
63098
|
logLevel,
|
|
63099
63099
|
defaultFragmentMasking = "enable",
|
|
63100
|
-
|
|
63101
|
-
schemaPollHeaders = {},
|
|
63100
|
+
watchSchema,
|
|
63102
63101
|
projectDir
|
|
63103
63102
|
} = this.configFile;
|
|
63104
63103
|
if (typeof schema === "string") {
|
|
@@ -63131,8 +63130,8 @@ var Config = class {
|
|
|
63131
63130
|
this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
|
|
63132
63131
|
this.defaultFragmentMasking = defaultFragmentMasking;
|
|
63133
63132
|
this.routesDir = join2(this.projectRoot, "src", "routes");
|
|
63134
|
-
this.schemaPollInterval =
|
|
63135
|
-
this.schemaPollHeaders =
|
|
63133
|
+
this.schemaPollInterval = watchSchema?.interval ?? 2e3;
|
|
63134
|
+
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
63136
63135
|
this.rootDir = join2(this.projectRoot, "$houdini");
|
|
63137
63136
|
if (defaultKeys) {
|
|
63138
63137
|
this.defaultKeys = defaultKeys;
|
|
@@ -63145,11 +63144,12 @@ var Config = class {
|
|
|
63145
63144
|
}
|
|
63146
63145
|
}
|
|
63147
63146
|
async apiURL() {
|
|
63148
|
-
|
|
63147
|
+
const apiURL = this.configFile.watchSchema?.url;
|
|
63148
|
+
if (!apiURL) {
|
|
63149
63149
|
return "";
|
|
63150
63150
|
}
|
|
63151
63151
|
const env = await this.getEnv();
|
|
63152
|
-
return this.processEnvValues(env,
|
|
63152
|
+
return this.processEnvValues(env, apiURL);
|
|
63153
63153
|
}
|
|
63154
63154
|
get include() {
|
|
63155
63155
|
if (this.configFile.include) {
|
|
@@ -63353,8 +63353,8 @@ var Config = class {
|
|
|
63353
63353
|
pluginDirectory(name) {
|
|
63354
63354
|
return join2(this.pluginRootDirectory, name);
|
|
63355
63355
|
}
|
|
63356
|
-
get
|
|
63357
|
-
return "
|
|
63356
|
+
get loadDirective() {
|
|
63357
|
+
return "load";
|
|
63358
63358
|
}
|
|
63359
63359
|
get maskEnableDirective() {
|
|
63360
63360
|
return "mask_enable";
|
|
@@ -63471,7 +63471,7 @@ var Config = class {
|
|
|
63471
63471
|
this.withDirective,
|
|
63472
63472
|
this.paginateDirective,
|
|
63473
63473
|
this.cacheDirective,
|
|
63474
|
-
this.
|
|
63474
|
+
this.loadDirective,
|
|
63475
63475
|
this.maskEnableDirective,
|
|
63476
63476
|
this.maskDisableDirective
|
|
63477
63477
|
].includes(name.value) || this.isDeleteDirective(name.value);
|
|
@@ -64081,7 +64081,7 @@ async function find_graphql(config, parsedScript, walker) {
|
|
|
64081
64081
|
return;
|
|
64082
64082
|
}
|
|
64083
64083
|
const parsedTag = graphql4.parse(documentString);
|
|
64084
|
-
if (walker.where && !walker.where(parsedTag)) {
|
|
64084
|
+
if (walker.where && !walker.where(parsedTag, { node, parent })) {
|
|
64085
64085
|
return;
|
|
64086
64086
|
}
|
|
64087
64087
|
const definition = config.extractDefinition(parsedTag);
|
|
@@ -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;
|
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;
|
|
@@ -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
|
*/
|
|
@@ -90,20 +81,9 @@ export type ConfigFile = {
|
|
|
90
81
|
*/
|
|
91
82
|
defaultFragmentMasking?: 'enable' | 'disable';
|
|
92
83
|
/**
|
|
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
|
|
84
|
+
* Configure the dev environment to watch a remote schema for changes
|
|
105
85
|
*/
|
|
106
|
-
|
|
86
|
+
watchSchema?: WatchSchemaConfig;
|
|
107
87
|
/**
|
|
108
88
|
* An object describing the plugins enabled for the project
|
|
109
89
|
*/
|
|
@@ -133,6 +113,25 @@ export type TypeConfig = {
|
|
|
133
113
|
};
|
|
134
114
|
};
|
|
135
115
|
};
|
|
116
|
+
export type WatchSchemaConfig = {
|
|
117
|
+
/**
|
|
118
|
+
* A url to use to pull the schema. For more information: https://www.houdinigraphql.com/api/cli#generate
|
|
119
|
+
*/
|
|
120
|
+
url: string | ((env: Record<string, string | undefined>) => string);
|
|
121
|
+
/**
|
|
122
|
+
* sets the amount of time between each request in milliseconds (default 2 seconds).
|
|
123
|
+
* To limit the schema introspection to just on the start of the server, set interval to 0.
|
|
124
|
+
* To disable the schema introspection, set interval to null.
|
|
125
|
+
*/
|
|
126
|
+
interval?: number | null;
|
|
127
|
+
/**
|
|
128
|
+
* An object containing the environment variables you want passed onto the api when polling for a new schema.
|
|
129
|
+
* The keys dictate the header names. If the value is a string, the corresponding environment variable will be used
|
|
130
|
+
* directly. If the value is a function, the current environment will be passed to your function so you can perform any
|
|
131
|
+
* logic you need
|
|
132
|
+
*/
|
|
133
|
+
headers?: Record<string, string | ((env: Record<string, string | undefined>) => string)> | ((env: Record<string, string | undefined>) => Record<string, string>);
|
|
134
|
+
};
|
|
136
135
|
export type ScalarSpec = {
|
|
137
136
|
type: string;
|
|
138
137
|
marshal?: (val: any) => any;
|
|
@@ -1,11 +1,11 @@
|
|
|
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;
|
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
import type { Cache as _Cache } from '../cache/cache';
|
|
2
|
-
import
|
|
2
|
+
import { type QueryArtifact } from '../lib';
|
|
3
3
|
import { ListCollection } from './list';
|
|
4
4
|
import { Record } from './record';
|
|
5
|
-
import type { CacheTypeDef, IDFields, TypeNames, ValidLists } from './types';
|
|
5
|
+
import type { CacheTypeDef, IDFields, QueryInput, QueryList, QueryValue, TypeNames, ValidLists } from './types';
|
|
6
6
|
export declare class Cache<Def extends CacheTypeDef> {
|
|
7
7
|
_internal_unstable: _Cache;
|
|
8
8
|
constructor(cache: _Cache);
|
|
9
9
|
validateInstabilityWarning(): void;
|
|
10
|
-
setFieldType(...args: Parameters<SchemaManager['setFieldType']>): void;
|
|
11
|
-
get root(): Record<Def, '__ROOT__'>;
|
|
12
10
|
get<T extends TypeNames<Def>>(type: T, data: IDFields<Def, T>): Record<Def, T>;
|
|
13
|
-
get config(): import("
|
|
11
|
+
get config(): import("../lib").ConfigFile;
|
|
14
12
|
list<Name extends ValidLists<Def>>(name: Name, { parentID, allLists }?: {
|
|
15
13
|
parentID?: string;
|
|
16
14
|
allLists?: boolean;
|
|
17
15
|
}): ListCollection<Def, Name>;
|
|
16
|
+
read<_Query extends {
|
|
17
|
+
artifact: QueryArtifact;
|
|
18
|
+
}>({ query, variables, }: {
|
|
19
|
+
query: _Query;
|
|
20
|
+
variables?: QueryInput<QueryList<Def>, _Query>;
|
|
21
|
+
}): {
|
|
22
|
+
data: QueryValue<QueryList<Def>, _Query> | null;
|
|
23
|
+
partial: boolean;
|
|
24
|
+
};
|
|
25
|
+
write<_Query extends {
|
|
26
|
+
artifact: QueryArtifact;
|
|
27
|
+
}>({ query, variables, data, }: {
|
|
28
|
+
query: _Query;
|
|
29
|
+
data: QueryValue<QueryList<Def>, _Query>;
|
|
30
|
+
variables?: QueryInput<QueryList<Def>, _Query>;
|
|
31
|
+
}): void;
|
|
18
32
|
}
|
|
19
|
-
export declare function _typeInfo<Def extends CacheTypeDef>(cache: Cache<Def>, type: string, field: string): TypeInfo;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { FragmentArtifact } from '../lib/types';
|
|
1
2
|
import type { Cache } from './cache';
|
|
2
|
-
import type {
|
|
3
|
+
import type { CacheTypeDef, FragmentList, FragmentValue, FragmentVariables, ValidTypes } from './types';
|
|
3
4
|
export declare class Record<Def extends CacheTypeDef, Type extends ValidTypes<Def>> {
|
|
4
5
|
#private;
|
|
5
6
|
type: string;
|
|
@@ -10,22 +11,21 @@ export declare class Record<Def extends CacheTypeDef, Type extends ValidTypes<De
|
|
|
10
11
|
idFields: {};
|
|
11
12
|
id: string;
|
|
12
13
|
});
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
read<_Fragment extends {
|
|
15
|
+
artifact: FragmentArtifact;
|
|
16
|
+
}>({ fragment, variables, }: {
|
|
17
|
+
fragment: _Fragment;
|
|
18
|
+
variables?: FragmentVariables<FragmentList<Def, Type>, _Fragment>;
|
|
19
|
+
}): {
|
|
20
|
+
data: FragmentValue<FragmentList<Def, Type>, _Fragment> | null;
|
|
21
|
+
partial: boolean;
|
|
22
|
+
};
|
|
23
|
+
write<_Fragment extends {
|
|
24
|
+
artifact: FragmentArtifact;
|
|
25
|
+
}, _Variable>(args: {
|
|
26
|
+
fragment: _Fragment;
|
|
27
|
+
data: FragmentValue<FragmentList<Def, Type>, _Fragment>;
|
|
28
|
+
variables?: FragmentVariables<FragmentList<Def, Type>, _Fragment>;
|
|
17
29
|
}): void;
|
|
18
|
-
get<Field extends TypeFieldNames<Def, Type>>({ field, args, }: {
|
|
19
|
-
field: Field;
|
|
20
|
-
args?: ArgType<Def, Type, Field>;
|
|
21
|
-
}): FieldType<Def, Type, Field>;
|
|
22
30
|
delete(): void;
|
|
23
31
|
}
|
|
24
|
-
export declare function computeKey({ field, args }: {
|
|
25
|
-
field: string;
|
|
26
|
-
args?: {
|
|
27
|
-
[key: string]: any;
|
|
28
|
-
};
|
|
29
|
-
}): string;
|
|
30
|
-
export declare const stringifyObjectWithNoQuotesOnKeys: (obj_from_json: {}) => string;
|
|
31
|
-
export declare function marshalNestedList(list: any[]): any[];
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { type SubscriptionSelection, type FragmentArtifact, type QueryArtifact } from '../../lib';
|
|
1
2
|
import { Cache } from '../cache';
|
|
2
3
|
import type { Record } from '../record';
|
|
3
4
|
type CacheTypeDef = {
|
|
4
5
|
types: {
|
|
5
6
|
__ROOT__: {
|
|
6
7
|
idFields: {};
|
|
8
|
+
fragments: [];
|
|
7
9
|
fields: {
|
|
8
10
|
test: {
|
|
9
11
|
type: number | null;
|
|
@@ -39,6 +41,19 @@ type CacheTypeDef = {
|
|
|
39
41
|
idFields: {
|
|
40
42
|
id: string;
|
|
41
43
|
};
|
|
44
|
+
fragments: [
|
|
45
|
+
[
|
|
46
|
+
{
|
|
47
|
+
artifact: FragmentArtifact;
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
firstName: string;
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
pattern: string;
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
];
|
|
42
57
|
fields: {
|
|
43
58
|
firstName: {
|
|
44
59
|
type: string;
|
|
@@ -62,6 +77,7 @@ type CacheTypeDef = {
|
|
|
62
77
|
idFields: {
|
|
63
78
|
id: string;
|
|
64
79
|
};
|
|
80
|
+
fragments: [];
|
|
65
81
|
fields: {
|
|
66
82
|
name: {
|
|
67
83
|
type: string | null;
|
|
@@ -85,6 +101,7 @@ type CacheTypeDef = {
|
|
|
85
101
|
idFields: {
|
|
86
102
|
id: string;
|
|
87
103
|
};
|
|
104
|
+
fragments: [];
|
|
88
105
|
fields: {
|
|
89
106
|
name: {
|
|
90
107
|
type: string | null;
|
|
@@ -97,6 +114,26 @@ type CacheTypeDef = {
|
|
|
97
114
|
};
|
|
98
115
|
};
|
|
99
116
|
};
|
|
117
|
+
queries: [
|
|
118
|
+
[
|
|
119
|
+
{
|
|
120
|
+
artifact: QueryArtifact;
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
viewer: {
|
|
124
|
+
id: string;
|
|
125
|
+
firstName: string;
|
|
126
|
+
__typename: string;
|
|
127
|
+
parent: {
|
|
128
|
+
id: string;
|
|
129
|
+
firstName: string;
|
|
130
|
+
__typename: string;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
any
|
|
135
|
+
]
|
|
136
|
+
];
|
|
100
137
|
lists: {
|
|
101
138
|
All_Pets: {
|
|
102
139
|
types: 'User' | 'Cat';
|
|
@@ -111,4 +148,10 @@ type CacheTypeDef = {
|
|
|
111
148
|
};
|
|
112
149
|
};
|
|
113
150
|
export declare const testCache: () => Cache<CacheTypeDef>;
|
|
151
|
+
export declare const testFragment: (selection: SubscriptionSelection) => {
|
|
152
|
+
artifact: FragmentArtifact;
|
|
153
|
+
};
|
|
154
|
+
export declare const testQuery: (selection: SubscriptionSelection) => {
|
|
155
|
+
artifact: QueryArtifact;
|
|
156
|
+
};
|
|
114
157
|
export {};
|
|
@@ -11,6 +11,7 @@ export type CacheTypeDef = {
|
|
|
11
11
|
type: any;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
+
fragments: [any, any, any][];
|
|
14
15
|
};
|
|
15
16
|
};
|
|
16
17
|
lists: {
|
|
@@ -19,11 +20,14 @@ export type CacheTypeDef = {
|
|
|
19
20
|
filters: any;
|
|
20
21
|
};
|
|
21
22
|
};
|
|
23
|
+
queries: [any, any, any][];
|
|
22
24
|
};
|
|
23
25
|
export type ValidTypes<Def extends CacheTypeDef> = keyof Def['types'];
|
|
24
26
|
export type TypeFields<Def extends CacheTypeDef, Type extends keyof Def['types']> = Def['types'][Type]['fields'];
|
|
25
27
|
export type TypeFieldNames<Def extends CacheTypeDef, Type extends keyof Def['types']> = Extract<keyof TypeFields<Def, Type>, string>;
|
|
26
28
|
export type TypeNames<Def extends CacheTypeDef> = Extract<Exclude<ValidTypes<Def>, '__ROOT__'>, string>;
|
|
29
|
+
export type FragmentList<Def extends CacheTypeDef, Type extends ValidTypes<Def>> = Def['types'][Type]['fragments'];
|
|
30
|
+
export type QueryList<Def extends CacheTypeDef> = Def['queries'];
|
|
27
31
|
export type IDFields<Def extends CacheTypeDef, Type extends keyof Def['types']> = Def['types'][Type]['idFields'];
|
|
28
32
|
export type ProxyUnion<Def extends CacheTypeDef, U> = U extends null ? null : U extends TypeNames<Def> ? Record<Def, U> : never;
|
|
29
33
|
export type FieldType<Def extends CacheTypeDef, Type extends keyof Def['types'], Field extends keyof TypeFields<Def, Type>> = TypeFields<Def, Type>[Field]['type'];
|
|
@@ -34,3 +38,7 @@ export type ListFilters<Def extends CacheTypeDef, ListName extends ValidLists<De
|
|
|
34
38
|
must_not?: Def['lists'][ListName]['filters'];
|
|
35
39
|
} : never;
|
|
36
40
|
export type ListType<Def extends CacheTypeDef, Name extends ValidLists<Def>> = ProxyUnion<Def, Def['lists'][Name]['types']>;
|
|
41
|
+
export type FragmentVariables<_List, _Target> = _List extends [infer Head, ...infer Rest] ? Head extends [infer _Key, infer _Value, infer _Input] ? _Key extends _Target ? _Input : FragmentValue<Rest, _Target> : 'Encountered unknown fragment. Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).' : 'Encountered unknown fragment. Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).';
|
|
42
|
+
export type FragmentValue<List, _Target> = List extends [infer Head, ...infer Rest] ? Head extends [infer _Key, infer _Value, infer _Input] ? _Key extends _Target ? _Value : FragmentValue<Rest, _Target> : 'Encountered unknown fragment. Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).' : 'Encountered unknown fragment. Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).';
|
|
43
|
+
export type QueryValue<List, _Target> = List extends [infer Head, ...infer Rest] ? Head extends [infer _Key, infer _Value, infer _Input] ? _Key extends _Target ? _Value : QueryValue<Rest, _Target> : 'Encountered unknown query.Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).' : 'Encountered unknown query.Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).';
|
|
44
|
+
export type QueryInput<List, _Target> = List extends [infer Head, ...infer Rest] ? Head extends [infer _Key, infer _Value, infer _Input] ? _Key extends _Target ? _Input : QueryValue<Rest, _Target> : 'Encountered unknown query.Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).' : 'Encountered unknown query.Please make sure your runtime is up to date (ie, `vite dev` or `vite build`).';
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -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
|
*/
|
|
@@ -90,20 +81,9 @@ export type ConfigFile = {
|
|
|
90
81
|
*/
|
|
91
82
|
defaultFragmentMasking?: 'enable' | 'disable';
|
|
92
83
|
/**
|
|
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
|
|
84
|
+
* Configure the dev environment to watch a remote schema for changes
|
|
105
85
|
*/
|
|
106
|
-
|
|
86
|
+
watchSchema?: WatchSchemaConfig;
|
|
107
87
|
/**
|
|
108
88
|
* An object describing the plugins enabled for the project
|
|
109
89
|
*/
|
|
@@ -133,6 +113,25 @@ export type TypeConfig = {
|
|
|
133
113
|
};
|
|
134
114
|
};
|
|
135
115
|
};
|
|
116
|
+
export type WatchSchemaConfig = {
|
|
117
|
+
/**
|
|
118
|
+
* A url to use to pull the schema. For more information: https://www.houdinigraphql.com/api/cli#generate
|
|
119
|
+
*/
|
|
120
|
+
url: string | ((env: Record<string, string | undefined>) => string);
|
|
121
|
+
/**
|
|
122
|
+
* sets the amount of time between each request in milliseconds (default 2 seconds).
|
|
123
|
+
* To limit the schema introspection to just on the start of the server, set interval to 0.
|
|
124
|
+
* To disable the schema introspection, set interval to null.
|
|
125
|
+
*/
|
|
126
|
+
interval?: number | null;
|
|
127
|
+
/**
|
|
128
|
+
* An object containing the environment variables you want passed onto the api when polling for a new schema.
|
|
129
|
+
* The keys dictate the header names. If the value is a string, the corresponding environment variable will be used
|
|
130
|
+
* directly. If the value is a function, the current environment will be passed to your function so you can perform any
|
|
131
|
+
* logic you need
|
|
132
|
+
*/
|
|
133
|
+
headers?: Record<string, string | ((env: Record<string, string | undefined>) => string)> | ((env: Record<string, string | undefined>) => Record<string, string>);
|
|
134
|
+
};
|
|
136
135
|
export type ScalarSpec = {
|
|
137
136
|
type: string;
|
|
138
137
|
marshal?: (val: any) => any;
|
|
@@ -1,11 +1,11 @@
|
|
|
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;
|
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
import type { Cache as _Cache } from '../cache/cache';
|
|
2
|
-
import
|
|
2
|
+
import { type QueryArtifact } from '../lib';
|
|
3
3
|
import { ListCollection } from './list';
|
|
4
4
|
import { Record } from './record';
|
|
5
|
-
import type { CacheTypeDef, IDFields, TypeNames, ValidLists } from './types';
|
|
5
|
+
import type { CacheTypeDef, IDFields, QueryInput, QueryList, QueryValue, TypeNames, ValidLists } from './types';
|
|
6
6
|
export declare class Cache<Def extends CacheTypeDef> {
|
|
7
7
|
_internal_unstable: _Cache;
|
|
8
8
|
constructor(cache: _Cache);
|
|
9
9
|
validateInstabilityWarning(): void;
|
|
10
|
-
setFieldType(...args: Parameters<SchemaManager['setFieldType']>): void;
|
|
11
|
-
get root(): Record<Def, '__ROOT__'>;
|
|
12
10
|
get<T extends TypeNames<Def>>(type: T, data: IDFields<Def, T>): Record<Def, T>;
|
|
13
|
-
get config(): import("
|
|
11
|
+
get config(): import("../lib").ConfigFile;
|
|
14
12
|
list<Name extends ValidLists<Def>>(name: Name, { parentID, allLists }?: {
|
|
15
13
|
parentID?: string;
|
|
16
14
|
allLists?: boolean;
|
|
17
15
|
}): ListCollection<Def, Name>;
|
|
16
|
+
read<_Query extends {
|
|
17
|
+
artifact: QueryArtifact;
|
|
18
|
+
}>({ query, variables, }: {
|
|
19
|
+
query: _Query;
|
|
20
|
+
variables?: QueryInput<QueryList<Def>, _Query>;
|
|
21
|
+
}): {
|
|
22
|
+
data: QueryValue<QueryList<Def>, _Query> | null;
|
|
23
|
+
partial: boolean;
|
|
24
|
+
};
|
|
25
|
+
write<_Query extends {
|
|
26
|
+
artifact: QueryArtifact;
|
|
27
|
+
}>({ query, variables, data, }: {
|
|
28
|
+
query: _Query;
|
|
29
|
+
data: QueryValue<QueryList<Def>, _Query>;
|
|
30
|
+
variables?: QueryInput<QueryList<Def>, _Query>;
|
|
31
|
+
}): void;
|
|
18
32
|
}
|
|
19
|
-
export declare function _typeInfo<Def extends CacheTypeDef>(cache: Cache<Def>, type: string, field: string): TypeInfo;
|