houdini 1.0.0-next.5 → 1.0.0-next.6
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 +130 -121
- package/build/cmd-esm/index.js +130 -121
- 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 +2 -2
- 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/typescript/documentTypes.d.ts +2 -2
- package/build/codegen/generators/typescript/imperativeTypeDef.d.ts +2 -2
- package/build/codegen/generators/typescript/index.d.ts +2 -2
- 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 +2 -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/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 +127 -118
- package/build/codegen-esm/index.js +127 -118
- package/build/lib/graphql.d.ts +2 -2
- package/build/lib/types.d.ts +35 -35
- package/build/lib-cjs/index.js +1 -1
- package/build/lib-esm/index.js +1 -1
- package/build/test/index.d.ts +3 -3
- package/build/test-cjs/index.js +125 -116
- package/build/test-esm/index.js +125 -116
- package/build/vite-cjs/index.js +130 -121
- package/build/vite-esm/index.js +130 -121
- package/package.json +1 -1
|
@@ -55153,7 +55153,7 @@ async function fragmentVariables(config2, documents) {
|
|
|
55153
55153
|
name: "generated::fragmentVariables",
|
|
55154
55154
|
kind: "HoudiniFragment" /* Fragment */,
|
|
55155
55155
|
document: doc,
|
|
55156
|
-
|
|
55156
|
+
originalParsed: doc,
|
|
55157
55157
|
generateStore: false,
|
|
55158
55158
|
generateArtifact: false,
|
|
55159
55159
|
filename: "generated::fragmentVariables",
|
|
@@ -56076,7 +56076,7 @@ async function paginate(config2, documents) {
|
|
|
56076
56076
|
filename: doc.filename,
|
|
56077
56077
|
name: refetchQueryName,
|
|
56078
56078
|
document: queryDoc,
|
|
56079
|
-
|
|
56079
|
+
originalParsed: queryDoc,
|
|
56080
56080
|
generateArtifact: true,
|
|
56081
56081
|
generateStore: false,
|
|
56082
56082
|
refetch: doc.refetch,
|
|
@@ -56496,7 +56496,7 @@ async function addListFragments(config2, documents) {
|
|
|
56496
56496
|
generateArtifact: false,
|
|
56497
56497
|
generateStore: false,
|
|
56498
56498
|
document: generatedDoc,
|
|
56499
|
-
|
|
56499
|
+
originalParsed: generatedDoc,
|
|
56500
56500
|
filename: "generated::lists",
|
|
56501
56501
|
originalString: "",
|
|
56502
56502
|
artifact: null
|
|
@@ -57024,11 +57024,11 @@ function artifactGenerator(stats) {
|
|
|
57024
57024
|
};
|
|
57025
57025
|
const plugin_data = config2.plugins.reduce(
|
|
57026
57026
|
(prev, plugin2) => {
|
|
57027
|
-
if (!plugin2.
|
|
57027
|
+
if (!plugin2.artifactData) {
|
|
57028
57028
|
return prev;
|
|
57029
57029
|
}
|
|
57030
57030
|
const result = { ...prev };
|
|
57031
|
-
const dataToAdd = plugin2.
|
|
57031
|
+
const dataToAdd = plugin2.artifactData({ config: config2, document: doc }) ?? {};
|
|
57032
57032
|
if (Object.keys(dataToAdd).length > 0) {
|
|
57033
57033
|
result[plugin2.name] = dataToAdd;
|
|
57034
57034
|
}
|
|
@@ -57073,10 +57073,10 @@ function artifactGenerator(stats) {
|
|
|
57073
57073
|
}
|
|
57074
57074
|
doc.artifact = artifact;
|
|
57075
57075
|
for (const plugin2 of config2.plugins) {
|
|
57076
|
-
if (!plugin2.
|
|
57076
|
+
if (!plugin2.artifactEnd) {
|
|
57077
57077
|
continue;
|
|
57078
57078
|
}
|
|
57079
|
-
plugin2.
|
|
57079
|
+
plugin2.artifactEnd({ config: config2, document: doc });
|
|
57080
57080
|
}
|
|
57081
57081
|
const file = AST5.program([
|
|
57082
57082
|
moduleExport(config2, "default", serializeValue(artifact)),
|
|
@@ -57116,18 +57116,18 @@ async function generateGraphqlReturnTypes(config2, docs) {
|
|
|
57116
57116
|
const indexPath = path_exports.join(config2.runtimeDirectory, "index.d.ts");
|
|
57117
57117
|
const fileContent = await fs_exports.readFile(indexPath) || "";
|
|
57118
57118
|
const contents = await parseJS(fileContent);
|
|
57119
|
-
const
|
|
57120
|
-
(plugin2) => plugin2.
|
|
57121
|
-
)?.
|
|
57122
|
-
if (!
|
|
57119
|
+
const graphqlTagReturn = config2.plugins.find(
|
|
57120
|
+
(plugin2) => plugin2.graphqlTagReturn
|
|
57121
|
+
)?.graphqlTagReturn;
|
|
57122
|
+
if (!graphqlTagReturn || !contents) {
|
|
57123
57123
|
return fileContent;
|
|
57124
57124
|
}
|
|
57125
57125
|
const overloaded_returns = {};
|
|
57126
57126
|
for (const doc of docs) {
|
|
57127
|
-
const return_value =
|
|
57127
|
+
const return_value = graphqlTagReturn({
|
|
57128
57128
|
config: config2,
|
|
57129
57129
|
document: doc,
|
|
57130
|
-
|
|
57130
|
+
ensureImport({ identifier, module }) {
|
|
57131
57131
|
ensureImports({
|
|
57132
57132
|
config: config2,
|
|
57133
57133
|
body: contents.script.body,
|
|
@@ -57175,18 +57175,18 @@ async function injectPlugins({
|
|
|
57175
57175
|
importStatement,
|
|
57176
57176
|
exportStatement
|
|
57177
57177
|
}) {
|
|
57178
|
-
const
|
|
57179
|
-
let plugins = plugin2.
|
|
57178
|
+
const clientPlugins = config2.plugins.filter((plugin2) => plugin2.clientPlugins).reduce((acc, plugin2) => {
|
|
57179
|
+
let plugins = plugin2.clientPlugins;
|
|
57180
57180
|
if (typeof plugins === "function") {
|
|
57181
57181
|
plugins = plugins(config2, config2.pluginConfig(plugin2.name));
|
|
57182
57182
|
}
|
|
57183
57183
|
return [...acc, ...Object.entries(plugins)];
|
|
57184
57184
|
}, []);
|
|
57185
|
-
return
|
|
57186
|
-
${
|
|
57185
|
+
return clientPlugins.length > 0 ? `
|
|
57186
|
+
${clientPlugins.map((plugin2, i) => importStatement(plugin2[0], `plugin${i}`))}
|
|
57187
57187
|
|
|
57188
57188
|
const plugins = [
|
|
57189
|
-
${
|
|
57189
|
+
${clientPlugins.map((plugin2, i) => {
|
|
57190
57190
|
const suffix = `(${JSON.stringify(plugin2[1])})`;
|
|
57191
57191
|
return `plugin${i}${suffix}`;
|
|
57192
57192
|
}).join(",\n")}
|
|
@@ -57230,18 +57230,18 @@ ${exportStatement("config")}
|
|
|
57230
57230
|
},
|
|
57231
57231
|
[path_exports.join(config2.runtimeSource, "client", "plugins", "injectedPlugins.js")]: (content) => injectPlugins({ config: config2, content, importStatement, exportStatement })
|
|
57232
57232
|
}),
|
|
57233
|
-
...config2.plugins.filter((plugin2) => plugin2.
|
|
57233
|
+
...config2.plugins.filter((plugin2) => plugin2.includeRuntime).map((plugin2) => generatePluginRuntime(config2, plugin2)),
|
|
57234
57234
|
generatePluginIndex({ config: config2, exportStatement: exportStar })
|
|
57235
57235
|
]);
|
|
57236
57236
|
await generateGraphqlReturnTypes(config2, docs);
|
|
57237
57237
|
}
|
|
57238
57238
|
async function generatePluginRuntime(config2, plugin2) {
|
|
57239
|
-
if (houdini_mode.is_testing || !plugin2.
|
|
57239
|
+
if (houdini_mode.is_testing || !plugin2.includeRuntime) {
|
|
57240
57240
|
return;
|
|
57241
57241
|
}
|
|
57242
57242
|
const runtime_path = path_exports.join(
|
|
57243
57243
|
path_exports.dirname(plugin2.filepath),
|
|
57244
|
-
typeof plugin2.
|
|
57244
|
+
typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime[config2.module]
|
|
57245
57245
|
);
|
|
57246
57246
|
try {
|
|
57247
57247
|
await fs_exports.stat(runtime_path);
|
|
@@ -57257,7 +57257,7 @@ async function generatePluginRuntime(config2, plugin2) {
|
|
|
57257
57257
|
runtime_path,
|
|
57258
57258
|
pluginDir,
|
|
57259
57259
|
Object.fromEntries(
|
|
57260
|
-
Object.entries(plugin2.
|
|
57260
|
+
Object.entries(plugin2.transformRuntime ?? {}).map(([key, value]) => [
|
|
57261
57261
|
path_exports.join(runtime_path, key),
|
|
57262
57262
|
(content) => value({ config: config2, content })
|
|
57263
57263
|
])
|
|
@@ -57651,7 +57651,7 @@ async function generateDocumentTypes(config2, docs) {
|
|
|
57651
57651
|
const typePaths = [];
|
|
57652
57652
|
const fragmentDefinitions = {};
|
|
57653
57653
|
for (const document of docs) {
|
|
57654
|
-
for (const defn of document.
|
|
57654
|
+
for (const defn of document.originalParsed.definitions.filter(
|
|
57655
57655
|
({ kind }) => kind === "FragmentDefinition"
|
|
57656
57656
|
)) {
|
|
57657
57657
|
fragmentDefinitions[defn.name.value] = defn;
|
|
@@ -57659,47 +57659,54 @@ async function generateDocumentTypes(config2, docs) {
|
|
|
57659
57659
|
}
|
|
57660
57660
|
const missingScalars = /* @__PURE__ */ new Set();
|
|
57661
57661
|
await Promise.all(
|
|
57662
|
-
docs.map(
|
|
57663
|
-
|
|
57664
|
-
|
|
57665
|
-
|
|
57666
|
-
|
|
57667
|
-
|
|
57668
|
-
|
|
57669
|
-
|
|
57670
|
-
|
|
57671
|
-
|
|
57672
|
-
|
|
57673
|
-
|
|
57674
|
-
|
|
57675
|
-
|
|
57676
|
-
|
|
57677
|
-
applyFragments: definition.kind === "OperationDefinition"
|
|
57678
|
-
});
|
|
57679
|
-
if (definition?.kind === "OperationDefinition") {
|
|
57680
|
-
await generateOperationTypeDefs(
|
|
57681
|
-
config2,
|
|
57682
|
-
filename,
|
|
57683
|
-
program.body,
|
|
57684
|
-
definition,
|
|
57685
|
-
selections,
|
|
57686
|
-
visitedTypes,
|
|
57687
|
-
missingScalars
|
|
57688
|
-
);
|
|
57689
|
-
} else {
|
|
57690
|
-
await generateFragmentTypeDefs(
|
|
57691
|
-
config2,
|
|
57692
|
-
filename,
|
|
57693
|
-
program.body,
|
|
57694
|
-
selections,
|
|
57695
|
-
originalDocument.definitions,
|
|
57696
|
-
visitedTypes,
|
|
57697
|
-
missingScalars
|
|
57662
|
+
docs.map(
|
|
57663
|
+
async ({
|
|
57664
|
+
originalParsed: originalDocument,
|
|
57665
|
+
name,
|
|
57666
|
+
filename,
|
|
57667
|
+
generateArtifact
|
|
57668
|
+
}) => {
|
|
57669
|
+
if (!generateArtifact) {
|
|
57670
|
+
return;
|
|
57671
|
+
}
|
|
57672
|
+
const typeDefPath = config2.artifactTypePath(originalDocument);
|
|
57673
|
+
const program = AST11.program([]);
|
|
57674
|
+
const visitedTypes = /* @__PURE__ */ new Set();
|
|
57675
|
+
let definition = originalDocument.definitions.find(
|
|
57676
|
+
(def) => (def.kind === "OperationDefinition" || def.kind === "FragmentDefinition") && def.name?.value === name
|
|
57698
57677
|
);
|
|
57678
|
+
const selections = flattenSelections({
|
|
57679
|
+
config: config2,
|
|
57680
|
+
filepath: filename,
|
|
57681
|
+
selections: definition.selectionSet.selections,
|
|
57682
|
+
fragmentDefinitions,
|
|
57683
|
+
applyFragments: definition.kind === "OperationDefinition"
|
|
57684
|
+
});
|
|
57685
|
+
if (definition?.kind === "OperationDefinition") {
|
|
57686
|
+
await generateOperationTypeDefs(
|
|
57687
|
+
config2,
|
|
57688
|
+
filename,
|
|
57689
|
+
program.body,
|
|
57690
|
+
definition,
|
|
57691
|
+
selections,
|
|
57692
|
+
visitedTypes,
|
|
57693
|
+
missingScalars
|
|
57694
|
+
);
|
|
57695
|
+
} else {
|
|
57696
|
+
await generateFragmentTypeDefs(
|
|
57697
|
+
config2,
|
|
57698
|
+
filename,
|
|
57699
|
+
program.body,
|
|
57700
|
+
selections,
|
|
57701
|
+
originalDocument.definitions,
|
|
57702
|
+
visitedTypes,
|
|
57703
|
+
missingScalars
|
|
57704
|
+
);
|
|
57705
|
+
}
|
|
57706
|
+
await fs_exports.writeFile(typeDefPath, recast11.print(program).code);
|
|
57707
|
+
typePaths.push(typeDefPath);
|
|
57699
57708
|
}
|
|
57700
|
-
|
|
57701
|
-
typePaths.push(typeDefPath);
|
|
57702
|
-
})
|
|
57709
|
+
)
|
|
57703
57710
|
);
|
|
57704
57711
|
const typeIndex = AST11.program(
|
|
57705
57712
|
typePaths.sort((a, b) => a.localeCompare(b)).map((typePath) => {
|
|
@@ -57714,28 +57721,28 @@ async function generateDocumentTypes(config2, docs) {
|
|
|
57714
57721
|
AST11.exportAllDeclaration(AST11.literal("./graphql"), null)
|
|
57715
57722
|
])
|
|
57716
57723
|
);
|
|
57717
|
-
const
|
|
57724
|
+
const exportDefaultAs = ({ module, as }) => `
|
|
57718
57725
|
export { default as ${as} } from "${module}"
|
|
57719
57726
|
`;
|
|
57720
|
-
const
|
|
57727
|
+
const exportStarFrom2 = ({ module }) => `
|
|
57721
57728
|
export * from "${module}"
|
|
57722
57729
|
`;
|
|
57723
57730
|
let indexContent = recast11.print(typeIndex).code;
|
|
57724
57731
|
for (const plugin2 of config2.plugins) {
|
|
57725
|
-
if (!plugin2.
|
|
57732
|
+
if (!plugin2.indexFile) {
|
|
57726
57733
|
continue;
|
|
57727
57734
|
}
|
|
57728
|
-
indexContent = plugin2.
|
|
57735
|
+
indexContent = plugin2.indexFile({
|
|
57729
57736
|
config: config2,
|
|
57730
57737
|
content: indexContent,
|
|
57731
|
-
|
|
57732
|
-
|
|
57733
|
-
|
|
57738
|
+
exportDefaultAs,
|
|
57739
|
+
exportStarFrom: exportStarFrom2,
|
|
57740
|
+
pluginRoot: config2.pluginDirectory(plugin2.name),
|
|
57734
57741
|
typedef: true,
|
|
57735
57742
|
documents: docs
|
|
57736
57743
|
});
|
|
57737
|
-
if (plugin2.
|
|
57738
|
-
indexContent +=
|
|
57744
|
+
if (plugin2.includeRuntime) {
|
|
57745
|
+
indexContent += exportStarFrom2({
|
|
57739
57746
|
module: "./" + path_exports.relative(config2.rootDir, config2.pluginRuntimeDirectory(plugin2.name))
|
|
57740
57747
|
});
|
|
57741
57748
|
}
|
|
@@ -57982,10 +57989,10 @@ var graphql17 = __toESM(require_graphql2(), 1);
|
|
|
57982
57989
|
var recast12 = __toESM(require_main2(), 1);
|
|
57983
57990
|
var AST12 = recast12.types.builders;
|
|
57984
57991
|
async function imperativeCacheTypef(config2, docs) {
|
|
57985
|
-
const returnType = (doc) => config2.plugins.find((plugin2) => plugin2.
|
|
57992
|
+
const returnType = (doc) => config2.plugins.find((plugin2) => plugin2.graphqlTagReturn)?.graphqlTagReturn?.({
|
|
57986
57993
|
config: config2,
|
|
57987
57994
|
document: doc,
|
|
57988
|
-
|
|
57995
|
+
ensureImport({ identifier, module }) {
|
|
57989
57996
|
ensureImports({
|
|
57990
57997
|
config: config2,
|
|
57991
57998
|
body,
|
|
@@ -58356,27 +58363,30 @@ async function persistOutputGenerator(config2, docs) {
|
|
|
58356
58363
|
console.log("Can only write the queryMap to a json file");
|
|
58357
58364
|
return;
|
|
58358
58365
|
}
|
|
58359
|
-
const queryMap = docs.reduce(
|
|
58360
|
-
|
|
58361
|
-
|
|
58362
|
-
|
|
58363
|
-
|
|
58364
|
-
graphql18.
|
|
58365
|
-
|
|
58366
|
-
|
|
58367
|
-
|
|
58366
|
+
const queryMap = docs.reduce(
|
|
58367
|
+
(acc, { document, generateArtifact }) => {
|
|
58368
|
+
if (!generateArtifact) {
|
|
58369
|
+
return acc;
|
|
58370
|
+
}
|
|
58371
|
+
let rawString = graphql18.print(
|
|
58372
|
+
graphql18.visit(document, {
|
|
58373
|
+
Directive(node) {
|
|
58374
|
+
if (config2.isInternalDirective(node.name.value)) {
|
|
58375
|
+
return null;
|
|
58376
|
+
}
|
|
58368
58377
|
}
|
|
58369
|
-
}
|
|
58370
|
-
|
|
58371
|
-
|
|
58372
|
-
|
|
58373
|
-
|
|
58374
|
-
|
|
58375
|
-
|
|
58376
|
-
|
|
58377
|
-
|
|
58378
|
-
|
|
58379
|
-
|
|
58378
|
+
})
|
|
58379
|
+
);
|
|
58380
|
+
const operations = document.definitions.filter(
|
|
58381
|
+
({ kind }) => kind === graphql18.Kind.OPERATION_DEFINITION
|
|
58382
|
+
);
|
|
58383
|
+
if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
|
|
58384
|
+
acc[hashDocument({ config: config2, document: rawString })] = rawString;
|
|
58385
|
+
}
|
|
58386
|
+
return acc;
|
|
58387
|
+
},
|
|
58388
|
+
{}
|
|
58389
|
+
);
|
|
58380
58390
|
if (Object.keys(queryMap).length === 0)
|
|
58381
58391
|
return;
|
|
58382
58392
|
await fs_exports.writeFile(config2.persistedQueryPath, JSON.stringify(queryMap, null, 4));
|
|
@@ -58445,32 +58455,32 @@ async function writeIndexFile2(config2, docs) {
|
|
|
58445
58455
|
const definitionsDir = relative2(config2.definitionsDirectory);
|
|
58446
58456
|
const cjs = config2.module === "commonjs";
|
|
58447
58457
|
let body = cjs ? cjsIndexFilePreamble : "";
|
|
58448
|
-
const
|
|
58449
|
-
const
|
|
58458
|
+
const exportStar = ({ module }) => "\n" + (cjs ? exportStarFrom(module) : `export * from "${module}"`) + "\n";
|
|
58459
|
+
const exportDefaultAs = ({ module, as }) => "\n" + (cjs ? exportDefaultFrom(module, as) : `export { default as ${as} } from "${module}"`) + "\n";
|
|
58450
58460
|
body += [
|
|
58451
|
-
|
|
58452
|
-
|
|
58453
|
-
|
|
58454
|
-
|
|
58461
|
+
exportStar({ module: "./" + path_exports.join(runtimeDir, "client") }),
|
|
58462
|
+
exportStar({ module: runtimeDir }),
|
|
58463
|
+
exportStar({ module: artifactDir }),
|
|
58464
|
+
exportStar({ module: definitionsDir })
|
|
58455
58465
|
].join("");
|
|
58456
58466
|
for (const plugin2 of config2.plugins) {
|
|
58457
|
-
if (plugin2.
|
|
58458
|
-
body = plugin2.
|
|
58467
|
+
if (plugin2.indexFile) {
|
|
58468
|
+
body = plugin2.indexFile({
|
|
58459
58469
|
config: config2,
|
|
58460
58470
|
content: body,
|
|
58461
|
-
|
|
58462
|
-
|
|
58463
|
-
|
|
58471
|
+
exportDefaultAs,
|
|
58472
|
+
exportStarFrom: exportStar,
|
|
58473
|
+
pluginRoot: config2.pluginDirectory(plugin2.name),
|
|
58464
58474
|
typedef: false,
|
|
58465
58475
|
documents: docs
|
|
58466
58476
|
});
|
|
58467
58477
|
}
|
|
58468
|
-
if (plugin2.
|
|
58469
|
-
body +=
|
|
58478
|
+
if (plugin2.includeRuntime) {
|
|
58479
|
+
body += exportStar({
|
|
58470
58480
|
module: relative2(config2.pluginRuntimeDirectory(plugin2.name))
|
|
58471
58481
|
});
|
|
58472
58482
|
}
|
|
58473
|
-
if (!plugin2.
|
|
58483
|
+
if (!plugin2.indexFile) {
|
|
58474
58484
|
continue;
|
|
58475
58485
|
}
|
|
58476
58486
|
}
|
|
@@ -59518,10 +59528,10 @@ async function runPipeline2(config2, docs) {
|
|
|
59518
59528
|
deleted: []
|
|
59519
59529
|
};
|
|
59520
59530
|
const generatePlugins = config2.plugins.filter((plugin2) => plugin2.generate);
|
|
59521
|
-
const
|
|
59531
|
+
const afterValidate = config2.plugins.filter((plugin2) => plugin2.afterValidate).map((plugin2) => plugin2.afterValidate);
|
|
59522
59532
|
const validate2 = config2.plugins.filter((plugin2) => plugin2.validate).map((plugin2) => plugin2.validate);
|
|
59523
|
-
const
|
|
59524
|
-
const
|
|
59533
|
+
const beforeValidate = config2.plugins.filter((plugin2) => plugin2.beforeValidate).map((plugin2) => plugin2.beforeValidate);
|
|
59534
|
+
const beforeGenerate = config2.plugins.filter((plugin2) => plugin2.beforeGenerate).map((plugin2) => plugin2.beforeGenerate);
|
|
59525
59535
|
const wrapHook = (hooks) => hooks.map(
|
|
59526
59536
|
(fn) => (config3, docs2) => fn({
|
|
59527
59537
|
config: config3,
|
|
@@ -59534,20 +59544,20 @@ async function runPipeline2(config2, docs) {
|
|
|
59534
59544
|
config2,
|
|
59535
59545
|
[
|
|
59536
59546
|
graphqlExtensions,
|
|
59537
|
-
...wrapHook(
|
|
59547
|
+
...wrapHook(beforeValidate),
|
|
59538
59548
|
typeCheck,
|
|
59539
59549
|
uniqueDocumentNames,
|
|
59540
59550
|
noIDAlias,
|
|
59541
59551
|
validatePlugins,
|
|
59542
59552
|
...wrapHook(validate2),
|
|
59543
|
-
...wrapHook(
|
|
59553
|
+
...wrapHook(afterValidate),
|
|
59544
59554
|
addID,
|
|
59545
59555
|
addTypename,
|
|
59546
59556
|
addListFragments,
|
|
59547
59557
|
paginate,
|
|
59548
59558
|
fragmentVariables,
|
|
59549
59559
|
includeFragmentDefinitions,
|
|
59550
|
-
...wrapHook(
|
|
59560
|
+
...wrapHook(beforeGenerate),
|
|
59551
59561
|
artifactGenerator(artifactStats),
|
|
59552
59562
|
runtimeGenerator,
|
|
59553
59563
|
writeIndexFile2,
|
|
@@ -59558,14 +59568,13 @@ async function runPipeline2(config2, docs) {
|
|
|
59558
59568
|
(plugin2) => async (config3, docs2) => await plugin2.generate({
|
|
59559
59569
|
config: config3,
|
|
59560
59570
|
documents: docs2,
|
|
59561
|
-
|
|
59571
|
+
pluginRoot: config3.pluginDirectory(plugin2.name)
|
|
59562
59572
|
})
|
|
59563
59573
|
)
|
|
59564
59574
|
],
|
|
59565
59575
|
docs
|
|
59566
59576
|
);
|
|
59567
59577
|
} catch (e) {
|
|
59568
|
-
console.log(e);
|
|
59569
59578
|
error = e;
|
|
59570
59579
|
}
|
|
59571
59580
|
const unchanged = artifactStats.total.length - artifactStats.changed.length - artifactStats.new.length - artifactStats.deleted.length;
|
|
@@ -59615,9 +59624,9 @@ async function collectDocuments(config2) {
|
|
|
59615
59624
|
".ts": []
|
|
59616
59625
|
};
|
|
59617
59626
|
for (const plugin2 of config2.plugins) {
|
|
59618
|
-
if (plugin2.extensions && plugin2.
|
|
59627
|
+
if (plugin2.extensions && plugin2.extractDocuments) {
|
|
59619
59628
|
for (const extension of plugin2.extensions) {
|
|
59620
|
-
extractors[extension] = [...extractors[extension] || [], plugin2.
|
|
59629
|
+
extractors[extension] = [...extractors[extension] || [], plugin2.extractDocuments];
|
|
59621
59630
|
}
|
|
59622
59631
|
}
|
|
59623
59632
|
}
|
|
@@ -59716,7 +59725,7 @@ async function processGraphQLDocument(config2, filepath, document) {
|
|
|
59716
59725
|
kind,
|
|
59717
59726
|
document: parsedDoc,
|
|
59718
59727
|
filename: filepath,
|
|
59719
|
-
|
|
59728
|
+
originalParsed: parsedDoc,
|
|
59720
59729
|
generateArtifact: true,
|
|
59721
59730
|
generateStore: true,
|
|
59722
59731
|
originalString: document,
|
package/build/lib/graphql.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as graphql from 'graphql';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Document, Config } from '.';
|
|
3
3
|
export declare function getRootType(type: graphql.GraphQLType): graphql.GraphQLType;
|
|
4
4
|
export declare function hashDocument({ document, }: {
|
|
5
5
|
config: Config;
|
|
6
|
-
document: string |
|
|
6
|
+
document: string | Document;
|
|
7
7
|
}): string;
|
|
8
8
|
type GraphQLParentType = graphql.GraphQLObjectType | graphql.GraphQLInputObjectType | graphql.GraphQLInterfaceType;
|
|
9
9
|
export declare function parentTypeFromAncestors(schema: graphql.GraphQLSchema, filepath: string, ancestors: readonly any[]): GraphQLParentType;
|
package/build/lib/types.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type TransformDocument = {
|
|
|
17
17
|
/**
|
|
18
18
|
* The result of collecting documents from source code
|
|
19
19
|
*/
|
|
20
|
-
export type
|
|
20
|
+
export type Document = {
|
|
21
21
|
/**
|
|
22
22
|
* The name of the document.
|
|
23
23
|
*/
|
|
@@ -39,10 +39,6 @@ export type CollectedGraphQLDocument = {
|
|
|
39
39
|
* The parsed document. This value should be modified throughout the pipeline.
|
|
40
40
|
* */
|
|
41
41
|
document: graphql.DocumentNode;
|
|
42
|
-
/**
|
|
43
|
-
* The document that the user provided
|
|
44
|
-
* */
|
|
45
|
-
originalDocument: graphql.DocumentNode;
|
|
46
42
|
/**
|
|
47
43
|
* Whether an artifact should be generated for the document. This should be set to false for internal
|
|
48
44
|
* or virtual documents .
|
|
@@ -57,6 +53,10 @@ export type CollectedGraphQLDocument = {
|
|
|
57
53
|
* The original document string that the user passed
|
|
58
54
|
*/
|
|
59
55
|
originalString: string;
|
|
56
|
+
/**
|
|
57
|
+
* The parsed document that the user provided
|
|
58
|
+
* */
|
|
59
|
+
originalParsed: graphql.DocumentNode;
|
|
60
60
|
/**
|
|
61
61
|
* Refetch logic that has been built up throughout the pipeline
|
|
62
62
|
*/
|
|
@@ -91,15 +91,15 @@ export type PluginHooks = {
|
|
|
91
91
|
* A relative path from the file exporting your plugin to a runtime that will be
|
|
92
92
|
* automatically included with your
|
|
93
93
|
*/
|
|
94
|
-
|
|
94
|
+
includeRuntime?: string | {
|
|
95
95
|
esm: string;
|
|
96
96
|
commonjs: string;
|
|
97
97
|
};
|
|
98
98
|
/**
|
|
99
99
|
* Transform the plugin's runtime while houdini is copying it .
|
|
100
|
-
* You must have passed a value to
|
|
100
|
+
* You must have passed a value to includeRuntime for this hook to matter.
|
|
101
101
|
*/
|
|
102
|
-
|
|
102
|
+
transformRuntime?: Record<string, (args: {
|
|
103
103
|
config: Config;
|
|
104
104
|
content: string;
|
|
105
105
|
}) => string>;
|
|
@@ -119,7 +119,7 @@ export type PluginHooks = {
|
|
|
119
119
|
/**
|
|
120
120
|
* Invoked after all plugins have loaded and modified config values.
|
|
121
121
|
*/
|
|
122
|
-
|
|
122
|
+
afterLoad?: (args: {
|
|
123
123
|
config: Config;
|
|
124
124
|
}) => Promise<void> | void;
|
|
125
125
|
/**
|
|
@@ -139,7 +139,7 @@ export type PluginHooks = {
|
|
|
139
139
|
/**
|
|
140
140
|
* Configure the codegen pipeline to extract graphql documents out of a file.
|
|
141
141
|
*/
|
|
142
|
-
|
|
142
|
+
extractDocuments?: (args: {
|
|
143
143
|
config: Config;
|
|
144
144
|
filepath: string;
|
|
145
145
|
content: string;
|
|
@@ -147,7 +147,7 @@ export type PluginHooks = {
|
|
|
147
147
|
/**
|
|
148
148
|
* Can be used to add custom definitions to your project's schema. Definitions (like directives) added
|
|
149
149
|
* here are automatically removed from the document before they are sent to the server. Useful
|
|
150
|
-
* in connection with
|
|
150
|
+
* in connection with artifactData or artifact_selection to embed data in the artifact.
|
|
151
151
|
*/
|
|
152
152
|
schema?: (args: {
|
|
153
153
|
config: Config;
|
|
@@ -155,53 +155,53 @@ export type PluginHooks = {
|
|
|
155
155
|
/**
|
|
156
156
|
* A hook to transform the documents before they are validated.
|
|
157
157
|
*/
|
|
158
|
-
|
|
158
|
+
beforeValidate?: (args: {
|
|
159
159
|
config: Config;
|
|
160
|
-
documents:
|
|
160
|
+
documents: Document[];
|
|
161
161
|
}) => Promise<void> | void;
|
|
162
162
|
/**
|
|
163
163
|
* A hook to validate all of the documents in a project.
|
|
164
164
|
*/
|
|
165
165
|
validate?: (args: {
|
|
166
166
|
config: Config;
|
|
167
|
-
documents:
|
|
167
|
+
documents: Document[];
|
|
168
168
|
}) => Promise<void> | void;
|
|
169
169
|
/**
|
|
170
170
|
* A hook to transform the documents after they are validated.
|
|
171
171
|
*/
|
|
172
|
-
|
|
172
|
+
afterValidate?: (args: {
|
|
173
173
|
config: Config;
|
|
174
|
-
documents:
|
|
174
|
+
documents: Document[];
|
|
175
175
|
}) => Promise<void> | void;
|
|
176
176
|
/**
|
|
177
177
|
* A hook to transform the documents before documents are generated.
|
|
178
178
|
*/
|
|
179
|
-
|
|
179
|
+
beforeGenerate?: (args: {
|
|
180
180
|
config: Config;
|
|
181
|
-
documents:
|
|
181
|
+
documents: Document[];
|
|
182
182
|
}) => Promise<void> | void;
|
|
183
183
|
/**
|
|
184
184
|
* A hook to embed metadata at the root of the artifact.
|
|
185
185
|
*/
|
|
186
|
-
|
|
186
|
+
artifactData?: (args: {
|
|
187
187
|
config: Config;
|
|
188
|
-
document:
|
|
188
|
+
document: Document;
|
|
189
189
|
}) => Record<string, any>;
|
|
190
190
|
/**
|
|
191
191
|
* A hook to customize the hash generated for your document.
|
|
192
192
|
*/
|
|
193
193
|
hash?: (args: {
|
|
194
194
|
config: Config;
|
|
195
|
-
document:
|
|
195
|
+
document: Document;
|
|
196
196
|
}) => string;
|
|
197
197
|
/**
|
|
198
198
|
* A hook to customize the return type of the graphql function. If you need to add an import to the file
|
|
199
199
|
* in order to resolve the import, you can use the `ensure_import` utility.
|
|
200
200
|
*/
|
|
201
|
-
|
|
201
|
+
graphqlTagReturn?: (args: {
|
|
202
202
|
config: Config;
|
|
203
|
-
document:
|
|
204
|
-
|
|
203
|
+
document: Document;
|
|
204
|
+
ensureImport: (import_args: {
|
|
205
205
|
identifier: string;
|
|
206
206
|
module: string;
|
|
207
207
|
}) => void;
|
|
@@ -209,7 +209,7 @@ export type PluginHooks = {
|
|
|
209
209
|
/**
|
|
210
210
|
* A hook to modify the root `index.js` of the generated runtime.
|
|
211
211
|
*/
|
|
212
|
-
|
|
212
|
+
indexFile?: ModuleIndexTransform;
|
|
213
213
|
/**
|
|
214
214
|
* A hook to generate custom files for every document in a project.
|
|
215
215
|
*/
|
|
@@ -217,19 +217,19 @@ export type PluginHooks = {
|
|
|
217
217
|
/**
|
|
218
218
|
* A hook to modify the generated artifact before it is persisted
|
|
219
219
|
*/
|
|
220
|
-
|
|
220
|
+
artifactEnd?: (args: {
|
|
221
221
|
config: Config;
|
|
222
|
-
document:
|
|
222
|
+
document: Document;
|
|
223
223
|
}) => void;
|
|
224
224
|
/**
|
|
225
225
|
* Specify the plugins that should be added to the user's client because
|
|
226
226
|
* of this plugin.
|
|
227
227
|
*/
|
|
228
|
-
|
|
228
|
+
clientPlugins?: Record<string, null | Record<string, any>> | ((config: ConfigFile, pluginConfig: any) => Record<string, null | Record<string, any>>);
|
|
229
229
|
/**
|
|
230
230
|
* A hook to transform the source file to support desired APIs.
|
|
231
231
|
*/
|
|
232
|
-
|
|
232
|
+
transformFile?: (page: TransformPage) => Promise<{
|
|
233
233
|
code: string;
|
|
234
234
|
}> | {
|
|
235
235
|
code: string;
|
|
@@ -250,22 +250,22 @@ export type PluginHooks = {
|
|
|
250
250
|
type ModuleIndexTransform = (arg: {
|
|
251
251
|
config: Config;
|
|
252
252
|
content: string;
|
|
253
|
-
|
|
253
|
+
exportDefaultAs(args: {
|
|
254
254
|
module: string;
|
|
255
255
|
as: string;
|
|
256
256
|
}): string;
|
|
257
|
-
|
|
257
|
+
exportStarFrom(args: {
|
|
258
258
|
module: string;
|
|
259
259
|
}): string;
|
|
260
|
-
|
|
260
|
+
pluginRoot: string;
|
|
261
261
|
typedef: boolean;
|
|
262
|
-
documents:
|
|
262
|
+
documents: Document[];
|
|
263
263
|
}) => string;
|
|
264
264
|
export type GenerateHook = (args: GenerateHookInput) => Promise<void> | void;
|
|
265
265
|
export type GenerateHookInput = {
|
|
266
266
|
config: Config;
|
|
267
|
-
documents:
|
|
268
|
-
|
|
267
|
+
documents: Document[];
|
|
268
|
+
pluginRoot: string;
|
|
269
269
|
};
|
|
270
270
|
export type PluginConfig = {
|
|
271
271
|
configPath?: string;
|