houdini 1.0.0-next.4 → 1.0.0-next.5
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 +1217 -1021
- package/build/cmd-esm/index.js +1217 -1021
- package/build/codegen/generators/artifacts/utils.d.ts +0 -1
- package/build/codegen-cjs/index.js +810 -676
- package/build/codegen-esm/index.js +810 -676
- package/build/lib/config.d.ts +10 -90
- 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/pipeline.d.ts +1 -1
- package/build/lib/plugin.d.ts +2 -0
- package/build/lib/types.d.ts +250 -2
- package/build/lib-cjs/index.js +351 -162
- package/build/lib-esm/index.js +349 -162
- package/build/runtime/cache/cache.d.ts +20 -3
- package/build/runtime/cache/staleManager.d.ts +30 -0
- package/build/runtime/cache/subscription.d.ts +2 -1
- package/build/runtime/client/plugins/subscription.d.ts +1 -2
- package/build/runtime/lib/config.d.ts +4 -0
- package/build/runtime/lib/index.d.ts +1 -0
- package/build/runtime/lib/key.d.ts +6 -0
- package/build/runtime/lib/types.d.ts +2 -2
- package/build/runtime/public/cache.d.ts +8 -1
- package/build/runtime/public/record.d.ts +11 -1
- package/build/runtime/public/tests/test.d.ts +9 -10
- package/build/runtime-cjs/cache/cache.d.ts +20 -3
- package/build/runtime-cjs/cache/cache.js +65 -6
- package/build/runtime-cjs/cache/gc.js +9 -0
- package/build/runtime-cjs/cache/staleManager.d.ts +30 -0
- package/build/runtime-cjs/cache/staleManager.js +95 -0
- package/build/runtime-cjs/cache/subscription.d.ts +2 -1
- package/build/runtime-cjs/cache/subscription.js +6 -3
- package/build/runtime-cjs/client/documentStore.js +1 -0
- package/build/runtime-cjs/client/plugins/cache.js +5 -3
- package/build/runtime-cjs/client/plugins/fetch.js +1 -0
- package/build/runtime-cjs/client/plugins/query.js +1 -0
- package/build/runtime-cjs/client/plugins/subscription.d.ts +1 -2
- package/build/runtime-cjs/client/plugins/subscription.js +2 -0
- package/build/runtime-cjs/lib/config.d.ts +4 -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/types.d.ts +2 -2
- package/build/runtime-cjs/public/cache.d.ts +8 -1
- package/build/runtime-cjs/public/cache.js +3 -0
- package/build/runtime-cjs/public/record.d.ts +11 -1
- package/build/runtime-cjs/public/record.js +8 -1
- package/build/runtime-cjs/public/tests/test.d.ts +9 -10
- package/build/runtime-esm/cache/cache.d.ts +20 -3
- package/build/runtime-esm/cache/cache.js +66 -7
- package/build/runtime-esm/cache/gc.js +9 -0
- package/build/runtime-esm/cache/staleManager.d.ts +30 -0
- package/build/runtime-esm/cache/staleManager.js +71 -0
- package/build/runtime-esm/cache/subscription.d.ts +2 -1
- package/build/runtime-esm/cache/subscription.js +6 -3
- package/build/runtime-esm/client/documentStore.js +1 -0
- package/build/runtime-esm/client/plugins/cache.js +5 -3
- package/build/runtime-esm/client/plugins/fetch.js +1 -0
- package/build/runtime-esm/client/plugins/query.js +1 -0
- package/build/runtime-esm/client/plugins/subscription.d.ts +1 -2
- package/build/runtime-esm/client/plugins/subscription.js +2 -0
- package/build/runtime-esm/lib/config.d.ts +4 -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/types.d.ts +2 -2
- package/build/runtime-esm/public/cache.d.ts +8 -1
- package/build/runtime-esm/public/cache.js +3 -0
- package/build/runtime-esm/public/record.d.ts +11 -1
- package/build/runtime-esm/public/record.js +8 -1
- package/build/runtime-esm/public/tests/test.d.ts +9 -10
- package/build/test-cjs/index.js +893 -747
- package/build/test-esm/index.js +893 -747
- package/build/vite-cjs/index.js +1195 -998
- package/build/vite-esm/index.js +1195 -998
- package/package.json +3 -2
package/build/lib/config.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import * as graphql from 'graphql';
|
|
2
|
-
import type { CustomPluginOptions, LoadResult, ObjectHook, PluginContext, ResolveIdResult } from 'rollup';
|
|
3
2
|
import type { ConfigFile } from '../runtime/lib';
|
|
4
3
|
import { CachePolicy } from '../runtime/lib';
|
|
5
|
-
import type {
|
|
6
|
-
import
|
|
7
|
-
export type PluginMeta =
|
|
4
|
+
import type { PluginConfig, PluginHooks } from './types';
|
|
5
|
+
import { LogLevel } from './types';
|
|
6
|
+
export type PluginMeta = PluginHooks & {
|
|
8
7
|
name: string;
|
|
9
|
-
|
|
10
|
-
version: string;
|
|
11
|
-
directory: string;
|
|
8
|
+
filepath: string;
|
|
12
9
|
};
|
|
13
10
|
export declare class Config {
|
|
11
|
+
#private;
|
|
14
12
|
filepath: string;
|
|
15
13
|
rootDir: string;
|
|
16
14
|
projectRoot: string;
|
|
@@ -26,7 +24,6 @@ export declare class Config {
|
|
|
26
24
|
internalListPosition: 'first' | 'last';
|
|
27
25
|
defaultListTarget: 'all' | null;
|
|
28
26
|
definitionsFolder?: string;
|
|
29
|
-
newSchema: string;
|
|
30
27
|
newDocuments: string;
|
|
31
28
|
defaultKeys: string[];
|
|
32
29
|
typeConfig: ConfigFile['types'];
|
|
@@ -50,6 +47,8 @@ export declare class Config {
|
|
|
50
47
|
processEnvValues(env: Record<string, string | undefined>, value: string | ((env: any) => string)): string | undefined;
|
|
51
48
|
pullHeaders(): Promise<any>;
|
|
52
49
|
sourceFiles(): Promise<string[]>;
|
|
50
|
+
set newSchema(value: string);
|
|
51
|
+
get newSchema(): string;
|
|
53
52
|
get artifactDirectory(): string;
|
|
54
53
|
get artifactDirectoryName(): string;
|
|
55
54
|
get artifactTypeDirectory(): string;
|
|
@@ -62,7 +61,6 @@ export declare class Config {
|
|
|
62
61
|
get typeIndexPath(): string;
|
|
63
62
|
get typeRootDir(): string;
|
|
64
63
|
get typeRootFile(): string;
|
|
65
|
-
findModule(pkg?: string, currentLocation?: string): string;
|
|
66
64
|
get runtimeSource(): string;
|
|
67
65
|
artifactTypePath(document: graphql.DocumentNode): string;
|
|
68
66
|
artifactPath(document: graphql.DocumentNode): string;
|
|
@@ -74,6 +72,7 @@ export declare class Config {
|
|
|
74
72
|
createDirectories(): void;
|
|
75
73
|
get compiledAssetsDir(): string;
|
|
76
74
|
compiledAssetPath(filepath: string): string;
|
|
75
|
+
excludeFile(filepath: string): boolean;
|
|
77
76
|
includeFile(filepath: string, { root, ignore_plugins, }?: {
|
|
78
77
|
root?: string;
|
|
79
78
|
ignore_plugins?: boolean;
|
|
@@ -119,7 +118,7 @@ export declare class Config {
|
|
|
119
118
|
isToggleFragment(name: string): boolean;
|
|
120
119
|
listRemoveFragment(name: string): string;
|
|
121
120
|
isInternalEnum(node: graphql.EnumTypeDefinitionNode): boolean;
|
|
122
|
-
isInternalDirective(
|
|
121
|
+
isInternalDirective(name: string): boolean;
|
|
123
122
|
isListFragment(name: string): boolean;
|
|
124
123
|
isListOperationDirective(name: string): boolean;
|
|
125
124
|
isFragmentForList(listName: string, fragmentName: string): boolean;
|
|
@@ -130,87 +129,8 @@ export declare class Config {
|
|
|
130
129
|
extractQueryDefinition(document: graphql.DocumentNode): graphql.OperationDefinitionNode;
|
|
131
130
|
variableFunctionName(name: string): string;
|
|
132
131
|
}
|
|
133
|
-
export declare function readConfigFile(configPath?: string): Promise<ConfigFile>;
|
|
134
132
|
export declare function getConfig({ configPath, noSchema, ...extraConfig }?: PluginConfig & {
|
|
135
133
|
noSchema?: boolean;
|
|
136
134
|
}): Promise<Config>;
|
|
137
|
-
export declare
|
|
138
|
-
Full = "full",
|
|
139
|
-
Summary = "summary",
|
|
140
|
-
ShortSummary = "short-summary",
|
|
141
|
-
Quiet = "quiet"
|
|
142
|
-
}
|
|
143
|
-
export type PluginFactory = (args?: PluginConfig) => Promise<Plugin>;
|
|
135
|
+
export declare function readConfigFile(configPath?: string): Promise<ConfigFile>;
|
|
144
136
|
export declare const orderedPlugins: (plugins: PluginMeta[]) => PluginMeta[];
|
|
145
|
-
export type Plugin = {
|
|
146
|
-
order?: 'before' | 'after' | 'core';
|
|
147
|
-
extensions?: string[];
|
|
148
|
-
transform_runtime?: Record<string, (args: {
|
|
149
|
-
config: Config;
|
|
150
|
-
content: string;
|
|
151
|
-
}) => string>;
|
|
152
|
-
after_load?: (config: Config) => Promise<void> | void;
|
|
153
|
-
artifact_data?: (config: Config, doc: CollectedGraphQLDocument) => Record<string, any>;
|
|
154
|
-
extract_documents?: (config: Config, filepath: string, content: string) => Promise<string[]> | string[];
|
|
155
|
-
generate?: GenerateHook;
|
|
156
|
-
client_plugins?: Record<string, null | Record<string, any>> | ((config: ConfigFile, pluginConfig: any) => Record<string, null | Record<string, any>>);
|
|
157
|
-
transform_file?: (page: TransformPage) => Promise<{
|
|
158
|
-
code: string;
|
|
159
|
-
}> | {
|
|
160
|
-
code: string;
|
|
161
|
-
};
|
|
162
|
-
index_file?: ModuleIndexTransform;
|
|
163
|
-
graphql_tag_return?: (args: {
|
|
164
|
-
config: Config;
|
|
165
|
-
doc: CollectedGraphQLDocument;
|
|
166
|
-
ensure_import: (import_args: {
|
|
167
|
-
identifier: string;
|
|
168
|
-
module: string;
|
|
169
|
-
}) => void;
|
|
170
|
-
}) => string | undefined;
|
|
171
|
-
env?: (args: {
|
|
172
|
-
env: any;
|
|
173
|
-
config: Config;
|
|
174
|
-
}) => Promise<Record<string, string>>;
|
|
175
|
-
validate?: (args: {
|
|
176
|
-
config: Config;
|
|
177
|
-
documents: CollectedGraphQLDocument[];
|
|
178
|
-
}) => Promise<void> | void;
|
|
179
|
-
vite?: {
|
|
180
|
-
resolveId?: ObjectHook<(this: PluginContext, source: string, importer: string | undefined, options: {
|
|
181
|
-
config: Config;
|
|
182
|
-
custom?: CustomPluginOptions;
|
|
183
|
-
ssr?: boolean;
|
|
184
|
-
isEntry: boolean;
|
|
185
|
-
}) => Promise<ResolveIdResult> | ResolveIdResult>;
|
|
186
|
-
load?: ObjectHook<(this: PluginContext, id: string, options: {
|
|
187
|
-
config: Config;
|
|
188
|
-
ssr?: boolean;
|
|
189
|
-
}) => Promise<LoadResult> | LoadResult>;
|
|
190
|
-
};
|
|
191
|
-
include?: (config: Config, filepath: string) => boolean | null | undefined;
|
|
192
|
-
};
|
|
193
|
-
type ModuleIndexTransform = (arg: {
|
|
194
|
-
config: Config;
|
|
195
|
-
content: string;
|
|
196
|
-
export_default_as(args: {
|
|
197
|
-
module: string;
|
|
198
|
-
as: string;
|
|
199
|
-
}): string;
|
|
200
|
-
export_star_from(args: {
|
|
201
|
-
module: string;
|
|
202
|
-
}): string;
|
|
203
|
-
plugin_root: string;
|
|
204
|
-
typedef: boolean;
|
|
205
|
-
documents: CollectedGraphQLDocument[];
|
|
206
|
-
}) => string;
|
|
207
|
-
export type GenerateHook = (args: GenerateHookInput) => Promise<void> | void;
|
|
208
|
-
export type GenerateHookInput = {
|
|
209
|
-
config: Config;
|
|
210
|
-
documents: CollectedGraphQLDocument[];
|
|
211
|
-
plugin_root: string;
|
|
212
|
-
};
|
|
213
|
-
export type PluginConfig = {
|
|
214
|
-
configPath?: string;
|
|
215
|
-
} & Partial<ConfigFile>;
|
|
216
|
-
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function deepMerge(filepath: string, ...targets: {}[]): {};
|
package/build/lib/graphql.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as graphql from 'graphql';
|
|
2
|
-
import type { Config } from '.';
|
|
2
|
+
import type { CollectedGraphQLDocument, Config } from '.';
|
|
3
3
|
export declare function getRootType(type: graphql.GraphQLType): graphql.GraphQLType;
|
|
4
|
-
export declare function hashDocument(document
|
|
4
|
+
export declare function hashDocument({ document, }: {
|
|
5
|
+
config: Config;
|
|
6
|
+
document: string | CollectedGraphQLDocument;
|
|
7
|
+
}): string;
|
|
5
8
|
type GraphQLParentType = graphql.GraphQLObjectType | graphql.GraphQLInputObjectType | graphql.GraphQLInterfaceType;
|
|
6
9
|
export declare function parentTypeFromAncestors(schema: graphql.GraphQLSchema, filepath: string, ancestors: readonly any[]): GraphQLParentType;
|
|
7
10
|
export declare function definitionFromAncestors(ancestors: readonly any[]): graphql.OperationDefinitionNode | graphql.FragmentDefinitionNode;
|
package/build/lib/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export * from './types';
|
|
|
9
9
|
export * from './constants';
|
|
10
10
|
export * from './introspection';
|
|
11
11
|
export * from './cleanupFiles';
|
|
12
|
+
export * from './deepMerge';
|
|
13
|
+
export * from './plugin';
|
|
12
14
|
export * from './walk';
|
|
13
15
|
export type { EmbeddedGraphqlDocument } from './walk';
|
|
14
16
|
export * as fs from './fs';
|
package/build/lib/pipeline.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Config } from './config';
|
|
2
|
-
export type Transform<_TransformType> = null | ((config: Config, documents: _TransformType) => Promise<void>);
|
|
2
|
+
export type Transform<_TransformType> = null | ((config: Config, documents: _TransformType) => Promise<void> | void);
|
|
3
3
|
export declare function runPipeline<_TransformType>(config: Config, pipeline: Transform<_TransformType>[], target: _TransformType): Promise<void>;
|
package/build/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type graphql from 'graphql';
|
|
2
2
|
import type * as recast from 'recast';
|
|
3
|
-
import type {
|
|
3
|
+
import type { CustomPluginOptions, LoadResult, ObjectHook, PluginContext, ResolveIdResult } from 'rollup';
|
|
4
|
+
import type { ConfigFile } from '../runtime/lib/config';
|
|
5
|
+
import type { ArtifactKind, BaseCompiledDocument, DocumentArtifact } from '../runtime/lib/types';
|
|
6
|
+
import type { TransformPage } from '../vite/houdini';
|
|
4
7
|
import type { Config } from './config';
|
|
5
8
|
type Program = recast.types.namedTypes.Program;
|
|
6
9
|
export type Maybe<T> = T | null | undefined;
|
|
@@ -11,16 +14,261 @@ export type TransformDocument = {
|
|
|
11
14
|
dependencies: string[];
|
|
12
15
|
filename: string;
|
|
13
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* The result of collecting documents from source code
|
|
19
|
+
*/
|
|
14
20
|
export type CollectedGraphQLDocument = {
|
|
21
|
+
/**
|
|
22
|
+
* The name of the document.
|
|
23
|
+
*/
|
|
24
|
+
name: string;
|
|
25
|
+
/**
|
|
26
|
+
* A field you can use to distinguish documents by type (query, mutation, subscription, fragment)
|
|
27
|
+
*/
|
|
15
28
|
kind: ArtifactKind;
|
|
29
|
+
/**
|
|
30
|
+
* The artifact generated for the document. This will only have a value in the last phase
|
|
31
|
+
* of the Generation Pipeline.
|
|
32
|
+
*/
|
|
33
|
+
artifact: DocumentArtifact | null;
|
|
34
|
+
/**
|
|
35
|
+
* The path of the file containing this document
|
|
36
|
+
*/
|
|
16
37
|
filename: string;
|
|
17
|
-
|
|
38
|
+
/**
|
|
39
|
+
* The parsed document. This value should be modified throughout the pipeline.
|
|
40
|
+
* */
|
|
18
41
|
document: graphql.DocumentNode;
|
|
42
|
+
/**
|
|
43
|
+
* The document that the user provided
|
|
44
|
+
* */
|
|
19
45
|
originalDocument: graphql.DocumentNode;
|
|
46
|
+
/**
|
|
47
|
+
* Whether an artifact should be generated for the document. This should be set to false for internal
|
|
48
|
+
* or virtual documents .
|
|
49
|
+
*/
|
|
20
50
|
generateArtifact: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Whether a runtime equivalent should be generated for the document. This should be set to false for internal
|
|
53
|
+
* or virtual documents .
|
|
54
|
+
*/
|
|
21
55
|
generateStore: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The original document string that the user passed
|
|
58
|
+
*/
|
|
22
59
|
originalString: string;
|
|
60
|
+
/**
|
|
61
|
+
* Refetch logic that has been built up throughout the pipeline
|
|
62
|
+
*/
|
|
23
63
|
refetch?: BaseCompiledDocument['refetch'];
|
|
24
64
|
};
|
|
65
|
+
export declare enum LogLevel {
|
|
66
|
+
Full = "full",
|
|
67
|
+
Summary = "summary",
|
|
68
|
+
ShortSummary = "short-summary",
|
|
69
|
+
Quiet = "quiet"
|
|
70
|
+
}
|
|
71
|
+
export type Plugin = (args?: PluginConfig) => Promise<(PluginHooks | PluginInit) | (PluginHooks | PluginInit)[] | null | false>;
|
|
72
|
+
export type PluginInit = {
|
|
73
|
+
__plugin_init__: boolean;
|
|
74
|
+
plugin: Plugin;
|
|
75
|
+
name: string;
|
|
76
|
+
config?: {};
|
|
77
|
+
local?: string;
|
|
78
|
+
with(config: {}): PluginInit;
|
|
79
|
+
};
|
|
80
|
+
export type PluginHooks = {
|
|
81
|
+
/**
|
|
82
|
+
* Specify the priority for the hook. The order is before -> core -> after.
|
|
83
|
+
* @default 'before'
|
|
84
|
+
*/
|
|
85
|
+
order?: 'before' | 'after' | 'core';
|
|
86
|
+
/**
|
|
87
|
+
* Add extensions to the list that houdini uses to find valid source files
|
|
88
|
+
*/
|
|
89
|
+
extensions?: string[];
|
|
90
|
+
/**
|
|
91
|
+
* A relative path from the file exporting your plugin to a runtime that will be
|
|
92
|
+
* automatically included with your
|
|
93
|
+
*/
|
|
94
|
+
include_runtime?: string | {
|
|
95
|
+
esm: string;
|
|
96
|
+
commonjs: string;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Transform the plugin's runtime while houdini is copying it .
|
|
100
|
+
* You must have passed a value to include_runtime for this hook to matter.
|
|
101
|
+
*/
|
|
102
|
+
transform_runtime?: Record<string, (args: {
|
|
103
|
+
config: Config;
|
|
104
|
+
content: string;
|
|
105
|
+
}) => string>;
|
|
106
|
+
/**
|
|
107
|
+
* Used to modify any values that the user passed to their config files. Configuration values
|
|
108
|
+
* that you return will be deeply merged with the previous value.
|
|
109
|
+
*/
|
|
110
|
+
config?: (old: ConfigFile) => ConfigFile | Promise<ConfigFile>;
|
|
111
|
+
/**
|
|
112
|
+
*
|
|
113
|
+
* Add environment variables to houdini's pipeline (ie, for schema polling headers, url, etc.)
|
|
114
|
+
*/
|
|
115
|
+
env?: (args: {
|
|
116
|
+
env: any;
|
|
117
|
+
config: Config;
|
|
118
|
+
}) => Promise<Record<string, string>>;
|
|
119
|
+
/**
|
|
120
|
+
* Invoked after all plugins have loaded and modified config values.
|
|
121
|
+
*/
|
|
122
|
+
after_load?: (args: {
|
|
123
|
+
config: Config;
|
|
124
|
+
}) => Promise<void> | void;
|
|
125
|
+
/**
|
|
126
|
+
* A filter for whether a file should be included in the the processing. Return true to include.
|
|
127
|
+
*/
|
|
128
|
+
include?: (args: {
|
|
129
|
+
config: Config;
|
|
130
|
+
filepath: string;
|
|
131
|
+
}) => boolean | null | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* A filter for whether a file should be included in the the processing. Return false to include.
|
|
134
|
+
*/
|
|
135
|
+
exclude?: (args: {
|
|
136
|
+
config: Config;
|
|
137
|
+
filepath: string;
|
|
138
|
+
}) => boolean | null | undefined;
|
|
139
|
+
/**
|
|
140
|
+
* Configure the codegen pipeline to extract graphql documents out of a file.
|
|
141
|
+
*/
|
|
142
|
+
extract_documents?: (args: {
|
|
143
|
+
config: Config;
|
|
144
|
+
filepath: string;
|
|
145
|
+
content: string;
|
|
146
|
+
}) => Promise<string[] | null> | string[] | null;
|
|
147
|
+
/**
|
|
148
|
+
* Can be used to add custom definitions to your project's schema. Definitions (like directives) added
|
|
149
|
+
* here are automatically removed from the document before they are sent to the server. Useful
|
|
150
|
+
* in connection with artifact_data or artifact_selection to embed data in the artifact.
|
|
151
|
+
*/
|
|
152
|
+
schema?: (args: {
|
|
153
|
+
config: Config;
|
|
154
|
+
}) => string;
|
|
155
|
+
/**
|
|
156
|
+
* A hook to transform the documents before they are validated.
|
|
157
|
+
*/
|
|
158
|
+
before_validate?: (args: {
|
|
159
|
+
config: Config;
|
|
160
|
+
documents: CollectedGraphQLDocument[];
|
|
161
|
+
}) => Promise<void> | void;
|
|
162
|
+
/**
|
|
163
|
+
* A hook to validate all of the documents in a project.
|
|
164
|
+
*/
|
|
165
|
+
validate?: (args: {
|
|
166
|
+
config: Config;
|
|
167
|
+
documents: CollectedGraphQLDocument[];
|
|
168
|
+
}) => Promise<void> | void;
|
|
169
|
+
/**
|
|
170
|
+
* A hook to transform the documents after they are validated.
|
|
171
|
+
*/
|
|
172
|
+
after_validate?: (args: {
|
|
173
|
+
config: Config;
|
|
174
|
+
documents: CollectedGraphQLDocument[];
|
|
175
|
+
}) => Promise<void> | void;
|
|
176
|
+
/**
|
|
177
|
+
* A hook to transform the documents before documents are generated.
|
|
178
|
+
*/
|
|
179
|
+
transform_before_generate?: (args: {
|
|
180
|
+
config: Config;
|
|
181
|
+
documents: CollectedGraphQLDocument[];
|
|
182
|
+
}) => Promise<void> | void;
|
|
183
|
+
/**
|
|
184
|
+
* A hook to embed metadata at the root of the artifact.
|
|
185
|
+
*/
|
|
186
|
+
artifact_data?: (args: {
|
|
187
|
+
config: Config;
|
|
188
|
+
document: CollectedGraphQLDocument;
|
|
189
|
+
}) => Record<string, any>;
|
|
190
|
+
/**
|
|
191
|
+
* A hook to customize the hash generated for your document.
|
|
192
|
+
*/
|
|
193
|
+
hash?: (args: {
|
|
194
|
+
config: Config;
|
|
195
|
+
document: CollectedGraphQLDocument;
|
|
196
|
+
}) => string;
|
|
197
|
+
/**
|
|
198
|
+
* A hook to customize the return type of the graphql function. If you need to add an import to the file
|
|
199
|
+
* in order to resolve the import, you can use the `ensure_import` utility.
|
|
200
|
+
*/
|
|
201
|
+
graphql_tag_return?: (args: {
|
|
202
|
+
config: Config;
|
|
203
|
+
document: CollectedGraphQLDocument;
|
|
204
|
+
ensure_import: (import_args: {
|
|
205
|
+
identifier: string;
|
|
206
|
+
module: string;
|
|
207
|
+
}) => void;
|
|
208
|
+
}) => string | undefined;
|
|
209
|
+
/**
|
|
210
|
+
* A hook to modify the root `index.js` of the generated runtime.
|
|
211
|
+
*/
|
|
212
|
+
index_file?: ModuleIndexTransform;
|
|
213
|
+
/**
|
|
214
|
+
* A hook to generate custom files for every document in a project.
|
|
215
|
+
*/
|
|
216
|
+
generate?: GenerateHook;
|
|
217
|
+
/**
|
|
218
|
+
* A hook to modify the generated artifact before it is persisted
|
|
219
|
+
*/
|
|
220
|
+
artifact_end?: (args: {
|
|
221
|
+
config: Config;
|
|
222
|
+
document: CollectedGraphQLDocument;
|
|
223
|
+
}) => void;
|
|
224
|
+
/**
|
|
225
|
+
* Specify the plugins that should be added to the user's client because
|
|
226
|
+
* of this plugin.
|
|
227
|
+
*/
|
|
228
|
+
client_plugins?: Record<string, null | Record<string, any>> | ((config: ConfigFile, pluginConfig: any) => Record<string, null | Record<string, any>>);
|
|
229
|
+
/**
|
|
230
|
+
* A hook to transform the source file to support desired APIs.
|
|
231
|
+
*/
|
|
232
|
+
transform_file?: (page: TransformPage) => Promise<{
|
|
233
|
+
code: string;
|
|
234
|
+
}> | {
|
|
235
|
+
code: string;
|
|
236
|
+
};
|
|
237
|
+
vite?: {
|
|
238
|
+
resolveId?: ObjectHook<(this: PluginContext, source: string, importer: string | undefined, options: {
|
|
239
|
+
config: Config;
|
|
240
|
+
custom?: CustomPluginOptions;
|
|
241
|
+
ssr?: boolean;
|
|
242
|
+
isEntry: boolean;
|
|
243
|
+
}) => Promise<ResolveIdResult> | ResolveIdResult>;
|
|
244
|
+
load?: ObjectHook<(this: PluginContext, id: string, options: {
|
|
245
|
+
config: Config;
|
|
246
|
+
ssr?: boolean;
|
|
247
|
+
}) => Promise<LoadResult> | LoadResult>;
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
type ModuleIndexTransform = (arg: {
|
|
251
|
+
config: Config;
|
|
252
|
+
content: string;
|
|
253
|
+
export_default_as(args: {
|
|
254
|
+
module: string;
|
|
255
|
+
as: string;
|
|
256
|
+
}): string;
|
|
257
|
+
export_star_from(args: {
|
|
258
|
+
module: string;
|
|
259
|
+
}): string;
|
|
260
|
+
plugin_root: string;
|
|
261
|
+
typedef: boolean;
|
|
262
|
+
documents: CollectedGraphQLDocument[];
|
|
263
|
+
}) => string;
|
|
264
|
+
export type GenerateHook = (args: GenerateHookInput) => Promise<void> | void;
|
|
265
|
+
export type GenerateHookInput = {
|
|
266
|
+
config: Config;
|
|
267
|
+
documents: CollectedGraphQLDocument[];
|
|
268
|
+
plugin_root: string;
|
|
269
|
+
};
|
|
270
|
+
export type PluginConfig = {
|
|
271
|
+
configPath?: string;
|
|
272
|
+
} & Partial<ConfigFile>;
|
|
25
273
|
export * from '../runtime/lib/types';
|
|
26
274
|
export * from '../runtime/lib/config';
|