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/vite-esm/index.js
CHANGED
|
@@ -66716,8 +66716,7 @@ var Config = class {
|
|
|
66716
66716
|
types: types17 = {},
|
|
66717
66717
|
logLevel,
|
|
66718
66718
|
defaultFragmentMasking = "enable",
|
|
66719
|
-
|
|
66720
|
-
schemaPollHeaders = {},
|
|
66719
|
+
watchSchema,
|
|
66721
66720
|
projectDir
|
|
66722
66721
|
} = this.configFile;
|
|
66723
66722
|
if (typeof schema === "string") {
|
|
@@ -66750,8 +66749,8 @@ var Config = class {
|
|
|
66750
66749
|
this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
|
|
66751
66750
|
this.defaultFragmentMasking = defaultFragmentMasking;
|
|
66752
66751
|
this.routesDir = join2(this.projectRoot, "src", "routes");
|
|
66753
|
-
this.schemaPollInterval =
|
|
66754
|
-
this.schemaPollHeaders =
|
|
66752
|
+
this.schemaPollInterval = watchSchema?.interval ?? 2e3;
|
|
66753
|
+
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
66755
66754
|
this.rootDir = join2(this.projectRoot, "$houdini");
|
|
66756
66755
|
if (defaultKeys) {
|
|
66757
66756
|
this.defaultKeys = defaultKeys;
|
|
@@ -66764,11 +66763,12 @@ var Config = class {
|
|
|
66764
66763
|
}
|
|
66765
66764
|
}
|
|
66766
66765
|
async apiURL() {
|
|
66767
|
-
|
|
66766
|
+
const apiURL = this.configFile.watchSchema?.url;
|
|
66767
|
+
if (!apiURL) {
|
|
66768
66768
|
return "";
|
|
66769
66769
|
}
|
|
66770
66770
|
const env = await this.getEnv();
|
|
66771
|
-
return this.processEnvValues(env,
|
|
66771
|
+
return this.processEnvValues(env, apiURL);
|
|
66772
66772
|
}
|
|
66773
66773
|
get include() {
|
|
66774
66774
|
if (this.configFile.include) {
|
|
@@ -66972,8 +66972,8 @@ var Config = class {
|
|
|
66972
66972
|
pluginDirectory(name2) {
|
|
66973
66973
|
return join2(this.pluginRootDirectory, name2);
|
|
66974
66974
|
}
|
|
66975
|
-
get
|
|
66976
|
-
return "
|
|
66975
|
+
get loadDirective() {
|
|
66976
|
+
return "load";
|
|
66977
66977
|
}
|
|
66978
66978
|
get maskEnableDirective() {
|
|
66979
66979
|
return "mask_enable";
|
|
@@ -67090,7 +67090,7 @@ var Config = class {
|
|
|
67090
67090
|
this.withDirective,
|
|
67091
67091
|
this.paginateDirective,
|
|
67092
67092
|
this.cacheDirective,
|
|
67093
|
-
this.
|
|
67093
|
+
this.loadDirective,
|
|
67094
67094
|
this.maskEnableDirective,
|
|
67095
67095
|
this.maskDisableDirective
|
|
67096
67096
|
].includes(name2.value) || this.isDeleteDirective(name2.value);
|
|
@@ -67675,7 +67675,7 @@ async function find_graphql(config4, parsedScript, walker) {
|
|
|
67675
67675
|
return;
|
|
67676
67676
|
}
|
|
67677
67677
|
const parsedTag = graphql4.parse(documentString);
|
|
67678
|
-
if (walker.where && !walker.where(parsedTag)) {
|
|
67678
|
+
if (walker.where && !walker.where(parsedTag, { node, parent })) {
|
|
67679
67679
|
return;
|
|
67680
67680
|
}
|
|
67681
67681
|
const definition = config4.extractDefinition(parsedTag);
|
|
@@ -67716,7 +67716,7 @@ async function find_graphql(config4, parsedScript, walker) {
|
|
|
67716
67716
|
}
|
|
67717
67717
|
|
|
67718
67718
|
// src/codegen/generators/artifacts/index.ts
|
|
67719
|
-
var
|
|
67719
|
+
var graphql14 = __toESM(require_graphql2(), 1);
|
|
67720
67720
|
var recast5 = __toESM(require_main2(), 1);
|
|
67721
67721
|
|
|
67722
67722
|
// src/codegen/utils/commonjs.ts
|
|
@@ -67974,159 +67974,534 @@ function murmurHash(str) {
|
|
|
67974
67974
|
return s2;
|
|
67975
67975
|
}
|
|
67976
67976
|
|
|
67977
|
-
// src/codegen/
|
|
67978
|
-
async function writeIndexFile(config4, docs) {
|
|
67979
|
-
const docsToGenerate = docs.filter((doc) => doc.generateArtifact).sort((a, b) => a.name.localeCompare(b.name));
|
|
67980
|
-
let body = config4.module === "esm" ? docsToGenerate.reduce(
|
|
67981
|
-
(content, doc) => content + `
|
|
67982
|
-
export { default as ${doc.name}} from './${doc.name}'`,
|
|
67983
|
-
""
|
|
67984
|
-
) : docsToGenerate.reduce(
|
|
67985
|
-
(content, doc) => content + `
|
|
67986
|
-
${exportDefaultFrom(`./${doc.name}`, doc.name)}`,
|
|
67987
|
-
cjsIndexFilePreamble
|
|
67988
|
-
);
|
|
67989
|
-
await fs_exports.writeFile(path_exports.join(config4.artifactDirectory, "index.js"), body);
|
|
67990
|
-
}
|
|
67991
|
-
|
|
67992
|
-
// src/codegen/generators/artifacts/inputs.ts
|
|
67977
|
+
// src/codegen/transforms/fragmentVariables.ts
|
|
67993
67978
|
var graphql5 = __toESM(require_graphql2(), 1);
|
|
67994
|
-
var recast3 = __toESM(require_main2(), 1);
|
|
67995
|
-
var AST3 = recast3.types.builders;
|
|
67996
|
-
function inputObject(config4, inputs) {
|
|
67997
|
-
const visitedTypes = /* @__PURE__ */ new Set();
|
|
67998
|
-
const inputObj = {
|
|
67999
|
-
fields: inputs.reduce((fields, input) => {
|
|
68000
|
-
const { type } = unwrapType(config4, input.type);
|
|
68001
|
-
return {
|
|
68002
|
-
...fields,
|
|
68003
|
-
[input.variable.name.value]: type.name
|
|
68004
|
-
};
|
|
68005
|
-
}, {}),
|
|
68006
|
-
types: {}
|
|
68007
|
-
};
|
|
68008
|
-
for (const input of inputs) {
|
|
68009
|
-
walkInputs(config4, visitedTypes, inputObj, input.type);
|
|
68010
|
-
}
|
|
68011
|
-
return inputObj;
|
|
68012
|
-
}
|
|
68013
|
-
function walkInputs(config4, visitedTypes, inputObj, rootType) {
|
|
68014
|
-
const { type } = unwrapType(config4, rootType);
|
|
68015
|
-
if (visitedTypes.has(type.name)) {
|
|
68016
|
-
return;
|
|
68017
|
-
}
|
|
68018
|
-
if (graphql5.isEnumType(type) || graphql5.isScalarType(type)) {
|
|
68019
|
-
return;
|
|
68020
|
-
}
|
|
68021
|
-
if (graphql5.isUnionType(type)) {
|
|
68022
|
-
return;
|
|
68023
|
-
}
|
|
68024
|
-
visitedTypes.add(type.name);
|
|
68025
|
-
inputObj.types[type.name] = Object.values(type.getFields()).reduce(
|
|
68026
|
-
(typeFields, field) => {
|
|
68027
|
-
const { type: fieldType } = unwrapType(config4, field.type);
|
|
68028
|
-
walkInputs(config4, visitedTypes, inputObj, fieldType);
|
|
68029
|
-
return {
|
|
68030
|
-
...typeFields,
|
|
68031
|
-
[field.name]: fieldType.toString()
|
|
68032
|
-
};
|
|
68033
|
-
},
|
|
68034
|
-
{}
|
|
68035
|
-
);
|
|
68036
|
-
}
|
|
68037
67979
|
|
|
68038
|
-
// src/codegen/
|
|
68039
|
-
var
|
|
68040
|
-
|
|
68041
|
-
|
|
68042
|
-
|
|
68043
|
-
|
|
68044
|
-
|
|
68045
|
-
|
|
68046
|
-
|
|
68047
|
-
|
|
67980
|
+
// src/codegen/transforms/composeQueries.ts
|
|
67981
|
+
var import_graphql30 = __toESM(require_graphql2(), 1);
|
|
67982
|
+
async function includeFragmentDefinitions(config4, documents) {
|
|
67983
|
+
const fragments = collectFragments(config4, documents);
|
|
67984
|
+
for (const [index, { name: name2, document, filename }] of documents.entries()) {
|
|
67985
|
+
const operation = document.definitions.find(
|
|
67986
|
+
({ kind }) => kind === import_graphql30.Kind.OPERATION_DEFINITION
|
|
67987
|
+
);
|
|
67988
|
+
if (!operation) {
|
|
67989
|
+
continue;
|
|
67990
|
+
}
|
|
67991
|
+
const allFragments = flattenFragments(
|
|
67992
|
+
filename,
|
|
67993
|
+
{ requiredFragments: findRequiredFragments(operation.selectionSet) },
|
|
67994
|
+
fragments
|
|
67995
|
+
);
|
|
67996
|
+
documents[index].document = {
|
|
67997
|
+
...document,
|
|
67998
|
+
definitions: [
|
|
67999
|
+
operation,
|
|
68000
|
+
...allFragments.map((fragmentName) => fragments[fragmentName].definition)
|
|
68001
|
+
]
|
|
68002
|
+
};
|
|
68048
68003
|
}
|
|
68049
|
-
|
|
68050
|
-
|
|
68051
|
-
|
|
68052
|
-
|
|
68053
|
-
)
|
|
68004
|
+
}
|
|
68005
|
+
function collectFragments(config4, docs) {
|
|
68006
|
+
return docs.reduce((acc, doc) => {
|
|
68007
|
+
const definitions = doc.document.definitions.reduce(
|
|
68008
|
+
(prev, definition) => definition.kind !== "FragmentDefinition" ? prev : {
|
|
68009
|
+
...prev,
|
|
68010
|
+
[definition.name.value]: {
|
|
68011
|
+
definition,
|
|
68012
|
+
requiredFragments: findRequiredFragments(definition.selectionSet),
|
|
68013
|
+
document: doc
|
|
68014
|
+
}
|
|
68015
|
+
},
|
|
68016
|
+
{}
|
|
68054
68017
|
);
|
|
68018
|
+
return {
|
|
68019
|
+
...acc,
|
|
68020
|
+
...definitions
|
|
68021
|
+
};
|
|
68022
|
+
}, {});
|
|
68023
|
+
}
|
|
68024
|
+
function findRequiredFragments(selectionSet) {
|
|
68025
|
+
if (selectionSet.selections.length === 0) {
|
|
68026
|
+
return [];
|
|
68055
68027
|
}
|
|
68056
|
-
|
|
68057
|
-
|
|
68058
|
-
|
|
68059
|
-
|
|
68060
|
-
|
|
68061
|
-
);
|
|
68028
|
+
const referencedFragments = [];
|
|
68029
|
+
for (const selection2 of selectionSet.selections) {
|
|
68030
|
+
if (selection2.kind === import_graphql30.Kind.FRAGMENT_SPREAD) {
|
|
68031
|
+
referencedFragments.push(selection2.name.value);
|
|
68032
|
+
} else if (selection2.selectionSet) {
|
|
68033
|
+
referencedFragments.push(...findRequiredFragments(selection2.selectionSet));
|
|
68062
68034
|
}
|
|
68063
|
-
return AST4.stringLiteral(value);
|
|
68064
68035
|
}
|
|
68065
|
-
return
|
|
68036
|
+
return referencedFragments;
|
|
68066
68037
|
}
|
|
68067
|
-
function
|
|
68068
|
-
|
|
68069
|
-
|
|
68070
|
-
|
|
68071
|
-
|
|
68038
|
+
function flattenFragments(filepath, operation, fragments) {
|
|
68039
|
+
const frags = /* @__PURE__ */ new Set();
|
|
68040
|
+
const remaining = [...operation.requiredFragments];
|
|
68041
|
+
while (remaining.length > 0) {
|
|
68042
|
+
const nextFragment = remaining.shift();
|
|
68043
|
+
if (!nextFragment) {
|
|
68044
|
+
continue;
|
|
68072
68045
|
}
|
|
68073
|
-
|
|
68074
|
-
|
|
68075
|
-
|
|
68076
|
-
|
|
68077
|
-
|
|
68078
|
-
|
|
68079
|
-
|
|
68080
|
-
|
|
68081
|
-
|
|
68082
|
-
|
|
68083
|
-
}
|
|
68084
|
-
fields[key].push(value);
|
|
68046
|
+
if (!frags.has(nextFragment)) {
|
|
68047
|
+
frags.add(nextFragment);
|
|
68048
|
+
} else {
|
|
68049
|
+
continue;
|
|
68050
|
+
}
|
|
68051
|
+
const targetFragment = fragments[nextFragment];
|
|
68052
|
+
if (!targetFragment) {
|
|
68053
|
+
throw new HoudiniError({
|
|
68054
|
+
filepath,
|
|
68055
|
+
message: "compose: could not find definition for fragment " + nextFragment
|
|
68056
|
+
});
|
|
68085
68057
|
}
|
|
68058
|
+
remaining.push(...targetFragment.requiredFragments);
|
|
68086
68059
|
}
|
|
68087
|
-
return
|
|
68088
|
-
Object.entries(fields).map(([key, value]) => [key, deepMerge(filepath, ...value)])
|
|
68089
|
-
);
|
|
68060
|
+
return [...frags];
|
|
68090
68061
|
}
|
|
68091
|
-
|
|
68092
|
-
|
|
68093
|
-
|
|
68094
|
-
|
|
68095
|
-
|
|
68096
|
-
|
|
68097
|
-
|
|
68098
|
-
|
|
68099
|
-
|
|
68100
|
-
|
|
68101
|
-
|
|
68102
|
-
|
|
68103
|
-
|
|
68104
|
-
|
|
68105
|
-
|
|
68106
|
-
|
|
68107
|
-
|
|
68108
|
-
|
|
68062
|
+
|
|
68063
|
+
// src/codegen/transforms/fragmentVariables.ts
|
|
68064
|
+
var GraphqlKinds2 = graphql5.Kind;
|
|
68065
|
+
async function fragmentVariables(config4, documents) {
|
|
68066
|
+
const fragments = collectFragments(config4, documents);
|
|
68067
|
+
const generatedFragments = {};
|
|
68068
|
+
const visitedFragments = /* @__PURE__ */ new Set();
|
|
68069
|
+
for (const doc2 of documents) {
|
|
68070
|
+
const operation = doc2.document.definitions.find(
|
|
68071
|
+
({ kind }) => kind === GraphqlKinds2.OPERATION_DEFINITION
|
|
68072
|
+
);
|
|
68073
|
+
if (!operation) {
|
|
68074
|
+
continue;
|
|
68075
|
+
}
|
|
68076
|
+
doc2.document = inlineFragmentArgs({
|
|
68077
|
+
config: config4,
|
|
68078
|
+
filepath: doc2.filename,
|
|
68079
|
+
fragmentDefinitions: fragments,
|
|
68080
|
+
document: doc2.document,
|
|
68081
|
+
generatedFragments,
|
|
68082
|
+
visitedFragments,
|
|
68083
|
+
scope: null
|
|
68084
|
+
});
|
|
68109
68085
|
}
|
|
68110
|
-
|
|
68086
|
+
const doc = {
|
|
68087
|
+
kind: graphql5.Kind.DOCUMENT,
|
|
68088
|
+
definitions: Object.values(generatedFragments)
|
|
68089
|
+
};
|
|
68090
|
+
documents.push({
|
|
68091
|
+
name: "generated::fragmentVariables",
|
|
68092
|
+
kind: "HoudiniFragment" /* Fragment */,
|
|
68093
|
+
document: doc,
|
|
68094
|
+
originalDocument: doc,
|
|
68095
|
+
generateStore: false,
|
|
68096
|
+
generateArtifact: false,
|
|
68097
|
+
filename: "generated::fragmentVariables",
|
|
68098
|
+
originalString: ""
|
|
68099
|
+
});
|
|
68111
68100
|
}
|
|
68112
|
-
|
|
68113
|
-
|
|
68114
|
-
|
|
68115
|
-
|
|
68116
|
-
|
|
68101
|
+
function inlineFragmentArgs({
|
|
68102
|
+
config: config4,
|
|
68103
|
+
filepath,
|
|
68104
|
+
fragmentDefinitions,
|
|
68105
|
+
document,
|
|
68106
|
+
generatedFragments,
|
|
68107
|
+
visitedFragments,
|
|
68108
|
+
scope,
|
|
68109
|
+
newName
|
|
68110
|
+
}) {
|
|
68111
|
+
if (!scope) {
|
|
68112
|
+
scope = operationScope(
|
|
68113
|
+
document.definitions.find(
|
|
68114
|
+
({ kind }) => kind === GraphqlKinds2.OPERATION_DEFINITION
|
|
68115
|
+
)
|
|
68116
|
+
);
|
|
68117
68117
|
}
|
|
68118
|
-
const
|
|
68119
|
-
|
|
68120
|
-
|
|
68121
|
-
|
|
68122
|
-
|
|
68123
|
-
|
|
68124
|
-
|
|
68125
|
-
|
|
68126
|
-
|
|
68127
|
-
}
|
|
68128
|
-
|
|
68129
|
-
|
|
68118
|
+
const definitionArgs = fragmentArguments(
|
|
68119
|
+
config4,
|
|
68120
|
+
filepath,
|
|
68121
|
+
document
|
|
68122
|
+
).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
|
|
68123
|
+
const result = graphql5.visit(document, {
|
|
68124
|
+
FragmentSpread(node) {
|
|
68125
|
+
const { definition } = fragmentDefinitions[node.name.value];
|
|
68126
|
+
let { args, hash } = collectWithArguments(config4, filepath, node, scope);
|
|
68127
|
+
const newFragmentName = `${node.name.value}${hash}`;
|
|
68128
|
+
if (!visitedFragments.has(newFragmentName)) {
|
|
68129
|
+
visitedFragments.add(newFragmentName);
|
|
68130
|
+
const defaultArguments = collectDefaultArgumentValues(config4, filepath, definition);
|
|
68131
|
+
if (args) {
|
|
68132
|
+
for (const [field, value] of Object.entries(defaultArguments || {})) {
|
|
68133
|
+
if (!args[field]) {
|
|
68134
|
+
args[field] = value;
|
|
68135
|
+
}
|
|
68136
|
+
}
|
|
68137
|
+
generatedFragments[newFragmentName] = inlineFragmentArgs({
|
|
68138
|
+
config: config4,
|
|
68139
|
+
filepath,
|
|
68140
|
+
fragmentDefinitions,
|
|
68141
|
+
document: fragmentDefinitions[node.name.value].definition,
|
|
68142
|
+
generatedFragments,
|
|
68143
|
+
visitedFragments,
|
|
68144
|
+
scope: args,
|
|
68145
|
+
newName: newFragmentName
|
|
68146
|
+
});
|
|
68147
|
+
} else {
|
|
68148
|
+
const doc = fragmentDefinitions[node.name.value].document;
|
|
68149
|
+
const definitionIndex = doc.document.definitions.findIndex(
|
|
68150
|
+
(definition2) => definition2.kind === "FragmentDefinition" && definition2.name.value === node.name.value
|
|
68151
|
+
);
|
|
68152
|
+
const localDefinitions = [...doc.document.definitions];
|
|
68153
|
+
localDefinitions.splice(definitionIndex, 1);
|
|
68154
|
+
localDefinitions.push(
|
|
68155
|
+
inlineFragmentArgs({
|
|
68156
|
+
config: config4,
|
|
68157
|
+
filepath,
|
|
68158
|
+
fragmentDefinitions,
|
|
68159
|
+
document: fragmentDefinitions[node.name.value].definition,
|
|
68160
|
+
generatedFragments,
|
|
68161
|
+
visitedFragments,
|
|
68162
|
+
scope: defaultArguments,
|
|
68163
|
+
newName: ""
|
|
68164
|
+
})
|
|
68165
|
+
);
|
|
68166
|
+
doc.document = {
|
|
68167
|
+
...doc.document,
|
|
68168
|
+
definitions: localDefinitions
|
|
68169
|
+
};
|
|
68170
|
+
}
|
|
68171
|
+
if (node.name.value !== newFragmentName) {
|
|
68172
|
+
return {
|
|
68173
|
+
...node,
|
|
68174
|
+
name: {
|
|
68175
|
+
kind: "Name",
|
|
68176
|
+
value: newFragmentName
|
|
68177
|
+
}
|
|
68178
|
+
};
|
|
68179
|
+
}
|
|
68180
|
+
}
|
|
68181
|
+
},
|
|
68182
|
+
Argument(node) {
|
|
68183
|
+
const value = node.value;
|
|
68184
|
+
if (value.kind !== "Variable") {
|
|
68185
|
+
return;
|
|
68186
|
+
}
|
|
68187
|
+
if (!scope) {
|
|
68188
|
+
throw new HoudiniError({
|
|
68189
|
+
filepath,
|
|
68190
|
+
message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
|
|
68191
|
+
});
|
|
68192
|
+
}
|
|
68193
|
+
const newValue = scope[value.name.value];
|
|
68194
|
+
if (newValue) {
|
|
68195
|
+
return {
|
|
68196
|
+
...node,
|
|
68197
|
+
value: newValue
|
|
68198
|
+
};
|
|
68199
|
+
}
|
|
68200
|
+
if (definitionArgs[value.name.value] && definitionArgs[value.name.value].required) {
|
|
68201
|
+
throw new HoudiniError({
|
|
68202
|
+
filepath,
|
|
68203
|
+
message: "Missing value for required arg: " + value.name.value
|
|
68204
|
+
});
|
|
68205
|
+
}
|
|
68206
|
+
return null;
|
|
68207
|
+
}
|
|
68208
|
+
});
|
|
68209
|
+
if (newName) {
|
|
68210
|
+
result.name = {
|
|
68211
|
+
kind: graphql5.Kind.NAME,
|
|
68212
|
+
value: newName
|
|
68213
|
+
};
|
|
68214
|
+
}
|
|
68215
|
+
return result;
|
|
68216
|
+
}
|
|
68217
|
+
function withArguments(config4, node) {
|
|
68218
|
+
const withDirectives = node.directives?.filter(
|
|
68219
|
+
(directive) => directive.name.value === config4.withDirective
|
|
68220
|
+
);
|
|
68221
|
+
if (!withDirectives || withDirectives.length === 0) {
|
|
68222
|
+
return [];
|
|
68223
|
+
}
|
|
68224
|
+
return withDirectives.flatMap((directive) => directive.arguments || []);
|
|
68225
|
+
}
|
|
68226
|
+
function fragmentArguments(config4, filepath, definition) {
|
|
68227
|
+
const directives = definition.directives?.filter(
|
|
68228
|
+
(directive) => directive.name.value === config4.argumentsDirective
|
|
68229
|
+
);
|
|
68230
|
+
if (!directives || directives.length === 0) {
|
|
68231
|
+
return [];
|
|
68232
|
+
}
|
|
68233
|
+
return directives.flatMap(
|
|
68234
|
+
(directive) => directive.arguments?.flatMap((arg) => {
|
|
68235
|
+
if (arg.value.kind !== "ObjectValue") {
|
|
68236
|
+
throw new HoudiniError({
|
|
68237
|
+
filepath,
|
|
68238
|
+
message: "values of @argument must be objects"
|
|
68239
|
+
});
|
|
68240
|
+
}
|
|
68241
|
+
const typeArg = arg.value.fields?.find((arg2) => arg2.name.value === "type")?.value;
|
|
68242
|
+
if (!typeArg || typeArg.kind !== "StringValue") {
|
|
68243
|
+
return [];
|
|
68244
|
+
}
|
|
68245
|
+
let type = typeArg.value;
|
|
68246
|
+
let name2 = arg.name.value;
|
|
68247
|
+
let required = false;
|
|
68248
|
+
let defaultValue = arg.value.fields?.find((arg2) => arg2.name.value === "default")?.value || null;
|
|
68249
|
+
if (type[type.length - 1] === "!") {
|
|
68250
|
+
type = type.slice(0, -1);
|
|
68251
|
+
required = true;
|
|
68252
|
+
defaultValue = null;
|
|
68253
|
+
}
|
|
68254
|
+
return [
|
|
68255
|
+
{
|
|
68256
|
+
name: name2,
|
|
68257
|
+
type,
|
|
68258
|
+
required,
|
|
68259
|
+
defaultValue
|
|
68260
|
+
}
|
|
68261
|
+
];
|
|
68262
|
+
}) || []
|
|
68263
|
+
);
|
|
68264
|
+
}
|
|
68265
|
+
function collectDefaultArgumentValues(config4, filepath, definition) {
|
|
68266
|
+
let result = {};
|
|
68267
|
+
for (const { name: name2, required, defaultValue } of fragmentArguments(
|
|
68268
|
+
config4,
|
|
68269
|
+
filepath,
|
|
68270
|
+
definition
|
|
68271
|
+
)) {
|
|
68272
|
+
if (required || !defaultValue) {
|
|
68273
|
+
continue;
|
|
68274
|
+
}
|
|
68275
|
+
result[name2] = defaultValue;
|
|
68276
|
+
}
|
|
68277
|
+
return result;
|
|
68278
|
+
}
|
|
68279
|
+
function collectWithArguments(config4, filepath, node, scope = {}) {
|
|
68280
|
+
const withArgs = withArguments(config4, node);
|
|
68281
|
+
if (withArgs.length === 0) {
|
|
68282
|
+
return { args: null, hash: "" };
|
|
68283
|
+
}
|
|
68284
|
+
let args = {};
|
|
68285
|
+
for (const arg of withArgs) {
|
|
68286
|
+
let value = arg.value;
|
|
68287
|
+
if (value.kind === GraphqlKinds2.VARIABLE) {
|
|
68288
|
+
if (!scope || !scope[value.name.value]) {
|
|
68289
|
+
throw new HoudiniError({
|
|
68290
|
+
filepath,
|
|
68291
|
+
message: "Encountered undefined variable: " + value.name.value
|
|
68292
|
+
});
|
|
68293
|
+
}
|
|
68294
|
+
value = scope[value.name.value];
|
|
68295
|
+
}
|
|
68296
|
+
args[arg.name.value] = {
|
|
68297
|
+
...value,
|
|
68298
|
+
loc: void 0
|
|
68299
|
+
};
|
|
68300
|
+
}
|
|
68301
|
+
return {
|
|
68302
|
+
args,
|
|
68303
|
+
hash: "_" + murmurHash(JSON.stringify(args))
|
|
68304
|
+
};
|
|
68305
|
+
}
|
|
68306
|
+
function operationScope(operation) {
|
|
68307
|
+
return operation.variableDefinitions?.reduce(
|
|
68308
|
+
(scope, definition) => ({
|
|
68309
|
+
...scope,
|
|
68310
|
+
[definition.variable.name.value]: {
|
|
68311
|
+
kind: "Variable",
|
|
68312
|
+
name: {
|
|
68313
|
+
kind: "Name",
|
|
68314
|
+
value: definition.variable.name.value
|
|
68315
|
+
}
|
|
68316
|
+
}
|
|
68317
|
+
}),
|
|
68318
|
+
{}
|
|
68319
|
+
) || {};
|
|
68320
|
+
}
|
|
68321
|
+
function fragmentArgumentsDefinitions(config4, filepath, definition) {
|
|
68322
|
+
const args = fragmentArguments(config4, filepath, definition);
|
|
68323
|
+
if (args.length === 0) {
|
|
68324
|
+
return [];
|
|
68325
|
+
}
|
|
68326
|
+
return args.map((arg) => {
|
|
68327
|
+
const innerType = {
|
|
68328
|
+
kind: "NamedType",
|
|
68329
|
+
name: {
|
|
68330
|
+
kind: "Name",
|
|
68331
|
+
value: arg.type
|
|
68332
|
+
}
|
|
68333
|
+
};
|
|
68334
|
+
return {
|
|
68335
|
+
kind: "VariableDefinition",
|
|
68336
|
+
type: arg.required ? innerType : {
|
|
68337
|
+
kind: "NonNullType",
|
|
68338
|
+
type: innerType
|
|
68339
|
+
},
|
|
68340
|
+
variable: {
|
|
68341
|
+
kind: "Variable",
|
|
68342
|
+
name: {
|
|
68343
|
+
kind: "Name",
|
|
68344
|
+
value: arg.name
|
|
68345
|
+
}
|
|
68346
|
+
},
|
|
68347
|
+
defaultValue: arg.defaultValue ?? void 0
|
|
68348
|
+
};
|
|
68349
|
+
});
|
|
68350
|
+
}
|
|
68351
|
+
|
|
68352
|
+
// src/codegen/generators/artifacts/indexFile.ts
|
|
68353
|
+
async function writeIndexFile(config4, docs) {
|
|
68354
|
+
const docsToGenerate = docs.filter((doc) => doc.generateArtifact).sort((a, b) => a.name.localeCompare(b.name));
|
|
68355
|
+
let body = config4.module === "esm" ? docsToGenerate.reduce(
|
|
68356
|
+
(content, doc) => content + `
|
|
68357
|
+
export { default as ${doc.name}} from './${doc.name}'`,
|
|
68358
|
+
""
|
|
68359
|
+
) : docsToGenerate.reduce(
|
|
68360
|
+
(content, doc) => content + `
|
|
68361
|
+
${exportDefaultFrom(`./${doc.name}`, doc.name)}`,
|
|
68362
|
+
cjsIndexFilePreamble
|
|
68363
|
+
);
|
|
68364
|
+
await fs_exports.writeFile(path_exports.join(config4.artifactDirectory, "index.js"), body);
|
|
68365
|
+
}
|
|
68366
|
+
|
|
68367
|
+
// src/codegen/generators/artifacts/inputs.ts
|
|
68368
|
+
var graphql6 = __toESM(require_graphql2(), 1);
|
|
68369
|
+
var recast3 = __toESM(require_main2(), 1);
|
|
68370
|
+
var AST3 = recast3.types.builders;
|
|
68371
|
+
function inputObject(config4, inputs) {
|
|
68372
|
+
const visitedTypes = /* @__PURE__ */ new Set();
|
|
68373
|
+
const inputObj = {
|
|
68374
|
+
fields: inputs.reduce((fields, input) => {
|
|
68375
|
+
const { type } = unwrapType(config4, input.type);
|
|
68376
|
+
return {
|
|
68377
|
+
...fields,
|
|
68378
|
+
[input.variable.name.value]: type.name
|
|
68379
|
+
};
|
|
68380
|
+
}, {}),
|
|
68381
|
+
types: {}
|
|
68382
|
+
};
|
|
68383
|
+
for (const input of inputs) {
|
|
68384
|
+
walkInputs(config4, visitedTypes, inputObj, input.type);
|
|
68385
|
+
}
|
|
68386
|
+
return inputObj;
|
|
68387
|
+
}
|
|
68388
|
+
function walkInputs(config4, visitedTypes, inputObj, rootType) {
|
|
68389
|
+
const { type } = unwrapType(config4, rootType);
|
|
68390
|
+
if (visitedTypes.has(type.name)) {
|
|
68391
|
+
return;
|
|
68392
|
+
}
|
|
68393
|
+
if (graphql6.isEnumType(type) || graphql6.isScalarType(type)) {
|
|
68394
|
+
return;
|
|
68395
|
+
}
|
|
68396
|
+
if (graphql6.isUnionType(type)) {
|
|
68397
|
+
return;
|
|
68398
|
+
}
|
|
68399
|
+
visitedTypes.add(type.name);
|
|
68400
|
+
inputObj.types[type.name] = Object.values(type.getFields()).reduce(
|
|
68401
|
+
(typeFields, field) => {
|
|
68402
|
+
const { type: fieldType } = unwrapType(config4, field.type);
|
|
68403
|
+
walkInputs(config4, visitedTypes, inputObj, fieldType);
|
|
68404
|
+
return {
|
|
68405
|
+
...typeFields,
|
|
68406
|
+
[field.name]: fieldType.toString()
|
|
68407
|
+
};
|
|
68408
|
+
},
|
|
68409
|
+
{}
|
|
68410
|
+
);
|
|
68411
|
+
}
|
|
68412
|
+
|
|
68413
|
+
// src/codegen/generators/artifacts/operations.ts
|
|
68414
|
+
var graphql8 = __toESM(require_graphql2(), 1);
|
|
68415
|
+
|
|
68416
|
+
// src/codegen/generators/artifacts/utils.ts
|
|
68417
|
+
var graphql7 = __toESM(require_graphql2(), 1);
|
|
68418
|
+
var recast4 = __toESM(require_main2(), 1);
|
|
68419
|
+
var AST4 = recast4.types.builders;
|
|
68420
|
+
function serializeValue(value) {
|
|
68421
|
+
if (Array.isArray(value)) {
|
|
68422
|
+
return AST4.arrayExpression(value.map(serializeValue));
|
|
68423
|
+
}
|
|
68424
|
+
if (typeof value === "object" && value !== null) {
|
|
68425
|
+
return AST4.objectExpression(
|
|
68426
|
+
Object.entries(value).filter(([, value2]) => typeof value2 !== "undefined").map(
|
|
68427
|
+
([key, value2]) => AST4.objectProperty(AST4.stringLiteral(key), serializeValue(value2))
|
|
68428
|
+
)
|
|
68429
|
+
);
|
|
68430
|
+
}
|
|
68431
|
+
if (typeof value === "string") {
|
|
68432
|
+
if (value.indexOf("\n") !== -1) {
|
|
68433
|
+
return AST4.templateLiteral(
|
|
68434
|
+
[AST4.templateElement({ raw: value, cooked: value }, true)],
|
|
68435
|
+
[]
|
|
68436
|
+
);
|
|
68437
|
+
}
|
|
68438
|
+
return AST4.stringLiteral(value);
|
|
68439
|
+
}
|
|
68440
|
+
return AST4.literal(value);
|
|
68441
|
+
}
|
|
68442
|
+
function deepMerge(filepath, ...targets) {
|
|
68443
|
+
if (typeof targets[0] !== "object") {
|
|
68444
|
+
const matches = targets.filter((val) => val !== targets[0]).length === 0;
|
|
68445
|
+
if (!matches) {
|
|
68446
|
+
throw new HoudiniError({ filepath, message: "could not merge: " + targets });
|
|
68447
|
+
}
|
|
68448
|
+
return targets[0];
|
|
68449
|
+
}
|
|
68450
|
+
if (Array.isArray(targets[0])) {
|
|
68451
|
+
return targets[0].concat(...targets.slice(1));
|
|
68452
|
+
}
|
|
68453
|
+
const fields = {};
|
|
68454
|
+
for (const target of targets) {
|
|
68455
|
+
for (const [key, value] of Object.entries(target)) {
|
|
68456
|
+
if (!fields[key]) {
|
|
68457
|
+
fields[key] = [];
|
|
68458
|
+
}
|
|
68459
|
+
fields[key].push(value);
|
|
68460
|
+
}
|
|
68461
|
+
}
|
|
68462
|
+
return Object.fromEntries(
|
|
68463
|
+
Object.entries(fields).map(([key, value]) => [key, deepMerge(filepath, ...value)])
|
|
68464
|
+
);
|
|
68465
|
+
}
|
|
68466
|
+
function convertValue(config4, val) {
|
|
68467
|
+
let value;
|
|
68468
|
+
let kind;
|
|
68469
|
+
if (val.kind === graphql7.Kind.INT) {
|
|
68470
|
+
value = parseInt(val.value, 10);
|
|
68471
|
+
kind = "Int";
|
|
68472
|
+
} else if (val.kind === graphql7.Kind.FLOAT) {
|
|
68473
|
+
value = parseFloat(val.value);
|
|
68474
|
+
kind = "Float";
|
|
68475
|
+
} else if (val.kind === graphql7.Kind.BOOLEAN) {
|
|
68476
|
+
value = val.value;
|
|
68477
|
+
kind = "Boolean";
|
|
68478
|
+
} else if (val.kind === graphql7.Kind.VARIABLE) {
|
|
68479
|
+
value = val.name.value;
|
|
68480
|
+
kind = "Variable";
|
|
68481
|
+
} else if (val.kind === graphql7.Kind.STRING) {
|
|
68482
|
+
value = val.value;
|
|
68483
|
+
kind = "String";
|
|
68484
|
+
}
|
|
68485
|
+
return { kind, value };
|
|
68486
|
+
}
|
|
68487
|
+
|
|
68488
|
+
// src/codegen/generators/artifacts/operations.ts
|
|
68489
|
+
function operationsByPath(config4, filepath, definition, filterTypes) {
|
|
68490
|
+
if (!definition) {
|
|
68491
|
+
return {};
|
|
68492
|
+
}
|
|
68493
|
+
const pathOperations = {};
|
|
68494
|
+
graphql8.visit(definition, {
|
|
68495
|
+
FragmentSpread(node, _, __, ___, ancestors) {
|
|
68496
|
+
if (!config4.isListFragment(node.name.value)) {
|
|
68497
|
+
return;
|
|
68498
|
+
}
|
|
68499
|
+
const path2 = ancestorKey(ancestors);
|
|
68500
|
+
if (!pathOperations[path2]) {
|
|
68501
|
+
pathOperations[path2] = [];
|
|
68502
|
+
}
|
|
68503
|
+
pathOperations[path2].push(
|
|
68504
|
+
operationObject({
|
|
68130
68505
|
config: config4,
|
|
68131
68506
|
filepath,
|
|
68132
68507
|
listName: config4.listNameFromFragment(node.name.value),
|
|
@@ -68275,7 +68650,7 @@ function ancestorKey(ancestors) {
|
|
|
68275
68650
|
}
|
|
68276
68651
|
|
|
68277
68652
|
// src/codegen/generators/artifacts/selection.ts
|
|
68278
|
-
var
|
|
68653
|
+
var graphql13 = __toESM(require_graphql2(), 1);
|
|
68279
68654
|
|
|
68280
68655
|
// ../../node_modules/.pnpm/@kitql+helper@0.5.0/node_modules/@kitql/helper/index.mjs
|
|
68281
68656
|
var config2 = {
|
|
@@ -68321,16 +68696,16 @@ async function sleep2(ms) {
|
|
|
68321
68696
|
}
|
|
68322
68697
|
|
|
68323
68698
|
// src/codegen/transforms/list.ts
|
|
68324
|
-
var
|
|
68699
|
+
var graphql11 = __toESM(require_graphql2(), 1);
|
|
68325
68700
|
|
|
68326
68701
|
// src/codegen/utils/objectIdentificationSelection.ts
|
|
68327
|
-
var
|
|
68702
|
+
var graphql9 = __toESM(require_graphql2(), 1);
|
|
68328
68703
|
var objectIdentificationSelection = (config4, type) => {
|
|
68329
68704
|
return config4.keyFieldsForType(type.name).map((key) => {
|
|
68330
68705
|
return {
|
|
68331
|
-
kind:
|
|
68706
|
+
kind: graphql9.Kind.FIELD,
|
|
68332
68707
|
name: {
|
|
68333
|
-
kind:
|
|
68708
|
+
kind: graphql9.Kind.NAME,
|
|
68334
68709
|
value: key
|
|
68335
68710
|
}
|
|
68336
68711
|
};
|
|
@@ -68338,7 +68713,7 @@ var objectIdentificationSelection = (config4, type) => {
|
|
|
68338
68713
|
};
|
|
68339
68714
|
|
|
68340
68715
|
// src/codegen/transforms/paginate.ts
|
|
68341
|
-
var
|
|
68716
|
+
var graphql10 = __toESM(require_graphql2(), 1);
|
|
68342
68717
|
async function paginate(config4, documents) {
|
|
68343
68718
|
const newDocs = [];
|
|
68344
68719
|
for (const doc of documents) {
|
|
@@ -68371,7 +68746,7 @@ async function paginate(config4, documents) {
|
|
|
68371
68746
|
};
|
|
68372
68747
|
let cursorType = "String";
|
|
68373
68748
|
let paginationPath = [];
|
|
68374
|
-
doc.document =
|
|
68749
|
+
doc.document = graphql10.visit(doc.document, {
|
|
68375
68750
|
Field(node, _, __, ___, ancestors) {
|
|
68376
68751
|
const paginateDirective = node.directives?.find(
|
|
68377
68752
|
(directive) => directive.name.value === config4.paginateDirective
|
|
@@ -68398,7 +68773,7 @@ async function paginate(config4, documents) {
|
|
|
68398
68773
|
flags.offset.enabled = offsetPagination;
|
|
68399
68774
|
flags.limit.enabled = offsetPagination;
|
|
68400
68775
|
paginationPath = ancestors.filter(
|
|
68401
|
-
(ancestor) => !Array.isArray(ancestor) && ancestor.kind ===
|
|
68776
|
+
(ancestor) => !Array.isArray(ancestor) && ancestor.kind === graphql10.Kind.FIELD
|
|
68402
68777
|
).concat(node).map((field) => field.alias?.value || field.name.value);
|
|
68403
68778
|
return {
|
|
68404
68779
|
...node,
|
|
@@ -68419,7 +68794,7 @@ async function paginate(config4, documents) {
|
|
|
68419
68794
|
refetchUpdate = "prepend" /* prepend */;
|
|
68420
68795
|
}
|
|
68421
68796
|
let fragment = "";
|
|
68422
|
-
doc.document =
|
|
68797
|
+
doc.document = graphql10.visit(doc.document, {
|
|
68423
68798
|
OperationDefinition(node) {
|
|
68424
68799
|
if (node.operation !== "query") {
|
|
68425
68800
|
throw new HoudiniError({
|
|
@@ -68473,9 +68848,9 @@ async function paginate(config4, documents) {
|
|
|
68473
68848
|
directives: [
|
|
68474
68849
|
...node.directives || [],
|
|
68475
68850
|
{
|
|
68476
|
-
kind:
|
|
68851
|
+
kind: graphql10.Kind.DIRECTIVE,
|
|
68477
68852
|
name: {
|
|
68478
|
-
kind:
|
|
68853
|
+
kind: graphql10.Kind.NAME,
|
|
68479
68854
|
value: config4.argumentsDirective
|
|
68480
68855
|
}
|
|
68481
68856
|
}
|
|
@@ -68538,16 +68913,16 @@ async function paginate(config4, documents) {
|
|
|
68538
68913
|
const paginationArgs = Object.entries(flags).filter(([_, { enabled }]) => enabled).map(([key, value]) => ({ name: key, ...value }));
|
|
68539
68914
|
const fragmentSpreadSelection = [
|
|
68540
68915
|
{
|
|
68541
|
-
kind:
|
|
68916
|
+
kind: graphql10.Kind.FRAGMENT_SPREAD,
|
|
68542
68917
|
name: {
|
|
68543
|
-
kind:
|
|
68918
|
+
kind: graphql10.Kind.NAME,
|
|
68544
68919
|
value: fragmentName
|
|
68545
68920
|
},
|
|
68546
68921
|
directives: [
|
|
68547
68922
|
{
|
|
68548
|
-
kind:
|
|
68923
|
+
kind: graphql10.Kind.DIRECTIVE,
|
|
68549
68924
|
name: {
|
|
68550
|
-
kind:
|
|
68925
|
+
kind: graphql10.Kind.NAME,
|
|
68551
68926
|
value: config4.withDirective
|
|
68552
68927
|
},
|
|
68553
68928
|
["arguments"]: paginationArgs.map(
|
|
@@ -68575,29 +68950,29 @@ async function paginate(config4, documents) {
|
|
|
68575
68950
|
});
|
|
68576
68951
|
const typeConfig = config4.typeConfig?.[fragment];
|
|
68577
68952
|
const queryDoc = {
|
|
68578
|
-
kind:
|
|
68953
|
+
kind: graphql10.Kind.DOCUMENT,
|
|
68579
68954
|
definitions: [
|
|
68580
68955
|
{
|
|
68581
|
-
kind:
|
|
68956
|
+
kind: graphql10.Kind.OPERATION_DEFINITION,
|
|
68582
68957
|
name: {
|
|
68583
|
-
kind:
|
|
68958
|
+
kind: graphql10.Kind.NAME,
|
|
68584
68959
|
value: refetchQueryName
|
|
68585
68960
|
},
|
|
68586
68961
|
operation: "query",
|
|
68587
68962
|
variableDefinitions: paginationArgs.map(
|
|
68588
68963
|
(arg) => ({
|
|
68589
|
-
kind:
|
|
68964
|
+
kind: graphql10.Kind.VARIABLE_DEFINITION,
|
|
68590
68965
|
type: {
|
|
68591
|
-
kind:
|
|
68966
|
+
kind: graphql10.Kind.NAMED_TYPE,
|
|
68592
68967
|
name: {
|
|
68593
|
-
kind:
|
|
68968
|
+
kind: graphql10.Kind.NAME,
|
|
68594
68969
|
value: arg.type
|
|
68595
68970
|
}
|
|
68596
68971
|
},
|
|
68597
68972
|
variable: {
|
|
68598
|
-
kind:
|
|
68973
|
+
kind: graphql10.Kind.VARIABLE,
|
|
68599
68974
|
name: {
|
|
68600
|
-
kind:
|
|
68975
|
+
kind: graphql10.Kind.NAME,
|
|
68601
68976
|
value: arg.name
|
|
68602
68977
|
}
|
|
68603
68978
|
},
|
|
@@ -68609,12 +68984,12 @@ async function paginate(config4, documents) {
|
|
|
68609
68984
|
).concat(
|
|
68610
68985
|
!nodeQuery ? [] : keys.map(
|
|
68611
68986
|
(key) => ({
|
|
68612
|
-
kind:
|
|
68987
|
+
kind: graphql10.Kind.VARIABLE_DEFINITION,
|
|
68613
68988
|
type: key.type,
|
|
68614
68989
|
variable: {
|
|
68615
|
-
kind:
|
|
68990
|
+
kind: graphql10.Kind.VARIABLE,
|
|
68616
68991
|
name: {
|
|
68617
|
-
kind:
|
|
68992
|
+
kind: graphql10.Kind.NAME,
|
|
68618
68993
|
value: key.name
|
|
68619
68994
|
}
|
|
68620
68995
|
}
|
|
@@ -68622,42 +68997,42 @@ async function paginate(config4, documents) {
|
|
|
68622
68997
|
)
|
|
68623
68998
|
),
|
|
68624
68999
|
selectionSet: {
|
|
68625
|
-
kind:
|
|
69000
|
+
kind: graphql10.Kind.SELECTION_SET,
|
|
68626
69001
|
selections: !nodeQuery ? fragmentSpreadSelection : [
|
|
68627
69002
|
{
|
|
68628
|
-
kind:
|
|
69003
|
+
kind: graphql10.Kind.FIELD,
|
|
68629
69004
|
name: {
|
|
68630
|
-
kind:
|
|
69005
|
+
kind: graphql10.Kind.NAME,
|
|
68631
69006
|
value: typeConfig?.resolve?.queryField || "node"
|
|
68632
69007
|
},
|
|
68633
69008
|
["arguments"]: keys.map((key) => ({
|
|
68634
|
-
kind:
|
|
69009
|
+
kind: graphql10.Kind.ARGUMENT,
|
|
68635
69010
|
name: {
|
|
68636
|
-
kind:
|
|
69011
|
+
kind: graphql10.Kind.NAME,
|
|
68637
69012
|
value: key.name
|
|
68638
69013
|
},
|
|
68639
69014
|
value: {
|
|
68640
|
-
kind:
|
|
69015
|
+
kind: graphql10.Kind.VARIABLE,
|
|
68641
69016
|
name: {
|
|
68642
|
-
kind:
|
|
69017
|
+
kind: graphql10.Kind.NAME,
|
|
68643
69018
|
value: key.name
|
|
68644
69019
|
}
|
|
68645
69020
|
}
|
|
68646
69021
|
})),
|
|
68647
69022
|
selectionSet: {
|
|
68648
|
-
kind:
|
|
69023
|
+
kind: graphql10.Kind.SELECTION_SET,
|
|
68649
69024
|
selections: [
|
|
68650
69025
|
{
|
|
68651
|
-
kind:
|
|
69026
|
+
kind: graphql10.Kind.FIELD,
|
|
68652
69027
|
name: {
|
|
68653
|
-
kind:
|
|
69028
|
+
kind: graphql10.Kind.NAME,
|
|
68654
69029
|
value: "__typename"
|
|
68655
69030
|
}
|
|
68656
69031
|
},
|
|
68657
69032
|
...(typeConfig?.keys || ["id"]).map((key) => ({
|
|
68658
|
-
kind:
|
|
69033
|
+
kind: graphql10.Kind.FIELD,
|
|
68659
69034
|
name: {
|
|
68660
|
-
kind:
|
|
69035
|
+
kind: graphql10.Kind.NAME,
|
|
68661
69036
|
value: key
|
|
68662
69037
|
}
|
|
68663
69038
|
})),
|
|
@@ -68719,15 +69094,15 @@ function replaceArgumentsWithVariables(args, flags) {
|
|
|
68719
69094
|
}
|
|
68720
69095
|
function variableAsArgument(name2, variable) {
|
|
68721
69096
|
return {
|
|
68722
|
-
kind:
|
|
69097
|
+
kind: graphql10.Kind.ARGUMENT,
|
|
68723
69098
|
name: {
|
|
68724
|
-
kind:
|
|
69099
|
+
kind: graphql10.Kind.NAME,
|
|
68725
69100
|
value: name2
|
|
68726
69101
|
},
|
|
68727
69102
|
value: {
|
|
68728
|
-
kind:
|
|
69103
|
+
kind: graphql10.Kind.VARIABLE,
|
|
68729
69104
|
name: {
|
|
68730
|
-
kind:
|
|
69105
|
+
kind: graphql10.Kind.NAME,
|
|
68731
69106
|
value: variable ?? name2
|
|
68732
69107
|
}
|
|
68733
69108
|
}
|
|
@@ -68735,18 +69110,18 @@ function variableAsArgument(name2, variable) {
|
|
|
68735
69110
|
}
|
|
68736
69111
|
function staticVariableDefinition(name2, type, defaultValue, variableName) {
|
|
68737
69112
|
return {
|
|
68738
|
-
kind:
|
|
69113
|
+
kind: graphql10.Kind.VARIABLE_DEFINITION,
|
|
68739
69114
|
type: {
|
|
68740
|
-
kind:
|
|
69115
|
+
kind: graphql10.Kind.NAMED_TYPE,
|
|
68741
69116
|
name: {
|
|
68742
|
-
kind:
|
|
69117
|
+
kind: graphql10.Kind.NAME,
|
|
68743
69118
|
value: type
|
|
68744
69119
|
}
|
|
68745
69120
|
},
|
|
68746
69121
|
variable: {
|
|
68747
|
-
kind:
|
|
69122
|
+
kind: graphql10.Kind.VARIABLE,
|
|
68748
69123
|
name: {
|
|
68749
|
-
kind:
|
|
69124
|
+
kind: graphql10.Kind.NAME,
|
|
68750
69125
|
value: variableName ?? name2
|
|
68751
69126
|
}
|
|
68752
69127
|
},
|
|
@@ -68758,9 +69133,9 @@ function staticVariableDefinition(name2, type, defaultValue, variableName) {
|
|
|
68758
69133
|
}
|
|
68759
69134
|
function argumentNode(name2, value) {
|
|
68760
69135
|
return {
|
|
68761
|
-
kind:
|
|
69136
|
+
kind: graphql10.Kind.ARGUMENT,
|
|
68762
69137
|
name: {
|
|
68763
|
-
kind:
|
|
69138
|
+
kind: graphql10.Kind.NAME,
|
|
68764
69139
|
value: name2
|
|
68765
69140
|
},
|
|
68766
69141
|
value: objectNode(value)
|
|
@@ -68768,16 +69143,16 @@ function argumentNode(name2, value) {
|
|
|
68768
69143
|
}
|
|
68769
69144
|
function objectNode([type, defaultValue]) {
|
|
68770
69145
|
const node = {
|
|
68771
|
-
kind:
|
|
69146
|
+
kind: graphql10.Kind.OBJECT,
|
|
68772
69147
|
fields: [
|
|
68773
69148
|
{
|
|
68774
|
-
kind:
|
|
69149
|
+
kind: graphql10.Kind.OBJECT_FIELD,
|
|
68775
69150
|
name: {
|
|
68776
|
-
kind:
|
|
69151
|
+
kind: graphql10.Kind.NAME,
|
|
68777
69152
|
value: "type"
|
|
68778
69153
|
},
|
|
68779
69154
|
value: {
|
|
68780
|
-
kind:
|
|
69155
|
+
kind: graphql10.Kind.STRING,
|
|
68781
69156
|
value: type
|
|
68782
69157
|
}
|
|
68783
69158
|
}
|
|
@@ -68785,8 +69160,8 @@ function objectNode([type, defaultValue]) {
|
|
|
68785
69160
|
};
|
|
68786
69161
|
if (defaultValue) {
|
|
68787
69162
|
node.fields.push({
|
|
68788
|
-
kind:
|
|
68789
|
-
name: { kind:
|
|
69163
|
+
kind: graphql10.Kind.OBJECT_FIELD,
|
|
69164
|
+
name: { kind: graphql10.Kind.NAME, value: "default" },
|
|
68790
69165
|
value: {
|
|
68791
69166
|
kind: typeof defaultValue === "number" ? "IntValue" : "StringValue",
|
|
68792
69167
|
value: defaultValue.toString()
|
|
@@ -68797,34 +69172,34 @@ function objectNode([type, defaultValue]) {
|
|
|
68797
69172
|
}
|
|
68798
69173
|
var pageInfoSelection = [
|
|
68799
69174
|
{
|
|
68800
|
-
kind:
|
|
69175
|
+
kind: graphql10.Kind.FIELD,
|
|
68801
69176
|
name: {
|
|
68802
|
-
kind:
|
|
69177
|
+
kind: graphql10.Kind.NAME,
|
|
68803
69178
|
value: "edges"
|
|
68804
69179
|
},
|
|
68805
69180
|
selectionSet: {
|
|
68806
|
-
kind:
|
|
69181
|
+
kind: graphql10.Kind.SELECTION_SET,
|
|
68807
69182
|
selections: [
|
|
68808
69183
|
{
|
|
68809
|
-
kind:
|
|
69184
|
+
kind: graphql10.Kind.FIELD,
|
|
68810
69185
|
name: {
|
|
68811
|
-
kind:
|
|
69186
|
+
kind: graphql10.Kind.NAME,
|
|
68812
69187
|
value: "cursor"
|
|
68813
69188
|
}
|
|
68814
69189
|
},
|
|
68815
69190
|
{
|
|
68816
|
-
kind:
|
|
69191
|
+
kind: graphql10.Kind.FIELD,
|
|
68817
69192
|
name: {
|
|
68818
|
-
kind:
|
|
69193
|
+
kind: graphql10.Kind.NAME,
|
|
68819
69194
|
value: "node"
|
|
68820
69195
|
},
|
|
68821
69196
|
selectionSet: {
|
|
68822
|
-
kind:
|
|
69197
|
+
kind: graphql10.Kind.SELECTION_SET,
|
|
68823
69198
|
selections: [
|
|
68824
69199
|
{
|
|
68825
|
-
kind:
|
|
69200
|
+
kind: graphql10.Kind.FIELD,
|
|
68826
69201
|
name: {
|
|
68827
|
-
kind:
|
|
69202
|
+
kind: graphql10.Kind.NAME,
|
|
68828
69203
|
value: "__typename"
|
|
68829
69204
|
}
|
|
68830
69205
|
}
|
|
@@ -68835,39 +69210,39 @@ var pageInfoSelection = [
|
|
|
68835
69210
|
}
|
|
68836
69211
|
},
|
|
68837
69212
|
{
|
|
68838
|
-
kind:
|
|
69213
|
+
kind: graphql10.Kind.FIELD,
|
|
68839
69214
|
name: {
|
|
68840
|
-
kind:
|
|
69215
|
+
kind: graphql10.Kind.NAME,
|
|
68841
69216
|
value: "pageInfo"
|
|
68842
69217
|
},
|
|
68843
69218
|
selectionSet: {
|
|
68844
|
-
kind:
|
|
69219
|
+
kind: graphql10.Kind.SELECTION_SET,
|
|
68845
69220
|
selections: [
|
|
68846
69221
|
{
|
|
68847
|
-
kind:
|
|
69222
|
+
kind: graphql10.Kind.FIELD,
|
|
68848
69223
|
name: {
|
|
68849
|
-
kind:
|
|
69224
|
+
kind: graphql10.Kind.NAME,
|
|
68850
69225
|
value: "hasPreviousPage"
|
|
68851
69226
|
}
|
|
68852
69227
|
},
|
|
68853
69228
|
{
|
|
68854
|
-
kind:
|
|
69229
|
+
kind: graphql10.Kind.FIELD,
|
|
68855
69230
|
name: {
|
|
68856
|
-
kind:
|
|
69231
|
+
kind: graphql10.Kind.NAME,
|
|
68857
69232
|
value: "hasNextPage"
|
|
68858
69233
|
}
|
|
68859
69234
|
},
|
|
68860
69235
|
{
|
|
68861
|
-
kind:
|
|
69236
|
+
kind: graphql10.Kind.FIELD,
|
|
68862
69237
|
name: {
|
|
68863
|
-
kind:
|
|
69238
|
+
kind: graphql10.Kind.NAME,
|
|
68864
69239
|
value: "startCursor"
|
|
68865
69240
|
}
|
|
68866
69241
|
},
|
|
68867
69242
|
{
|
|
68868
|
-
kind:
|
|
69243
|
+
kind: graphql10.Kind.FIELD,
|
|
68869
69244
|
name: {
|
|
68870
|
-
kind:
|
|
69245
|
+
kind: graphql10.Kind.NAME,
|
|
68871
69246
|
value: "endCursor"
|
|
68872
69247
|
}
|
|
68873
69248
|
}
|
|
@@ -68881,15 +69256,15 @@ async function addListFragments(config4, documents) {
|
|
|
68881
69256
|
const lists = {};
|
|
68882
69257
|
const errors = [];
|
|
68883
69258
|
for (const doc of documents) {
|
|
68884
|
-
doc.document =
|
|
69259
|
+
doc.document = graphql11.visit(doc.document, {
|
|
68885
69260
|
Directive(node, key, parent, path2, ancestors) {
|
|
68886
69261
|
if ([config4.listDirective, config4.paginateDirective].includes(node.name.value)) {
|
|
68887
69262
|
const nameArg = node.arguments?.find((arg) => arg.name.value === "name");
|
|
68888
69263
|
let error = {
|
|
68889
|
-
...new
|
|
69264
|
+
...new graphql11.GraphQLError(
|
|
68890
69265
|
"",
|
|
68891
69266
|
node,
|
|
68892
|
-
new
|
|
69267
|
+
new graphql11.Source(""),
|
|
68893
69268
|
node.loc ? [node.loc.start, node.loc.end] : null,
|
|
68894
69269
|
path2
|
|
68895
69270
|
),
|
|
@@ -68941,7 +69316,7 @@ async function addListFragments(config4, documents) {
|
|
|
68941
69316
|
{
|
|
68942
69317
|
kind: "Argument",
|
|
68943
69318
|
name: {
|
|
68944
|
-
kind:
|
|
69319
|
+
kind: graphql11.Kind.NAME,
|
|
68945
69320
|
value: "connection"
|
|
68946
69321
|
},
|
|
68947
69322
|
value: {
|
|
@@ -68991,7 +69366,7 @@ async function addListFragments(config4, documents) {
|
|
|
68991
69366
|
const validDeletes = [
|
|
68992
69367
|
...new Set(
|
|
68993
69368
|
Object.values(lists).map(({ type }) => {
|
|
68994
|
-
if (!(type instanceof
|
|
69369
|
+
if (!(type instanceof graphql11.GraphQLObjectType)) {
|
|
68995
69370
|
return "";
|
|
68996
69371
|
}
|
|
68997
69372
|
if (config4.keyFieldsForType(type.name).length !== 1) {
|
|
@@ -69005,7 +69380,7 @@ async function addListFragments(config4, documents) {
|
|
|
69005
69380
|
return;
|
|
69006
69381
|
}
|
|
69007
69382
|
const generatedDoc = {
|
|
69008
|
-
kind:
|
|
69383
|
+
kind: graphql11.Kind.DOCUMENT,
|
|
69009
69384
|
definitions: Object.entries(lists).flatMap(
|
|
69010
69385
|
([name2, { selection: selection2, type }]) => {
|
|
69011
69386
|
const schemaType = config4.schema.getType(type.name);
|
|
@@ -69013,7 +69388,7 @@ async function addListFragments(config4, documents) {
|
|
|
69013
69388
|
throw new HoudiniError({ message: "Lists must have a selection" });
|
|
69014
69389
|
}
|
|
69015
69390
|
const fragmentSelection = {
|
|
69016
|
-
kind:
|
|
69391
|
+
kind: graphql11.Kind.SELECTION_SET,
|
|
69017
69392
|
selections: [...selection2.selections]
|
|
69018
69393
|
};
|
|
69019
69394
|
if (schemaType && fragmentSelection && !fragmentSelection?.selections.find(
|
|
@@ -69028,14 +69403,14 @@ async function addListFragments(config4, documents) {
|
|
|
69028
69403
|
{
|
|
69029
69404
|
name: {
|
|
69030
69405
|
value: config4.listInsertFragment(name2),
|
|
69031
|
-
kind:
|
|
69406
|
+
kind: graphql11.Kind.NAME
|
|
69032
69407
|
},
|
|
69033
|
-
kind:
|
|
69408
|
+
kind: graphql11.Kind.FRAGMENT_DEFINITION,
|
|
69034
69409
|
selectionSet: fragmentSelection,
|
|
69035
69410
|
typeCondition: {
|
|
69036
|
-
kind:
|
|
69411
|
+
kind: graphql11.Kind.NAMED_TYPE,
|
|
69037
69412
|
name: {
|
|
69038
|
-
kind:
|
|
69413
|
+
kind: graphql11.Kind.NAME,
|
|
69039
69414
|
value: type.name
|
|
69040
69415
|
}
|
|
69041
69416
|
}
|
|
@@ -69043,32 +69418,32 @@ async function addListFragments(config4, documents) {
|
|
|
69043
69418
|
{
|
|
69044
69419
|
name: {
|
|
69045
69420
|
value: config4.listToggleFragment(name2),
|
|
69046
|
-
kind:
|
|
69421
|
+
kind: graphql11.Kind.NAME
|
|
69047
69422
|
},
|
|
69048
|
-
kind:
|
|
69423
|
+
kind: graphql11.Kind.FRAGMENT_DEFINITION,
|
|
69049
69424
|
selectionSet: fragmentSelection,
|
|
69050
69425
|
typeCondition: {
|
|
69051
|
-
kind:
|
|
69426
|
+
kind: graphql11.Kind.NAMED_TYPE,
|
|
69052
69427
|
name: {
|
|
69053
|
-
kind:
|
|
69428
|
+
kind: graphql11.Kind.NAME,
|
|
69054
69429
|
value: type.name
|
|
69055
69430
|
}
|
|
69056
69431
|
}
|
|
69057
69432
|
},
|
|
69058
69433
|
{
|
|
69059
|
-
kind:
|
|
69434
|
+
kind: graphql11.Kind.FRAGMENT_DEFINITION,
|
|
69060
69435
|
name: {
|
|
69061
69436
|
value: config4.listRemoveFragment(name2),
|
|
69062
|
-
kind:
|
|
69437
|
+
kind: graphql11.Kind.NAME
|
|
69063
69438
|
},
|
|
69064
69439
|
selectionSet: {
|
|
69065
|
-
kind:
|
|
69440
|
+
kind: graphql11.Kind.SELECTION_SET,
|
|
69066
69441
|
selections: [...objectIdentificationSelection(config4, type)]
|
|
69067
69442
|
},
|
|
69068
69443
|
typeCondition: {
|
|
69069
|
-
kind:
|
|
69444
|
+
kind: graphql11.Kind.NAMED_TYPE,
|
|
69070
69445
|
name: {
|
|
69071
|
-
kind:
|
|
69446
|
+
kind: graphql11.Kind.NAME,
|
|
69072
69447
|
value: type.name
|
|
69073
69448
|
}
|
|
69074
69449
|
}
|
|
@@ -69077,14 +69452,14 @@ async function addListFragments(config4, documents) {
|
|
|
69077
69452
|
}
|
|
69078
69453
|
).concat(
|
|
69079
69454
|
...validDeletes.map((typeName) => ({
|
|
69080
|
-
kind:
|
|
69455
|
+
kind: graphql11.Kind.DIRECTIVE_DEFINITION,
|
|
69081
69456
|
name: {
|
|
69082
|
-
kind:
|
|
69457
|
+
kind: graphql11.Kind.NAME,
|
|
69083
69458
|
value: config4.listDeleteDirective(typeName)
|
|
69084
69459
|
},
|
|
69085
69460
|
locations: [
|
|
69086
69461
|
{
|
|
69087
|
-
kind:
|
|
69462
|
+
kind: graphql11.Kind.NAME,
|
|
69088
69463
|
value: "FIELD"
|
|
69089
69464
|
}
|
|
69090
69465
|
],
|
|
@@ -69092,8 +69467,8 @@ async function addListFragments(config4, documents) {
|
|
|
69092
69467
|
}))
|
|
69093
69468
|
)
|
|
69094
69469
|
};
|
|
69095
|
-
config4.newSchema += "\n" + generatedDoc.definitions.filter((c) => c.kind !== "FragmentDefinition").map(
|
|
69096
|
-
config4.newDocuments += "\n" + generatedDoc.definitions.filter((c) => c.kind === "FragmentDefinition").map(
|
|
69470
|
+
config4.newSchema += "\n" + generatedDoc.definitions.filter((c) => c.kind !== "FragmentDefinition").map(graphql11.print).join("\n\n");
|
|
69471
|
+
config4.newDocuments += "\n" + generatedDoc.definitions.filter((c) => c.kind === "FragmentDefinition").map(graphql11.print).join("\n\n");
|
|
69097
69472
|
documents.push({
|
|
69098
69473
|
name: "generated::lists",
|
|
69099
69474
|
kind: "HoudiniFragment" /* Fragment */,
|
|
@@ -69178,11 +69553,11 @@ var nodeNotDefinedMessage = (config4) => `Looks like you are trying to use the $
|
|
|
69178
69553
|
For more information, visit this link: ${siteURL}/guides/pagination`;
|
|
69179
69554
|
|
|
69180
69555
|
// src/codegen/generators/artifacts/fieldKey.ts
|
|
69181
|
-
var
|
|
69556
|
+
var graphql12 = __toESM(require_graphql2(), 1);
|
|
69182
69557
|
function fieldKey(config4, field) {
|
|
69183
69558
|
const attributeName = field.alias?.value || field.name.value;
|
|
69184
|
-
const printed =
|
|
69185
|
-
const secondParse =
|
|
69559
|
+
const printed = graphql12.print(field);
|
|
69560
|
+
const secondParse = graphql12.parse(`{${printed}}`).definitions[0].selectionSet.selections[0];
|
|
69186
69561
|
const paginated = !!field.directives?.find(
|
|
69187
69562
|
(directive) => directive.name.value === config4.paginateDirective
|
|
69188
69563
|
);
|
|
@@ -69277,8 +69652,8 @@ function selection({
|
|
|
69277
69652
|
const typeConditionName = field.typeCondition.name.value;
|
|
69278
69653
|
const typeCondition = config4.schema.getType(typeConditionName);
|
|
69279
69654
|
const possibleTypes = [];
|
|
69280
|
-
if (!
|
|
69281
|
-
} else if (
|
|
69655
|
+
if (!graphql13.isAbstractType(typeCondition)) {
|
|
69656
|
+
} else if (graphql13.isAbstractType(parentType)) {
|
|
69282
69657
|
const possibleParentTypes = config4.schema.getPossibleTypes(parentType).map((type) => type.name);
|
|
69283
69658
|
for (const possible of config4.schema.getPossibleTypes(typeCondition)) {
|
|
69284
69659
|
if (possibleParentTypes.includes(possible.name)) {
|
|
@@ -69326,7 +69701,7 @@ function selection({
|
|
|
69326
69701
|
} else {
|
|
69327
69702
|
let typeRef = type.getFields()[field.name.value].type;
|
|
69328
69703
|
fieldType = getRootType(typeRef);
|
|
69329
|
-
nullable = !
|
|
69704
|
+
nullable = !graphql13.isNonNullType(typeRef);
|
|
69330
69705
|
}
|
|
69331
69706
|
const typeName = fieldType.toString();
|
|
69332
69707
|
const pathSoFar = path2.concat(attributeName);
|
|
@@ -69391,7 +69766,7 @@ function selection({
|
|
|
69391
69766
|
{}
|
|
69392
69767
|
);
|
|
69393
69768
|
}
|
|
69394
|
-
if (
|
|
69769
|
+
if (graphql13.isInterfaceType(fieldType) || graphql13.isUnionType(fieldType)) {
|
|
69395
69770
|
fieldObj.abstract = true;
|
|
69396
69771
|
}
|
|
69397
69772
|
object.fields = {
|
|
@@ -69448,7 +69823,7 @@ function artifactGenerator(stats) {
|
|
|
69448
69823
|
return async function(config4, docs) {
|
|
69449
69824
|
const filterTypes = {};
|
|
69450
69825
|
for (const doc of docs) {
|
|
69451
|
-
|
|
69826
|
+
graphql14.visit(doc.document, {
|
|
69452
69827
|
Directive(node, _, __, ___, ancestors) {
|
|
69453
69828
|
if (node.name.value !== config4.listDirective) {
|
|
69454
69829
|
return;
|
|
@@ -69507,7 +69882,7 @@ function artifactGenerator(stats) {
|
|
|
69507
69882
|
return;
|
|
69508
69883
|
}
|
|
69509
69884
|
const usedVariableNames = /* @__PURE__ */ new Set();
|
|
69510
|
-
let documentWithoutInternalDirectives =
|
|
69885
|
+
let documentWithoutInternalDirectives = graphql14.visit(document, {
|
|
69511
69886
|
Directive(node) {
|
|
69512
69887
|
if (config4.isInternalDirective(node)) {
|
|
69513
69888
|
return null;
|
|
@@ -69520,7 +69895,7 @@ function artifactGenerator(stats) {
|
|
|
69520
69895
|
}
|
|
69521
69896
|
}
|
|
69522
69897
|
});
|
|
69523
|
-
let documentWithoutExtraVariables =
|
|
69898
|
+
let documentWithoutExtraVariables = graphql14.visit(
|
|
69524
69899
|
documentWithoutInternalDirectives,
|
|
69525
69900
|
{
|
|
69526
69901
|
VariableDefinition(variableDefinitionNode) {
|
|
@@ -69531,13 +69906,13 @@ function artifactGenerator(stats) {
|
|
|
69531
69906
|
}
|
|
69532
69907
|
}
|
|
69533
69908
|
);
|
|
69534
|
-
let rawString =
|
|
69909
|
+
let rawString = graphql14.print(documentWithoutExtraVariables);
|
|
69535
69910
|
let docKind = doc.kind;
|
|
69536
69911
|
const operations = document.definitions.filter(
|
|
69537
|
-
({ kind }) => kind ===
|
|
69912
|
+
({ kind }) => kind === graphql14.Kind.OPERATION_DEFINITION
|
|
69538
69913
|
);
|
|
69539
69914
|
const fragments = document.definitions.filter(
|
|
69540
|
-
({ kind }) => kind ===
|
|
69915
|
+
({ kind }) => kind === graphql14.Kind.FRAGMENT_DEFINITION
|
|
69541
69916
|
);
|
|
69542
69917
|
let rootType = "";
|
|
69543
69918
|
let selectionSet;
|
|
@@ -69570,7 +69945,13 @@ function artifactGenerator(stats) {
|
|
|
69570
69945
|
rootType = matchingFragment.typeCondition.name.value;
|
|
69571
69946
|
selectionSet = matchingFragment.selectionSet;
|
|
69572
69947
|
}
|
|
69573
|
-
|
|
69948
|
+
let inputs = operations[0]?.variableDefinitions;
|
|
69949
|
+
let directive = fragments[0]?.directives?.find(
|
|
69950
|
+
(directive2) => directive2.name.value === config4.argumentsDirective
|
|
69951
|
+
);
|
|
69952
|
+
if (docKind === "HoudiniFragment" /* Fragment */ && directive) {
|
|
69953
|
+
inputs = fragmentArgumentsDefinitions(config4, doc.filename, fragments[0]);
|
|
69954
|
+
}
|
|
69574
69955
|
const mergedSelection = flattenSelections({
|
|
69575
69956
|
config: config4,
|
|
69576
69957
|
filepath: doc.filename,
|
|
@@ -69631,7 +70012,7 @@ function artifactGenerator(stats) {
|
|
|
69631
70012
|
}
|
|
69632
70013
|
if (docKind === "HoudiniQuery") {
|
|
69633
70014
|
const cacheDirective = operations[0].directives?.find(
|
|
69634
|
-
(
|
|
70015
|
+
(directive2) => directive2.name.value === config4.cacheDirective
|
|
69635
70016
|
);
|
|
69636
70017
|
if (cacheDirective) {
|
|
69637
70018
|
const args = cacheDirective.arguments?.reduce(
|
|
@@ -69847,19 +70228,19 @@ async function generatePluginRuntime(config4, plugin) {
|
|
|
69847
70228
|
);
|
|
69848
70229
|
}
|
|
69849
70230
|
|
|
69850
|
-
// src/codegen/generators/typescript/
|
|
69851
|
-
var
|
|
70231
|
+
// src/codegen/generators/typescript/documentTypes.ts
|
|
70232
|
+
var recast11 = __toESM(require_main2(), 1);
|
|
69852
70233
|
|
|
69853
70234
|
// src/codegen/generators/typescript/addReferencedInputTypes.ts
|
|
69854
|
-
var
|
|
70235
|
+
var graphql17 = __toESM(require_graphql2(), 1);
|
|
69855
70236
|
var recast9 = __toESM(require_main2(), 1);
|
|
69856
70237
|
|
|
69857
70238
|
// src/codegen/generators/typescript/typeReference.ts
|
|
69858
|
-
var
|
|
70239
|
+
var graphql16 = __toESM(require_graphql2(), 1);
|
|
69859
70240
|
var recast8 = __toESM(require_main2(), 1);
|
|
69860
70241
|
|
|
69861
70242
|
// src/codegen/generators/typescript/types.ts
|
|
69862
|
-
var
|
|
70243
|
+
var graphql15 = __toESM(require_graphql2(), 1);
|
|
69863
70244
|
var recast7 = __toESM(require_main2(), 1);
|
|
69864
70245
|
var AST7 = recast7.types.builders;
|
|
69865
70246
|
function readonlyProperty(prop, enable = true) {
|
|
@@ -69890,336 +70271,89 @@ function scalarPropertyValue(config4, missingScalars, target) {
|
|
|
69890
70271
|
return AST7.tsBooleanKeyword();
|
|
69891
70272
|
}
|
|
69892
70273
|
case "ID": {
|
|
69893
|
-
return AST7.tsStringKeyword();
|
|
69894
|
-
}
|
|
69895
|
-
default: {
|
|
69896
|
-
if (
|
|
69897
|
-
return scalarPropertyValue(
|
|
69898
|
-
config4,
|
|
69899
|
-
missingScalars,
|
|
69900
|
-
target.ofType
|
|
69901
|
-
);
|
|
69902
|
-
}
|
|
69903
|
-
if (config4.scalars?.[target.name]) {
|
|
69904
|
-
return AST7.tsTypeReference(AST7.identifier(config4.scalars?.[target.name].type));
|
|
69905
|
-
}
|
|
69906
|
-
missingScalars.add(target.name);
|
|
69907
|
-
return AST7.tsAnyKeyword();
|
|
69908
|
-
}
|
|
69909
|
-
}
|
|
69910
|
-
}
|
|
69911
|
-
|
|
69912
|
-
// src/codegen/generators/typescript/typeReference.ts
|
|
69913
|
-
var AST8 = recast8.types.builders;
|
|
69914
|
-
function tsTypeReference(config4, missingScalars, definition) {
|
|
69915
|
-
const { type, wrappers } = unwrapType(config4, definition.type);
|
|
69916
|
-
let result;
|
|
69917
|
-
if (graphql15.isScalarType(type)) {
|
|
69918
|
-
result = scalarPropertyValue(config4, missingScalars, type);
|
|
69919
|
-
} else {
|
|
69920
|
-
result = AST8.tsTypeReference(AST8.identifier(type.name));
|
|
69921
|
-
}
|
|
69922
|
-
for (const toWrap of wrappers) {
|
|
69923
|
-
if (toWrap === "NonNull" /* NonNull */) {
|
|
69924
|
-
continue;
|
|
69925
|
-
} else if (toWrap === "Nullable" /* Nullable */) {
|
|
69926
|
-
result = nullableField(result, true);
|
|
69927
|
-
} else if (toWrap === "List" /* List */) {
|
|
69928
|
-
result = AST8.tsArrayType(AST8.tsParenthesizedType(result));
|
|
69929
|
-
}
|
|
69930
|
-
}
|
|
69931
|
-
return result;
|
|
69932
|
-
}
|
|
69933
|
-
|
|
69934
|
-
// src/codegen/generators/typescript/addReferencedInputTypes.ts
|
|
69935
|
-
var AST9 = recast9.types.builders;
|
|
69936
|
-
function addReferencedInputTypes(config4, filepath, body, visitedTypes, missingScalars, rootType) {
|
|
69937
|
-
const { type } = unwrapType(config4, rootType);
|
|
69938
|
-
if (graphql16.isScalarType(type)) {
|
|
69939
|
-
return;
|
|
69940
|
-
}
|
|
69941
|
-
if (visitedTypes.has(type.name)) {
|
|
69942
|
-
return;
|
|
69943
|
-
}
|
|
69944
|
-
if (graphql16.isUnionType(type)) {
|
|
69945
|
-
throw new HoudiniError({ filepath, message: "Input Unions are not supported yet. Sorry!" });
|
|
69946
|
-
}
|
|
69947
|
-
visitedTypes.add(type.name);
|
|
69948
|
-
if (graphql16.isEnumType(type)) {
|
|
69949
|
-
ensureImports({
|
|
69950
|
-
config: config4,
|
|
69951
|
-
body,
|
|
69952
|
-
import: [type.name],
|
|
69953
|
-
sourceModule: "$houdini/graphql/enums",
|
|
69954
|
-
importKind: "type"
|
|
69955
|
-
});
|
|
69956
|
-
return;
|
|
69957
|
-
}
|
|
69958
|
-
const members = [];
|
|
69959
|
-
for (const field of Object.values(type.getFields())) {
|
|
69960
|
-
addReferencedInputTypes(config4, filepath, body, visitedTypes, missingScalars, field.type);
|
|
69961
|
-
members.push(
|
|
69962
|
-
AST9.tsPropertySignature(
|
|
69963
|
-
AST9.identifier(field.name),
|
|
69964
|
-
AST9.tsTypeAnnotation(tsTypeReference(config4, missingScalars, field)),
|
|
69965
|
-
graphql16.isNullableType(field.type)
|
|
69966
|
-
)
|
|
69967
|
-
);
|
|
69968
|
-
}
|
|
69969
|
-
body.push(AST9.tsTypeAliasDeclaration(AST9.identifier(type.name), AST9.tsTypeLiteral(members)));
|
|
69970
|
-
}
|
|
69971
|
-
|
|
69972
|
-
// src/codegen/generators/typescript/imperativeCache.ts
|
|
69973
|
-
var graphql17 = __toESM(require_graphql2(), 1);
|
|
69974
|
-
var recast10 = __toESM(require_main2(), 1);
|
|
69975
|
-
var AST10 = recast10.types.builders;
|
|
69976
|
-
async function imperativeCacheTypef(config4, docs) {
|
|
69977
|
-
const target = path_exports.join(config4.runtimeDirectory, "generated.d.ts");
|
|
69978
|
-
const body = [];
|
|
69979
|
-
const declaration = AST10.tsTypeAliasDeclaration(
|
|
69980
|
-
AST10.identifier(CacheTypeDefName),
|
|
69981
|
-
AST10.tsTypeLiteral([
|
|
69982
|
-
AST10.tsPropertySignature(
|
|
69983
|
-
AST10.identifier("types"),
|
|
69984
|
-
AST10.tsTypeAnnotation(typeDefinitions(config4, body))
|
|
69985
|
-
),
|
|
69986
|
-
AST10.tsPropertySignature(
|
|
69987
|
-
AST10.identifier("lists"),
|
|
69988
|
-
AST10.tsTypeAnnotation(listDefinitions(config4, docs))
|
|
69989
|
-
)
|
|
69990
|
-
])
|
|
69991
|
-
);
|
|
69992
|
-
declaration.declare = true;
|
|
69993
|
-
const importRecord = AST10.importDeclaration(
|
|
69994
|
-
[AST10.importSpecifier(AST10.identifier("Record"))],
|
|
69995
|
-
AST10.stringLiteral("./public/record")
|
|
69996
|
-
);
|
|
69997
|
-
importRecord.importKind = "type";
|
|
69998
|
-
await fs_exports.writeFile(
|
|
69999
|
-
target,
|
|
70000
|
-
recast10.prettyPrint(
|
|
70001
|
-
AST10.program([importRecord, ...body, AST10.exportNamedDeclaration(declaration)])
|
|
70002
|
-
).code
|
|
70003
|
-
);
|
|
70004
|
-
}
|
|
70005
|
-
function typeDefinitions(config4, body) {
|
|
70006
|
-
const operationTypes = [config4.schema.getMutationType(), config4.schema.getSubscriptionType()].filter(Boolean).map((type) => type?.name);
|
|
70007
|
-
const visitedTypes = /* @__PURE__ */ new Set();
|
|
70008
|
-
const types17 = Object.values(config4.schema.getTypeMap()).filter(
|
|
70009
|
-
(type) => !graphql17.isAbstractType(type) && !graphql17.isScalarType(type) && !graphql17.isEnumType(type) && !graphql17.isInputObjectType(type) && !type.name.startsWith("__") && !operationTypes.includes(type.name)
|
|
70010
|
-
);
|
|
70011
|
-
return AST10.tsTypeLiteral(
|
|
70012
|
-
types17.map((type) => {
|
|
70013
|
-
let typeName = type.name;
|
|
70014
|
-
if (config4.schema.getQueryType() && config4.schema.getQueryType()?.name === type.name) {
|
|
70015
|
-
typeName = "__ROOT__";
|
|
70016
|
-
}
|
|
70017
|
-
let idFields = AST10.tsNeverKeyword();
|
|
70018
|
-
const keys = keyFieldsForType(config4.configFile, type.name);
|
|
70019
|
-
if (graphql17.isObjectType(type) && keys.length > 0 && keys.every((key) => type.getFields()[key])) {
|
|
70020
|
-
idFields = AST10.tsTypeLiteral(
|
|
70021
|
-
keys.map((key) => {
|
|
70022
|
-
const fieldType = type.getFields()[key];
|
|
70023
|
-
const unwrapped = unwrapType(config4, fieldType.type);
|
|
70024
|
-
return AST10.tsPropertySignature(
|
|
70025
|
-
AST10.identifier(key),
|
|
70026
|
-
AST10.tsTypeAnnotation(
|
|
70027
|
-
scalarPropertyValue(config4, /* @__PURE__ */ new Set(), unwrapped.type)
|
|
70028
|
-
)
|
|
70029
|
-
);
|
|
70030
|
-
})
|
|
70031
|
-
);
|
|
70032
|
-
} else if (typeName === "__ROOT__") {
|
|
70033
|
-
idFields = AST10.tsTypeLiteral([]);
|
|
70034
|
-
}
|
|
70035
|
-
let fields = AST10.tsTypeLiteral([]);
|
|
70036
|
-
if (graphql17.isObjectType(type)) {
|
|
70037
|
-
fields = AST10.tsTypeLiteral(
|
|
70038
|
-
Object.entries(type.getFields()).map(
|
|
70039
|
-
([key, fieldType]) => {
|
|
70040
|
-
const unwrapped = unwrapType(config4, fieldType.type);
|
|
70041
|
-
let typeOptions = AST10.tsUnionType([]);
|
|
70042
|
-
if (graphql17.isScalarType(unwrapped.type)) {
|
|
70043
|
-
typeOptions.types.push(
|
|
70044
|
-
scalarPropertyValue(config4, /* @__PURE__ */ new Set(), unwrapped.type)
|
|
70045
|
-
);
|
|
70046
|
-
} else if (graphql17.isEnumType(unwrapped.type)) {
|
|
70047
|
-
typeOptions.types.push(
|
|
70048
|
-
AST10.tsTypeReference(AST10.identifier(unwrapped.type.name))
|
|
70049
|
-
);
|
|
70050
|
-
} else if (!graphql17.isAbstractType(unwrapped.type)) {
|
|
70051
|
-
typeOptions.types.push(record(unwrapped.type.name));
|
|
70052
|
-
} else {
|
|
70053
|
-
typeOptions.types.push(
|
|
70054
|
-
...config4.schema.getPossibleTypes(unwrapped.type).map((type2) => record(type2.name))
|
|
70055
|
-
);
|
|
70056
|
-
}
|
|
70057
|
-
for (const wrapper of unwrapped.wrappers) {
|
|
70058
|
-
if (wrapper === "Nullable" /* Nullable */) {
|
|
70059
|
-
typeOptions = AST10.tsParenthesizedType(
|
|
70060
|
-
AST10.tsUnionType([typeOptions, AST10.tsNullKeyword()])
|
|
70061
|
-
);
|
|
70062
|
-
} else if (wrapper === "List" /* List */) {
|
|
70063
|
-
typeOptions = AST10.tsArrayType(
|
|
70064
|
-
AST10.tsParenthesizedType(typeOptions)
|
|
70065
|
-
);
|
|
70066
|
-
}
|
|
70067
|
-
}
|
|
70068
|
-
if (typeOptions.type === "TSParenthesizedType") {
|
|
70069
|
-
typeOptions = typeOptions.typeAnnotation;
|
|
70070
|
-
}
|
|
70071
|
-
let args = AST10.tsNeverKeyword();
|
|
70072
|
-
if (fieldType.args?.length > 0) {
|
|
70073
|
-
args = AST10.tsTypeLiteral(
|
|
70074
|
-
fieldType.args.map((arg) => {
|
|
70075
|
-
addReferencedInputTypes(
|
|
70076
|
-
config4,
|
|
70077
|
-
"",
|
|
70078
|
-
body,
|
|
70079
|
-
visitedTypes,
|
|
70080
|
-
/* @__PURE__ */ new Set(),
|
|
70081
|
-
arg.type
|
|
70082
|
-
);
|
|
70083
|
-
const prop = AST10.tsPropertySignature(
|
|
70084
|
-
AST10.identifier(arg.name),
|
|
70085
|
-
AST10.tsTypeAnnotation(
|
|
70086
|
-
tsTypeReference(config4, /* @__PURE__ */ new Set(), arg)
|
|
70087
|
-
)
|
|
70088
|
-
);
|
|
70089
|
-
const unwrapped2 = unwrapType(config4, arg.type);
|
|
70090
|
-
prop.optional = unwrapped2.wrappers[unwrapped2.wrappers.length - 1] === "Nullable" /* Nullable */;
|
|
70091
|
-
return prop;
|
|
70092
|
-
})
|
|
70093
|
-
);
|
|
70094
|
-
}
|
|
70095
|
-
return AST10.tsPropertySignature(
|
|
70096
|
-
AST10.identifier(key),
|
|
70097
|
-
AST10.tsTypeAnnotation(
|
|
70098
|
-
AST10.tsTypeLiteral([
|
|
70099
|
-
AST10.tsPropertySignature(
|
|
70100
|
-
AST10.identifier("type"),
|
|
70101
|
-
AST10.tsTypeAnnotation(typeOptions)
|
|
70102
|
-
),
|
|
70103
|
-
AST10.tsPropertySignature(
|
|
70104
|
-
AST10.identifier("args"),
|
|
70105
|
-
AST10.tsTypeAnnotation(args)
|
|
70106
|
-
)
|
|
70107
|
-
])
|
|
70108
|
-
)
|
|
70109
|
-
);
|
|
70110
|
-
}
|
|
70111
|
-
)
|
|
70274
|
+
return AST7.tsStringKeyword();
|
|
70275
|
+
}
|
|
70276
|
+
default: {
|
|
70277
|
+
if (graphql15.isNonNullType(target) && "ofType" in target) {
|
|
70278
|
+
return scalarPropertyValue(
|
|
70279
|
+
config4,
|
|
70280
|
+
missingScalars,
|
|
70281
|
+
target.ofType
|
|
70112
70282
|
);
|
|
70113
70283
|
}
|
|
70114
|
-
|
|
70115
|
-
|
|
70116
|
-
AST10.tsTypeAnnotation(
|
|
70117
|
-
AST10.tsTypeLiteral([
|
|
70118
|
-
AST10.tsPropertySignature(
|
|
70119
|
-
AST10.identifier("idFields"),
|
|
70120
|
-
AST10.tsTypeAnnotation(idFields)
|
|
70121
|
-
),
|
|
70122
|
-
AST10.tsPropertySignature(
|
|
70123
|
-
AST10.identifier("fields"),
|
|
70124
|
-
AST10.tsTypeAnnotation(fields)
|
|
70125
|
-
)
|
|
70126
|
-
])
|
|
70127
|
-
)
|
|
70128
|
-
);
|
|
70129
|
-
})
|
|
70130
|
-
);
|
|
70131
|
-
}
|
|
70132
|
-
function listDefinitions(config4, docs) {
|
|
70133
|
-
const lists = [];
|
|
70134
|
-
const visitedLists = /* @__PURE__ */ new Set();
|
|
70135
|
-
for (const doc of docs) {
|
|
70136
|
-
graphql17.visit(doc.document, {
|
|
70137
|
-
Directive(node, key, parent, path2, ancestors) {
|
|
70138
|
-
if (![config4.listDirective, config4.paginateDirective].includes(node.name.value)) {
|
|
70139
|
-
return;
|
|
70140
|
-
}
|
|
70141
|
-
const nameArg = node.arguments?.find((arg) => arg.name.value === "name");
|
|
70142
|
-
const nameValue = nameArg?.value?.value || "";
|
|
70143
|
-
if (!nameValue || visitedLists.has(nameValue)) {
|
|
70144
|
-
return;
|
|
70145
|
-
}
|
|
70146
|
-
visitedLists.add(nameValue);
|
|
70147
|
-
const parentType = parentTypeFromAncestors(
|
|
70148
|
-
config4.schema,
|
|
70149
|
-
doc.filename,
|
|
70150
|
-
ancestors.slice(0, -1)
|
|
70151
|
-
);
|
|
70152
|
-
const targetField = ancestors[ancestors.length - 1];
|
|
70153
|
-
const targetFieldDefinition = parentType.getFields()[targetField.name.value];
|
|
70154
|
-
const { type: listType } = unwrapType(config4, targetFieldDefinition.type);
|
|
70155
|
-
const possibleTypes = [];
|
|
70156
|
-
if (graphql17.isAbstractType(listType)) {
|
|
70157
|
-
possibleTypes.push(
|
|
70158
|
-
...config4.schema.getPossibleTypes(listType).map((possible) => possible.name)
|
|
70159
|
-
);
|
|
70160
|
-
} else {
|
|
70161
|
-
possibleTypes.push(listType.name);
|
|
70162
|
-
}
|
|
70163
|
-
lists.push(
|
|
70164
|
-
AST10.tsPropertySignature(
|
|
70165
|
-
AST10.identifier(nameValue),
|
|
70166
|
-
AST10.tsTypeAnnotation(
|
|
70167
|
-
AST10.tsTypeLiteral([
|
|
70168
|
-
AST10.tsPropertySignature(
|
|
70169
|
-
AST10.identifier("types"),
|
|
70170
|
-
AST10.tsTypeAnnotation(
|
|
70171
|
-
AST10.tsUnionType(
|
|
70172
|
-
possibleTypes.map(
|
|
70173
|
-
(possible) => AST10.tsLiteralType(AST10.stringLiteral(possible))
|
|
70174
|
-
)
|
|
70175
|
-
)
|
|
70176
|
-
)
|
|
70177
|
-
),
|
|
70178
|
-
AST10.tsPropertySignature(
|
|
70179
|
-
AST10.identifier("filters"),
|
|
70180
|
-
AST10.tsTypeAnnotation(
|
|
70181
|
-
targetFieldDefinition.args.length === 0 ? AST10.tsNeverKeyword() : AST10.tsTypeLiteral(
|
|
70182
|
-
targetFieldDefinition.args.map((arg) => {
|
|
70183
|
-
const argDef = AST10.tsPropertySignature(
|
|
70184
|
-
AST10.identifier(arg.name),
|
|
70185
|
-
AST10.tsTypeAnnotation(
|
|
70186
|
-
tsTypeReference(
|
|
70187
|
-
config4,
|
|
70188
|
-
/* @__PURE__ */ new Set(),
|
|
70189
|
-
arg
|
|
70190
|
-
)
|
|
70191
|
-
)
|
|
70192
|
-
);
|
|
70193
|
-
argDef.optional = true;
|
|
70194
|
-
return argDef;
|
|
70195
|
-
})
|
|
70196
|
-
)
|
|
70197
|
-
)
|
|
70198
|
-
)
|
|
70199
|
-
])
|
|
70200
|
-
)
|
|
70201
|
-
)
|
|
70202
|
-
);
|
|
70284
|
+
if (config4.scalars?.[target.name]) {
|
|
70285
|
+
return AST7.tsTypeReference(AST7.identifier(config4.scalars?.[target.name].type));
|
|
70203
70286
|
}
|
|
70204
|
-
|
|
70287
|
+
missingScalars.add(target.name);
|
|
70288
|
+
return AST7.tsAnyKeyword();
|
|
70289
|
+
}
|
|
70205
70290
|
}
|
|
70206
|
-
return AST10.tsTypeLiteral(lists);
|
|
70207
70291
|
}
|
|
70208
|
-
|
|
70209
|
-
|
|
70210
|
-
|
|
70211
|
-
|
|
70212
|
-
|
|
70213
|
-
|
|
70214
|
-
|
|
70215
|
-
|
|
70216
|
-
|
|
70292
|
+
|
|
70293
|
+
// src/codegen/generators/typescript/typeReference.ts
|
|
70294
|
+
var AST8 = recast8.types.builders;
|
|
70295
|
+
function tsTypeReference(config4, missingScalars, definition) {
|
|
70296
|
+
const { type, wrappers } = unwrapType(config4, definition.type);
|
|
70297
|
+
let result;
|
|
70298
|
+
if (graphql16.isScalarType(type)) {
|
|
70299
|
+
result = scalarPropertyValue(config4, missingScalars, type);
|
|
70300
|
+
} else {
|
|
70301
|
+
result = AST8.tsTypeReference(AST8.identifier(type.name));
|
|
70302
|
+
}
|
|
70303
|
+
for (const toWrap of wrappers) {
|
|
70304
|
+
if (toWrap === "NonNull" /* NonNull */) {
|
|
70305
|
+
continue;
|
|
70306
|
+
} else if (toWrap === "Nullable" /* Nullable */) {
|
|
70307
|
+
result = nullableField(result, true);
|
|
70308
|
+
} else if (toWrap === "List" /* List */) {
|
|
70309
|
+
result = AST8.tsArrayType(AST8.tsParenthesizedType(result));
|
|
70310
|
+
}
|
|
70311
|
+
}
|
|
70312
|
+
return result;
|
|
70313
|
+
}
|
|
70314
|
+
|
|
70315
|
+
// src/codegen/generators/typescript/addReferencedInputTypes.ts
|
|
70316
|
+
var AST9 = recast9.types.builders;
|
|
70317
|
+
function addReferencedInputTypes(config4, filepath, body, visitedTypes, missingScalars, rootType) {
|
|
70318
|
+
const { type } = unwrapType(config4, rootType);
|
|
70319
|
+
if (graphql17.isScalarType(type)) {
|
|
70320
|
+
return;
|
|
70321
|
+
}
|
|
70322
|
+
if (visitedTypes.has(type.name)) {
|
|
70323
|
+
return;
|
|
70324
|
+
}
|
|
70325
|
+
if (graphql17.isUnionType(type)) {
|
|
70326
|
+
throw new HoudiniError({ filepath, message: "Input Unions are not supported yet. Sorry!" });
|
|
70327
|
+
}
|
|
70328
|
+
visitedTypes.add(type.name);
|
|
70329
|
+
if (graphql17.isEnumType(type)) {
|
|
70330
|
+
ensureImports({
|
|
70331
|
+
config: config4,
|
|
70332
|
+
body,
|
|
70333
|
+
import: [type.name],
|
|
70334
|
+
sourceModule: "$houdini/graphql/enums",
|
|
70335
|
+
importKind: "type"
|
|
70336
|
+
});
|
|
70337
|
+
return;
|
|
70338
|
+
}
|
|
70339
|
+
const members = [];
|
|
70340
|
+
for (const field of Object.values(type.getFields())) {
|
|
70341
|
+
addReferencedInputTypes(config4, filepath, body, visitedTypes, missingScalars, field.type);
|
|
70342
|
+
members.push(
|
|
70343
|
+
AST9.tsPropertySignature(
|
|
70344
|
+
AST9.identifier(field.name),
|
|
70345
|
+
AST9.tsTypeAnnotation(tsTypeReference(config4, missingScalars, field)),
|
|
70346
|
+
graphql17.isNullableType(field.type)
|
|
70347
|
+
)
|
|
70348
|
+
);
|
|
70349
|
+
}
|
|
70350
|
+
body.push(AST9.tsTypeAliasDeclaration(AST9.identifier(type.name), AST9.tsTypeLiteral(members)));
|
|
70217
70351
|
}
|
|
70218
70352
|
|
|
70219
70353
|
// src/codegen/generators/typescript/inlineType.ts
|
|
70220
70354
|
var graphql18 = __toESM(require_graphql2(), 1);
|
|
70221
|
-
var
|
|
70222
|
-
var
|
|
70355
|
+
var recast10 = __toESM(require_main2(), 1);
|
|
70356
|
+
var AST10 = recast10.types.builders;
|
|
70223
70357
|
var fragmentKey = "$fragments";
|
|
70224
70358
|
function inlineType({
|
|
70225
70359
|
config: config4,
|
|
@@ -70248,7 +70382,7 @@ function inlineType({
|
|
|
70248
70382
|
});
|
|
70249
70383
|
visitedTypes.add(type.name);
|
|
70250
70384
|
}
|
|
70251
|
-
result =
|
|
70385
|
+
result = AST10.tsTypeReference(AST10.identifier(type.name));
|
|
70252
70386
|
} else if (selections) {
|
|
70253
70387
|
const rootObj = type;
|
|
70254
70388
|
const inlineFragments = {};
|
|
@@ -70299,7 +70433,7 @@ function inlineType({
|
|
|
70299
70433
|
selectedFields.push(selection2);
|
|
70300
70434
|
}
|
|
70301
70435
|
}
|
|
70302
|
-
result =
|
|
70436
|
+
result = AST10.tsTypeLiteral([
|
|
70303
70437
|
...(selectedFields || []).filter(
|
|
70304
70438
|
(field) => field.kind === "Field"
|
|
70305
70439
|
).map((selection2) => {
|
|
@@ -70319,9 +70453,9 @@ function inlineType({
|
|
|
70319
70453
|
allOptional
|
|
70320
70454
|
});
|
|
70321
70455
|
const prop = readonlyProperty(
|
|
70322
|
-
|
|
70323
|
-
|
|
70324
|
-
|
|
70456
|
+
AST10.tsPropertySignature(
|
|
70457
|
+
AST10.identifier(attributeName),
|
|
70458
|
+
AST10.tsTypeAnnotation(attributeType)
|
|
70325
70459
|
),
|
|
70326
70460
|
allowReadonly
|
|
70327
70461
|
);
|
|
@@ -70335,15 +70469,15 @@ function inlineType({
|
|
|
70335
70469
|
if (includeFragments && fragmentSpreads && fragmentSpreads.length) {
|
|
70336
70470
|
result.members.push(
|
|
70337
70471
|
readonlyProperty(
|
|
70338
|
-
|
|
70339
|
-
|
|
70340
|
-
|
|
70341
|
-
|
|
70472
|
+
AST10.tsPropertySignature(
|
|
70473
|
+
AST10.identifier(fragmentKey),
|
|
70474
|
+
AST10.tsTypeAnnotation(
|
|
70475
|
+
AST10.tsTypeLiteral(
|
|
70342
70476
|
(fragmentSpreads || []).map(
|
|
70343
|
-
(fragmentSpread) =>
|
|
70344
|
-
|
|
70345
|
-
|
|
70346
|
-
|
|
70477
|
+
(fragmentSpread) => AST10.tsPropertySignature(
|
|
70478
|
+
AST10.identifier(fragmentSpread.name.value),
|
|
70479
|
+
AST10.tsTypeAnnotation(
|
|
70480
|
+
AST10.tsLiteralType(AST10.booleanLiteral(true))
|
|
70347
70481
|
)
|
|
70348
70482
|
)
|
|
70349
70483
|
)
|
|
@@ -70389,9 +70523,9 @@ function inlineType({
|
|
|
70389
70523
|
}
|
|
70390
70524
|
objectType.members.push(
|
|
70391
70525
|
readonlyProperty(
|
|
70392
|
-
|
|
70393
|
-
|
|
70394
|
-
|
|
70526
|
+
AST10.tsPropertySignature(
|
|
70527
|
+
AST10.identifier("__typename"),
|
|
70528
|
+
AST10.tsTypeAnnotation(AST10.tsLiteralType(AST10.stringLiteral(typeName)))
|
|
70395
70529
|
),
|
|
70396
70530
|
allowReadonly
|
|
70397
70531
|
)
|
|
@@ -70402,8 +70536,8 @@ function inlineType({
|
|
|
70402
70536
|
if (Object.keys(inlineFragmentSelections).length > 0) {
|
|
70403
70537
|
let selectionTypes = Object.entries(inlineFragmentSelections).map(
|
|
70404
70538
|
([typeName, { type: type2, tsType }]) => {
|
|
70405
|
-
return
|
|
70406
|
-
|
|
70539
|
+
return AST10.tsParenthesizedType(
|
|
70540
|
+
AST10.tsIntersectionType(
|
|
70407
70541
|
[tsType].flatMap((type3) => {
|
|
70408
70542
|
if (type3.type === "TSUnionType") {
|
|
70409
70543
|
return type3.types.filter(
|
|
@@ -70416,9 +70550,9 @@ function inlineType({
|
|
|
70416
70550
|
);
|
|
70417
70551
|
}
|
|
70418
70552
|
);
|
|
70419
|
-
result =
|
|
70553
|
+
result = AST10.tsIntersectionType([
|
|
70420
70554
|
result,
|
|
70421
|
-
|
|
70555
|
+
AST10.tsParenthesizedType(AST10.tsUnionType(selectionTypes))
|
|
70422
70556
|
]);
|
|
70423
70557
|
}
|
|
70424
70558
|
} else {
|
|
@@ -70430,7 +70564,7 @@ function inlineType({
|
|
|
70430
70564
|
} else if (toWrap === "NonNull" /* NonNull */) {
|
|
70431
70565
|
continue;
|
|
70432
70566
|
} else if (toWrap === "List" /* List */) {
|
|
70433
|
-
result =
|
|
70567
|
+
result = AST10.tsArrayType(AST10.tsParenthesizedType(result));
|
|
70434
70568
|
}
|
|
70435
70569
|
}
|
|
70436
70570
|
return result;
|
|
@@ -70474,9 +70608,9 @@ function selectionTypeInfo(schema, filepath, rootType, selection2) {
|
|
|
70474
70608
|
return { field, type: selectionType };
|
|
70475
70609
|
}
|
|
70476
70610
|
|
|
70477
|
-
// src/codegen/generators/typescript/
|
|
70478
|
-
var
|
|
70479
|
-
async function
|
|
70611
|
+
// src/codegen/generators/typescript/documentTypes.ts
|
|
70612
|
+
var AST11 = recast11.types.builders;
|
|
70613
|
+
async function generateDocumentTypes(config4, docs) {
|
|
70480
70614
|
const typePaths = [];
|
|
70481
70615
|
const fragmentDefinitions = {};
|
|
70482
70616
|
for (const document of docs) {
|
|
@@ -70493,7 +70627,7 @@ async function typescriptGenerator(config4, docs) {
|
|
|
70493
70627
|
return;
|
|
70494
70628
|
}
|
|
70495
70629
|
const typeDefPath = config4.artifactTypePath(originalDocument);
|
|
70496
|
-
const program =
|
|
70630
|
+
const program = AST11.program([]);
|
|
70497
70631
|
const visitedTypes = /* @__PURE__ */ new Set();
|
|
70498
70632
|
let definition = originalDocument.definitions.find(
|
|
70499
70633
|
(def) => (def.kind === "OperationDefinition" || def.kind === "FragmentDefinition") && def.name?.value === name2
|
|
@@ -70526,21 +70660,21 @@ async function typescriptGenerator(config4, docs) {
|
|
|
70526
70660
|
missingScalars
|
|
70527
70661
|
);
|
|
70528
70662
|
}
|
|
70529
|
-
await fs_exports.writeFile(typeDefPath,
|
|
70663
|
+
await fs_exports.writeFile(typeDefPath, recast11.print(program).code);
|
|
70530
70664
|
typePaths.push(typeDefPath);
|
|
70531
70665
|
})
|
|
70532
70666
|
);
|
|
70533
|
-
const typeIndex =
|
|
70667
|
+
const typeIndex = AST11.program(
|
|
70534
70668
|
typePaths.sort((a, b) => a.localeCompare(b)).map((typePath) => {
|
|
70535
|
-
return
|
|
70536
|
-
|
|
70669
|
+
return AST11.exportAllDeclaration(
|
|
70670
|
+
AST11.literal(
|
|
70537
70671
|
"./" + path_exports.relative(path_exports.resolve(config4.typeIndexPath, ".."), typePath).replace(/\.[^/.]+\.[^/.]+$/, "")
|
|
70538
70672
|
),
|
|
70539
70673
|
null
|
|
70540
70674
|
);
|
|
70541
70675
|
}).concat([
|
|
70542
|
-
|
|
70543
|
-
|
|
70676
|
+
AST11.exportAllDeclaration(AST11.literal("./runtime"), null),
|
|
70677
|
+
AST11.exportAllDeclaration(AST11.literal("./graphql"), null)
|
|
70544
70678
|
])
|
|
70545
70679
|
);
|
|
70546
70680
|
const export_default_as = ({ module, as }) => `
|
|
@@ -70549,7 +70683,7 @@ export { default as ${as} } from "${module}"
|
|
|
70549
70683
|
const export_star_from = ({ module }) => `
|
|
70550
70684
|
export * from "${module}"
|
|
70551
70685
|
`;
|
|
70552
|
-
let indexContent =
|
|
70686
|
+
let indexContent = recast11.print(typeIndex).code;
|
|
70553
70687
|
for (const plugin of config4.plugins) {
|
|
70554
70688
|
if (!plugin.index_file) {
|
|
70555
70689
|
continue;
|
|
@@ -70570,7 +70704,6 @@ export * from "${module}"
|
|
|
70570
70704
|
}
|
|
70571
70705
|
}
|
|
70572
70706
|
await fs_exports.writeFile(config4.typeIndexPath, indexContent);
|
|
70573
|
-
await imperativeCacheTypef(config4, docs);
|
|
70574
70707
|
if (missingScalars.size > 0) {
|
|
70575
70708
|
console.warn(`\u26A0\uFE0F Missing definitions for the following scalars: ${[...missingScalars].join(
|
|
70576
70709
|
", "
|
|
@@ -70612,23 +70745,23 @@ async function generateOperationTypeDefs(config4, filepath, body, definition, se
|
|
|
70612
70745
|
const optimisticTypeName = `${definition.name.value}$optimistic`;
|
|
70613
70746
|
const hasInputs = definition.variableDefinitions && definition.variableDefinitions.length > 0;
|
|
70614
70747
|
body.push(
|
|
70615
|
-
|
|
70616
|
-
|
|
70617
|
-
|
|
70618
|
-
|
|
70748
|
+
AST11.exportNamedDeclaration(
|
|
70749
|
+
AST11.tsTypeAliasDeclaration(
|
|
70750
|
+
AST11.identifier(definition.name.value),
|
|
70751
|
+
AST11.tsTypeLiteral([
|
|
70619
70752
|
readonlyProperty(
|
|
70620
|
-
|
|
70621
|
-
|
|
70622
|
-
|
|
70753
|
+
AST11.tsPropertySignature(
|
|
70754
|
+
AST11.stringLiteral("input"),
|
|
70755
|
+
AST11.tsTypeAnnotation(AST11.tsTypeReference(AST11.identifier(inputTypeName)))
|
|
70623
70756
|
)
|
|
70624
70757
|
),
|
|
70625
70758
|
readonlyProperty(
|
|
70626
|
-
|
|
70627
|
-
|
|
70628
|
-
|
|
70629
|
-
definition.operation === "mutation" ?
|
|
70630
|
-
|
|
70631
|
-
|
|
70759
|
+
AST11.tsPropertySignature(
|
|
70760
|
+
AST11.stringLiteral("result"),
|
|
70761
|
+
AST11.tsTypeAnnotation(
|
|
70762
|
+
definition.operation === "mutation" ? AST11.tsTypeReference(AST11.identifier(shapeTypeName)) : AST11.tsUnionType([
|
|
70763
|
+
AST11.tsTypeReference(AST11.identifier(shapeTypeName)),
|
|
70764
|
+
AST11.tsUndefinedKeyword()
|
|
70632
70765
|
])
|
|
70633
70766
|
)
|
|
70634
70767
|
)
|
|
@@ -70636,9 +70769,9 @@ async function generateOperationTypeDefs(config4, filepath, body, definition, se
|
|
|
70636
70769
|
])
|
|
70637
70770
|
)
|
|
70638
70771
|
),
|
|
70639
|
-
|
|
70640
|
-
|
|
70641
|
-
|
|
70772
|
+
AST11.exportNamedDeclaration(
|
|
70773
|
+
AST11.tsTypeAliasDeclaration(
|
|
70774
|
+
AST11.identifier(shapeTypeName),
|
|
70642
70775
|
inlineType({
|
|
70643
70776
|
config: config4,
|
|
70644
70777
|
filepath,
|
|
@@ -70666,15 +70799,15 @@ async function generateOperationTypeDefs(config4, filepath, body, definition, se
|
|
|
70666
70799
|
);
|
|
70667
70800
|
}
|
|
70668
70801
|
body.push(
|
|
70669
|
-
|
|
70670
|
-
|
|
70671
|
-
|
|
70672
|
-
|
|
70802
|
+
AST11.exportNamedDeclaration(
|
|
70803
|
+
AST11.tsTypeAliasDeclaration(
|
|
70804
|
+
AST11.identifier(inputTypeName),
|
|
70805
|
+
AST11.tsTypeLiteral(
|
|
70673
70806
|
(definition.variableDefinitions || []).map(
|
|
70674
70807
|
(definition2) => {
|
|
70675
|
-
return
|
|
70676
|
-
|
|
70677
|
-
|
|
70808
|
+
return AST11.tsPropertySignature(
|
|
70809
|
+
AST11.identifier(definition2.variable.name.value),
|
|
70810
|
+
AST11.tsTypeAnnotation(
|
|
70678
70811
|
tsTypeReference(config4, missingScalars, definition2)
|
|
70679
70812
|
),
|
|
70680
70813
|
definition2.type.kind !== "NonNullType"
|
|
@@ -70687,16 +70820,16 @@ async function generateOperationTypeDefs(config4, filepath, body, definition, se
|
|
|
70687
70820
|
);
|
|
70688
70821
|
} else {
|
|
70689
70822
|
body.push(
|
|
70690
|
-
|
|
70691
|
-
|
|
70823
|
+
AST11.exportNamedDeclaration(
|
|
70824
|
+
AST11.tsTypeAliasDeclaration(AST11.identifier(inputTypeName), AST11.tsNullKeyword())
|
|
70692
70825
|
)
|
|
70693
70826
|
);
|
|
70694
70827
|
}
|
|
70695
70828
|
if (definition.operation === "mutation") {
|
|
70696
70829
|
body.push(
|
|
70697
|
-
|
|
70698
|
-
|
|
70699
|
-
|
|
70830
|
+
AST11.exportNamedDeclaration(
|
|
70831
|
+
AST11.tsTypeAliasDeclaration(
|
|
70832
|
+
AST11.identifier(optimisticTypeName),
|
|
70700
70833
|
inlineType({
|
|
70701
70834
|
config: config4,
|
|
70702
70835
|
filepath,
|
|
@@ -70722,65 +70855,463 @@ async function generateFragmentTypeDefs(config4, filepath, body, selections, def
|
|
|
70722
70855
|
}
|
|
70723
70856
|
const propTypeName = definition.name.value;
|
|
70724
70857
|
const shapeTypeName = `${definition.name.value}$data`;
|
|
70858
|
+
const inputTypeName = `${definition.name.value}$input`;
|
|
70725
70859
|
const type = config4.schema.getType(definition.typeCondition.name.value);
|
|
70726
70860
|
if (!type) {
|
|
70727
70861
|
throw new Error("Should not get here");
|
|
70728
70862
|
}
|
|
70863
|
+
let extraExports = [];
|
|
70864
|
+
let directive = definition.directives?.find(
|
|
70865
|
+
(directive2) => directive2.name.value === config4.argumentsDirective
|
|
70866
|
+
);
|
|
70867
|
+
if (directive) {
|
|
70868
|
+
extraExports.push(
|
|
70869
|
+
AST11.exportNamedDeclaration(
|
|
70870
|
+
AST11.tsTypeAliasDeclaration(
|
|
70871
|
+
AST11.identifier(inputTypeName),
|
|
70872
|
+
AST11.tsTypeLiteral(
|
|
70873
|
+
(fragmentArgumentsDefinitions(config4, filepath, definition) || []).map(
|
|
70874
|
+
(definition2) => {
|
|
70875
|
+
return AST11.tsPropertySignature(
|
|
70876
|
+
AST11.identifier(definition2.variable.name.value),
|
|
70877
|
+
AST11.tsTypeAnnotation(
|
|
70878
|
+
tsTypeReference(config4, missingScalars, definition2)
|
|
70879
|
+
),
|
|
70880
|
+
definition2.type.kind !== "NonNullType"
|
|
70881
|
+
);
|
|
70882
|
+
}
|
|
70883
|
+
)
|
|
70884
|
+
)
|
|
70885
|
+
)
|
|
70886
|
+
)
|
|
70887
|
+
);
|
|
70888
|
+
}
|
|
70729
70889
|
body.push(
|
|
70730
|
-
|
|
70731
|
-
|
|
70732
|
-
|
|
70733
|
-
|
|
70890
|
+
...extraExports,
|
|
70891
|
+
AST11.exportNamedDeclaration(
|
|
70892
|
+
AST11.tsTypeAliasDeclaration(
|
|
70893
|
+
AST11.identifier(propTypeName),
|
|
70894
|
+
AST11.tsTypeLiteral([
|
|
70734
70895
|
readonlyProperty(
|
|
70735
|
-
|
|
70736
|
-
|
|
70737
|
-
|
|
70738
|
-
|
|
70896
|
+
AST11.tsPropertySignature(
|
|
70897
|
+
AST11.stringLiteral("shape"),
|
|
70898
|
+
AST11.tsTypeAnnotation(
|
|
70899
|
+
AST11.tsTypeReference(AST11.identifier(shapeTypeName))
|
|
70739
70900
|
),
|
|
70740
70901
|
true
|
|
70741
70902
|
)
|
|
70742
70903
|
),
|
|
70743
70904
|
readonlyProperty(
|
|
70744
|
-
|
|
70745
|
-
|
|
70905
|
+
AST11.tsPropertySignature(
|
|
70906
|
+
AST11.stringLiteral(fragmentKey),
|
|
70907
|
+
AST11.tsTypeAnnotation(
|
|
70908
|
+
AST11.tsTypeLiteral([
|
|
70909
|
+
AST11.tsPropertySignature(
|
|
70910
|
+
AST11.stringLiteral(propTypeName),
|
|
70911
|
+
AST11.tsTypeAnnotation(
|
|
70912
|
+
AST11.tsLiteralType(AST11.booleanLiteral(true))
|
|
70913
|
+
)
|
|
70914
|
+
)
|
|
70915
|
+
])
|
|
70916
|
+
)
|
|
70917
|
+
)
|
|
70918
|
+
)
|
|
70919
|
+
])
|
|
70920
|
+
)
|
|
70921
|
+
),
|
|
70922
|
+
AST11.exportNamedDeclaration(
|
|
70923
|
+
AST11.tsTypeAliasDeclaration(
|
|
70924
|
+
AST11.identifier(shapeTypeName),
|
|
70925
|
+
inlineType({
|
|
70926
|
+
config: config4,
|
|
70927
|
+
filepath,
|
|
70928
|
+
rootType: type,
|
|
70929
|
+
selections,
|
|
70930
|
+
root: true,
|
|
70931
|
+
allowReadonly: true,
|
|
70932
|
+
body,
|
|
70933
|
+
visitedTypes,
|
|
70934
|
+
missingScalars,
|
|
70935
|
+
includeFragments: true
|
|
70936
|
+
})
|
|
70937
|
+
)
|
|
70938
|
+
)
|
|
70939
|
+
);
|
|
70940
|
+
}
|
|
70941
|
+
}
|
|
70942
|
+
|
|
70943
|
+
// src/codegen/generators/typescript/imperativeTypeDef.ts
|
|
70944
|
+
var graphql19 = __toESM(require_graphql2(), 1);
|
|
70945
|
+
var recast12 = __toESM(require_main2(), 1);
|
|
70946
|
+
var AST12 = recast12.types.builders;
|
|
70947
|
+
async function imperativeCacheTypef(config4, docs) {
|
|
70948
|
+
const returnType = (doc) => config4.plugins.find((plugin) => plugin.graphql_tag_return)?.graphql_tag_return?.({
|
|
70949
|
+
config: config4,
|
|
70950
|
+
doc,
|
|
70951
|
+
ensure_import({ identifier, module }) {
|
|
70952
|
+
ensureImports({
|
|
70953
|
+
config: config4,
|
|
70954
|
+
body,
|
|
70955
|
+
sourceModule: module,
|
|
70956
|
+
import: [identifier]
|
|
70957
|
+
});
|
|
70958
|
+
}
|
|
70959
|
+
}) ?? "any";
|
|
70960
|
+
const target = path_exports.join(config4.runtimeDirectory, "generated.d.ts");
|
|
70961
|
+
const body = [];
|
|
70962
|
+
const declaration = AST12.tsTypeAliasDeclaration(
|
|
70963
|
+
AST12.identifier(CacheTypeDefName),
|
|
70964
|
+
AST12.tsTypeLiteral([
|
|
70965
|
+
AST12.tsPropertySignature(
|
|
70966
|
+
AST12.identifier("types"),
|
|
70967
|
+
AST12.tsTypeAnnotation(typeDefinitions(config4, body, docs, returnType))
|
|
70968
|
+
),
|
|
70969
|
+
AST12.tsPropertySignature(
|
|
70970
|
+
AST12.identifier("lists"),
|
|
70971
|
+
AST12.tsTypeAnnotation(listDefinitions(config4, docs))
|
|
70972
|
+
),
|
|
70973
|
+
AST12.tsPropertySignature(
|
|
70974
|
+
AST12.identifier("queries"),
|
|
70975
|
+
AST12.tsTypeAnnotation(queryDefinitions(config4, body, docs, returnType))
|
|
70976
|
+
)
|
|
70977
|
+
])
|
|
70978
|
+
);
|
|
70979
|
+
declaration.declare = true;
|
|
70980
|
+
const importRecord = AST12.importDeclaration(
|
|
70981
|
+
[AST12.importSpecifier(AST12.identifier("Record"))],
|
|
70982
|
+
AST12.stringLiteral("./public/record")
|
|
70983
|
+
);
|
|
70984
|
+
importRecord.importKind = "type";
|
|
70985
|
+
await fs_exports.writeFile(
|
|
70986
|
+
target,
|
|
70987
|
+
recast12.prettyPrint(
|
|
70988
|
+
AST12.program([importRecord, ...body, AST12.exportNamedDeclaration(declaration)])
|
|
70989
|
+
).code
|
|
70990
|
+
);
|
|
70991
|
+
}
|
|
70992
|
+
function typeDefinitions(config4, body, docs, returnType) {
|
|
70993
|
+
const operationTypes = [config4.schema.getMutationType(), config4.schema.getSubscriptionType()].filter(Boolean).map((type) => type?.name);
|
|
70994
|
+
const visitedTypes = /* @__PURE__ */ new Set();
|
|
70995
|
+
const types17 = Object.values(config4.schema.getTypeMap()).filter(
|
|
70996
|
+
(type) => !graphql19.isAbstractType(type) && !graphql19.isScalarType(type) && !graphql19.isEnumType(type) && !graphql19.isInputObjectType(type) && !type.name.startsWith("__") && !operationTypes.includes(type.name)
|
|
70997
|
+
);
|
|
70998
|
+
const fragmentMap = fragmentListMap(
|
|
70999
|
+
config4,
|
|
71000
|
+
types17.map((type) => type.name),
|
|
71001
|
+
body,
|
|
71002
|
+
docs,
|
|
71003
|
+
returnType
|
|
71004
|
+
);
|
|
71005
|
+
return AST12.tsTypeLiteral(
|
|
71006
|
+
types17.map((type) => {
|
|
71007
|
+
let typeName = type.name;
|
|
71008
|
+
if (config4.schema.getQueryType() && config4.schema.getQueryType()?.name === type.name) {
|
|
71009
|
+
typeName = "__ROOT__";
|
|
71010
|
+
}
|
|
71011
|
+
let idFields = AST12.tsNeverKeyword();
|
|
71012
|
+
const keys = keyFieldsForType(config4.configFile, type.name);
|
|
71013
|
+
if (graphql19.isObjectType(type) && keys.length > 0 && keys.every((key) => type.getFields()[key])) {
|
|
71014
|
+
idFields = AST12.tsTypeLiteral(
|
|
71015
|
+
keys.map((key) => {
|
|
71016
|
+
const fieldType = type.getFields()[key];
|
|
71017
|
+
const unwrapped = unwrapType(config4, fieldType.type);
|
|
71018
|
+
return AST12.tsPropertySignature(
|
|
71019
|
+
AST12.identifier(key),
|
|
71020
|
+
AST12.tsTypeAnnotation(
|
|
71021
|
+
scalarPropertyValue(config4, /* @__PURE__ */ new Set(), unwrapped.type)
|
|
71022
|
+
)
|
|
71023
|
+
);
|
|
71024
|
+
})
|
|
71025
|
+
);
|
|
71026
|
+
} else if (typeName === "__ROOT__") {
|
|
71027
|
+
idFields = AST12.tsTypeLiteral([]);
|
|
71028
|
+
}
|
|
71029
|
+
let fields = AST12.tsTypeLiteral([]);
|
|
71030
|
+
if (graphql19.isObjectType(type)) {
|
|
71031
|
+
fields = AST12.tsTypeLiteral(
|
|
71032
|
+
Object.entries(type.getFields()).map(
|
|
71033
|
+
([key, fieldType]) => {
|
|
71034
|
+
const unwrapped = unwrapType(config4, fieldType.type);
|
|
71035
|
+
let typeOptions = AST12.tsUnionType([]);
|
|
71036
|
+
if (graphql19.isScalarType(unwrapped.type)) {
|
|
71037
|
+
typeOptions.types.push(
|
|
71038
|
+
scalarPropertyValue(config4, /* @__PURE__ */ new Set(), unwrapped.type)
|
|
71039
|
+
);
|
|
71040
|
+
} else if (graphql19.isEnumType(unwrapped.type)) {
|
|
71041
|
+
typeOptions.types.push(
|
|
71042
|
+
AST12.tsTypeReference(AST12.identifier(unwrapped.type.name))
|
|
71043
|
+
);
|
|
71044
|
+
} else if (!graphql19.isAbstractType(unwrapped.type)) {
|
|
71045
|
+
typeOptions.types.push(record(unwrapped.type.name));
|
|
71046
|
+
} else {
|
|
71047
|
+
typeOptions.types.push(
|
|
71048
|
+
...config4.schema.getPossibleTypes(unwrapped.type).map((type2) => record(type2.name))
|
|
71049
|
+
);
|
|
71050
|
+
}
|
|
71051
|
+
for (const wrapper of unwrapped.wrappers) {
|
|
71052
|
+
if (wrapper === "Nullable" /* Nullable */) {
|
|
71053
|
+
typeOptions = AST12.tsParenthesizedType(
|
|
71054
|
+
AST12.tsUnionType([typeOptions, AST12.tsNullKeyword()])
|
|
71055
|
+
);
|
|
71056
|
+
} else if (wrapper === "List" /* List */) {
|
|
71057
|
+
typeOptions = AST12.tsArrayType(
|
|
71058
|
+
AST12.tsParenthesizedType(typeOptions)
|
|
71059
|
+
);
|
|
71060
|
+
}
|
|
71061
|
+
}
|
|
71062
|
+
if (typeOptions.type === "TSParenthesizedType") {
|
|
71063
|
+
typeOptions = typeOptions.typeAnnotation;
|
|
71064
|
+
}
|
|
71065
|
+
let args = AST12.tsNeverKeyword();
|
|
71066
|
+
if (fieldType.args?.length > 0) {
|
|
71067
|
+
args = AST12.tsTypeLiteral(
|
|
71068
|
+
fieldType.args.map((arg) => {
|
|
71069
|
+
addReferencedInputTypes(
|
|
71070
|
+
config4,
|
|
71071
|
+
"",
|
|
71072
|
+
body,
|
|
71073
|
+
visitedTypes,
|
|
71074
|
+
/* @__PURE__ */ new Set(),
|
|
71075
|
+
arg.type
|
|
71076
|
+
);
|
|
71077
|
+
const prop = AST12.tsPropertySignature(
|
|
71078
|
+
AST12.identifier(arg.name),
|
|
71079
|
+
AST12.tsTypeAnnotation(
|
|
71080
|
+
tsTypeReference(config4, /* @__PURE__ */ new Set(), arg)
|
|
71081
|
+
)
|
|
71082
|
+
);
|
|
71083
|
+
const unwrapped2 = unwrapType(config4, arg.type);
|
|
71084
|
+
prop.optional = unwrapped2.wrappers[unwrapped2.wrappers.length - 1] === "Nullable" /* Nullable */;
|
|
71085
|
+
return prop;
|
|
71086
|
+
})
|
|
71087
|
+
);
|
|
71088
|
+
}
|
|
71089
|
+
return AST12.tsPropertySignature(
|
|
71090
|
+
AST12.identifier(key),
|
|
70746
71091
|
AST12.tsTypeAnnotation(
|
|
70747
71092
|
AST12.tsTypeLiteral([
|
|
70748
71093
|
AST12.tsPropertySignature(
|
|
70749
|
-
AST12.
|
|
70750
|
-
AST12.tsTypeAnnotation(
|
|
70751
|
-
|
|
70752
|
-
|
|
71094
|
+
AST12.identifier("type"),
|
|
71095
|
+
AST12.tsTypeAnnotation(typeOptions)
|
|
71096
|
+
),
|
|
71097
|
+
AST12.tsPropertySignature(
|
|
71098
|
+
AST12.identifier("args"),
|
|
71099
|
+
AST12.tsTypeAnnotation(args)
|
|
70753
71100
|
)
|
|
70754
71101
|
])
|
|
70755
71102
|
)
|
|
70756
|
-
)
|
|
71103
|
+
);
|
|
71104
|
+
}
|
|
71105
|
+
)
|
|
71106
|
+
);
|
|
71107
|
+
}
|
|
71108
|
+
return AST12.tsPropertySignature(
|
|
71109
|
+
AST12.identifier(typeName),
|
|
71110
|
+
AST12.tsTypeAnnotation(
|
|
71111
|
+
AST12.tsTypeLiteral([
|
|
71112
|
+
AST12.tsPropertySignature(
|
|
71113
|
+
AST12.identifier("idFields"),
|
|
71114
|
+
AST12.tsTypeAnnotation(idFields)
|
|
71115
|
+
),
|
|
71116
|
+
AST12.tsPropertySignature(
|
|
71117
|
+
AST12.identifier("fields"),
|
|
71118
|
+
AST12.tsTypeAnnotation(fields)
|
|
71119
|
+
),
|
|
71120
|
+
AST12.tsPropertySignature(
|
|
71121
|
+
AST12.identifier("fragments"),
|
|
71122
|
+
AST12.tsTypeAnnotation(fragmentMap[typeName] ?? AST12.tsTupleType([]))
|
|
70757
71123
|
)
|
|
70758
71124
|
])
|
|
70759
71125
|
)
|
|
71126
|
+
);
|
|
71127
|
+
})
|
|
71128
|
+
);
|
|
71129
|
+
}
|
|
71130
|
+
function listDefinitions(config4, docs) {
|
|
71131
|
+
const lists = [];
|
|
71132
|
+
const visitedLists = /* @__PURE__ */ new Set();
|
|
71133
|
+
for (const doc of docs) {
|
|
71134
|
+
graphql19.visit(doc.document, {
|
|
71135
|
+
Directive(node, key, parent, path2, ancestors) {
|
|
71136
|
+
if (![config4.listDirective, config4.paginateDirective].includes(node.name.value)) {
|
|
71137
|
+
return;
|
|
71138
|
+
}
|
|
71139
|
+
const nameArg = node.arguments?.find((arg) => arg.name.value === "name");
|
|
71140
|
+
const nameValue = nameArg?.value?.value || "";
|
|
71141
|
+
if (!nameValue || visitedLists.has(nameValue)) {
|
|
71142
|
+
return;
|
|
71143
|
+
}
|
|
71144
|
+
visitedLists.add(nameValue);
|
|
71145
|
+
const parentType = parentTypeFromAncestors(
|
|
71146
|
+
config4.schema,
|
|
71147
|
+
doc.filename,
|
|
71148
|
+
ancestors.slice(0, -1)
|
|
71149
|
+
);
|
|
71150
|
+
const targetField = ancestors[ancestors.length - 1];
|
|
71151
|
+
const targetFieldDefinition = parentType.getFields()[targetField.name.value];
|
|
71152
|
+
const { type: listType } = unwrapType(config4, targetFieldDefinition.type);
|
|
71153
|
+
const possibleTypes = [];
|
|
71154
|
+
if (graphql19.isAbstractType(listType)) {
|
|
71155
|
+
possibleTypes.push(
|
|
71156
|
+
...config4.schema.getPossibleTypes(listType).map((possible) => possible.name)
|
|
71157
|
+
);
|
|
71158
|
+
} else {
|
|
71159
|
+
possibleTypes.push(listType.name);
|
|
71160
|
+
}
|
|
71161
|
+
lists.push(
|
|
71162
|
+
AST12.tsPropertySignature(
|
|
71163
|
+
AST12.identifier(nameValue),
|
|
71164
|
+
AST12.tsTypeAnnotation(
|
|
71165
|
+
AST12.tsTypeLiteral([
|
|
71166
|
+
AST12.tsPropertySignature(
|
|
71167
|
+
AST12.identifier("types"),
|
|
71168
|
+
AST12.tsTypeAnnotation(
|
|
71169
|
+
AST12.tsUnionType(
|
|
71170
|
+
possibleTypes.map(
|
|
71171
|
+
(possible) => AST12.tsLiteralType(AST12.stringLiteral(possible))
|
|
71172
|
+
)
|
|
71173
|
+
)
|
|
71174
|
+
)
|
|
71175
|
+
),
|
|
71176
|
+
AST12.tsPropertySignature(
|
|
71177
|
+
AST12.identifier("filters"),
|
|
71178
|
+
AST12.tsTypeAnnotation(
|
|
71179
|
+
targetFieldDefinition.args.length === 0 ? AST12.tsNeverKeyword() : AST12.tsTypeLiteral(
|
|
71180
|
+
targetFieldDefinition.args.map((arg) => {
|
|
71181
|
+
const argDef = AST12.tsPropertySignature(
|
|
71182
|
+
AST12.identifier(arg.name),
|
|
71183
|
+
AST12.tsTypeAnnotation(
|
|
71184
|
+
tsTypeReference(
|
|
71185
|
+
config4,
|
|
71186
|
+
/* @__PURE__ */ new Set(),
|
|
71187
|
+
arg
|
|
71188
|
+
)
|
|
71189
|
+
)
|
|
71190
|
+
);
|
|
71191
|
+
argDef.optional = true;
|
|
71192
|
+
return argDef;
|
|
71193
|
+
})
|
|
71194
|
+
)
|
|
71195
|
+
)
|
|
71196
|
+
)
|
|
71197
|
+
])
|
|
71198
|
+
)
|
|
71199
|
+
)
|
|
71200
|
+
);
|
|
71201
|
+
}
|
|
71202
|
+
});
|
|
71203
|
+
}
|
|
71204
|
+
return AST12.tsTypeLiteral(lists);
|
|
71205
|
+
}
|
|
71206
|
+
function queryDefinitions(config4, body, docs, returnType) {
|
|
71207
|
+
return AST12.tsTupleType(
|
|
71208
|
+
docs.reduce((prev, doc) => {
|
|
71209
|
+
if (doc.kind !== "HoudiniQuery" /* Query */ || !doc.generateStore) {
|
|
71210
|
+
return prev;
|
|
71211
|
+
}
|
|
71212
|
+
const definition = doc.document.definitions.find(
|
|
71213
|
+
(def) => def.kind === "OperationDefinition" && def.operation === "query"
|
|
71214
|
+
);
|
|
71215
|
+
if (!definition) {
|
|
71216
|
+
return prev;
|
|
71217
|
+
}
|
|
71218
|
+
const runtimeType = returnType(doc);
|
|
71219
|
+
const [shapeType, inputType] = ensureImports({
|
|
71220
|
+
config: config4,
|
|
71221
|
+
body,
|
|
71222
|
+
sourceModule: path_exports.relative(
|
|
71223
|
+
config4.runtimeDirectory,
|
|
71224
|
+
config4.artifactImportPath(doc.name)
|
|
71225
|
+
),
|
|
71226
|
+
import: [`${doc.name}$result`, `${doc.name}$input`]
|
|
71227
|
+
});
|
|
71228
|
+
return prev.concat(
|
|
71229
|
+
AST12.tsTupleType([
|
|
71230
|
+
AST12.tsTypeReference(AST12.identifier(runtimeType)),
|
|
71231
|
+
AST12.tsTypeReference(AST12.identifier(shapeType)),
|
|
71232
|
+
AST12.tsTypeReference(AST12.identifier(inputType))
|
|
71233
|
+
])
|
|
71234
|
+
);
|
|
71235
|
+
}, [])
|
|
71236
|
+
);
|
|
71237
|
+
}
|
|
71238
|
+
function fragmentListMap(config4, concreteTypes, body, docs, return_type) {
|
|
71239
|
+
return docs.reduce((prev, doc) => {
|
|
71240
|
+
if (doc.kind !== "HoudiniFragment" /* Fragment */) {
|
|
71241
|
+
return prev;
|
|
71242
|
+
}
|
|
71243
|
+
const definition = doc.document.definitions.find(
|
|
71244
|
+
(def) => def.kind === "FragmentDefinition" && def.name.value === doc.name
|
|
71245
|
+
);
|
|
71246
|
+
if (!definition || !concreteTypes.includes(definition.typeCondition.name.value)) {
|
|
71247
|
+
return prev;
|
|
71248
|
+
}
|
|
71249
|
+
const typeName = definition.typeCondition.name.value;
|
|
71250
|
+
const previousValue = prev[typeName]?.elementTypes ?? [];
|
|
71251
|
+
const tagResult = return_type(doc);
|
|
71252
|
+
const [shapeType] = ensureImports({
|
|
71253
|
+
config: config4,
|
|
71254
|
+
body,
|
|
71255
|
+
sourceModule: path_exports.relative(
|
|
71256
|
+
config4.runtimeDirectory,
|
|
71257
|
+
config4.artifactImportPath(doc.name)
|
|
70760
71258
|
),
|
|
70761
|
-
|
|
70762
|
-
|
|
70763
|
-
|
|
70764
|
-
|
|
71259
|
+
import: [`${definition.name.value}$data`]
|
|
71260
|
+
});
|
|
71261
|
+
let inputType = AST12.tsNeverKeyword();
|
|
71262
|
+
let directive = definition.directives?.find(
|
|
71263
|
+
(directive2) => directive2.name.value === config4.argumentsDirective
|
|
71264
|
+
);
|
|
71265
|
+
if (directive) {
|
|
71266
|
+
inputType = AST12.tsTypeReference(
|
|
71267
|
+
AST12.identifier(
|
|
71268
|
+
ensureImports({
|
|
70765
71269
|
config: config4,
|
|
70766
|
-
filepath,
|
|
70767
|
-
rootType: type,
|
|
70768
|
-
selections,
|
|
70769
|
-
root: true,
|
|
70770
|
-
allowReadonly: true,
|
|
70771
71270
|
body,
|
|
70772
|
-
|
|
70773
|
-
|
|
70774
|
-
|
|
70775
|
-
|
|
71271
|
+
sourceModule: path_exports.relative(
|
|
71272
|
+
config4.runtimeDirectory,
|
|
71273
|
+
config4.artifactImportPath(doc.name)
|
|
71274
|
+
),
|
|
71275
|
+
import: [`${definition.name.value}$input`]
|
|
71276
|
+
})[0]
|
|
71277
|
+
)
|
|
71278
|
+
);
|
|
71279
|
+
}
|
|
71280
|
+
return {
|
|
71281
|
+
...prev,
|
|
71282
|
+
[typeName]: AST12.tsTupleType(
|
|
71283
|
+
previousValue.concat(
|
|
71284
|
+
AST12.tsTupleType([
|
|
71285
|
+
AST12.tsTypeReference(AST12.identifier(tagResult)),
|
|
71286
|
+
AST12.tsTypeReference(AST12.identifier(shapeType)),
|
|
71287
|
+
inputType
|
|
71288
|
+
])
|
|
70776
71289
|
)
|
|
70777
71290
|
)
|
|
70778
|
-
|
|
70779
|
-
}
|
|
71291
|
+
};
|
|
71292
|
+
}, {});
|
|
71293
|
+
}
|
|
71294
|
+
var CacheTypeDefName = "CacheTypeDef";
|
|
71295
|
+
function record(name2) {
|
|
71296
|
+
return AST12.tsTypeReference(
|
|
71297
|
+
AST12.identifier("Record"),
|
|
71298
|
+
AST12.tsTypeParameterInstantiation([
|
|
71299
|
+
AST12.tsTypeReference(AST12.identifier(CacheTypeDefName)),
|
|
71300
|
+
AST12.tsLiteralType(AST12.stringLiteral(name2))
|
|
71301
|
+
])
|
|
71302
|
+
);
|
|
71303
|
+
}
|
|
71304
|
+
|
|
71305
|
+
// src/codegen/generators/typescript/index.ts
|
|
71306
|
+
async function typescriptGenerator(config4, docs) {
|
|
71307
|
+
await Promise.all([
|
|
71308
|
+
generateDocumentTypes(config4, docs),
|
|
71309
|
+
imperativeCacheTypef(config4, docs)
|
|
71310
|
+
]);
|
|
70780
71311
|
}
|
|
70781
71312
|
|
|
70782
71313
|
// src/codegen/generators/persistedQueries/index.ts
|
|
70783
|
-
var
|
|
71314
|
+
var graphql20 = __toESM(require_graphql2(), 1);
|
|
70784
71315
|
async function persistOutputGenerator(config4, docs) {
|
|
70785
71316
|
if (typeof config4.persistedQueryPath !== "string" || config4.persistedQueryPath.length === 0)
|
|
70786
71317
|
return;
|
|
@@ -70792,8 +71323,8 @@ async function persistOutputGenerator(config4, docs) {
|
|
|
70792
71323
|
if (!generateArtifact) {
|
|
70793
71324
|
return acc;
|
|
70794
71325
|
}
|
|
70795
|
-
let rawString =
|
|
70796
|
-
|
|
71326
|
+
let rawString = graphql20.print(
|
|
71327
|
+
graphql20.visit(document, {
|
|
70797
71328
|
Directive(node) {
|
|
70798
71329
|
if (config4.isInternalDirective(node)) {
|
|
70799
71330
|
return null;
|
|
@@ -70802,7 +71333,7 @@ async function persistOutputGenerator(config4, docs) {
|
|
|
70802
71333
|
})
|
|
70803
71334
|
);
|
|
70804
71335
|
const operations = document.definitions.filter(
|
|
70805
|
-
({ kind }) => kind ===
|
|
71336
|
+
({ kind }) => kind === graphql20.Kind.OPERATION_DEFINITION
|
|
70806
71337
|
);
|
|
70807
71338
|
if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
|
|
70808
71339
|
acc[hashDocument(rawString)] = rawString;
|
|
@@ -70815,11 +71346,11 @@ async function persistOutputGenerator(config4, docs) {
|
|
|
70815
71346
|
}
|
|
70816
71347
|
|
|
70817
71348
|
// src/codegen/generators/definitions/enums.ts
|
|
70818
|
-
var
|
|
71349
|
+
var graphql21 = __toESM(require_graphql2(), 1);
|
|
70819
71350
|
var recast13 = __toESM(require_main2(), 1);
|
|
70820
71351
|
var AST13 = recast13.types.builders;
|
|
70821
71352
|
async function definitionsGenerator(config4) {
|
|
70822
|
-
const enums =
|
|
71353
|
+
const enums = graphql21.parse(graphql21.printSchema(config4.schema)).definitions.filter(
|
|
70823
71354
|
(definition) => definition.kind === "EnumTypeDefinition"
|
|
70824
71355
|
).filter((def) => !config4.isInternalEnum(def));
|
|
70825
71356
|
const runtimeDefinitions = recast13.print(
|
|
@@ -70909,91 +71440,8 @@ async function writeIndexFile2(config4, docs) {
|
|
|
70909
71440
|
await fs_exports.writeFile(path_exports.join(config4.rootDir, "index.js"), body);
|
|
70910
71441
|
}
|
|
70911
71442
|
|
|
70912
|
-
// src/codegen/transforms/composeQueries.ts
|
|
70913
|
-
var import_graphql30 = __toESM(require_graphql2(), 1);
|
|
70914
|
-
async function includeFragmentDefinitions(config4, documents) {
|
|
70915
|
-
const fragments = collectFragments(config4, documents);
|
|
70916
|
-
for (const [index, { name: name2, document, filename }] of documents.entries()) {
|
|
70917
|
-
const operation = document.definitions.find(
|
|
70918
|
-
({ kind }) => kind === import_graphql30.Kind.OPERATION_DEFINITION
|
|
70919
|
-
);
|
|
70920
|
-
if (!operation) {
|
|
70921
|
-
continue;
|
|
70922
|
-
}
|
|
70923
|
-
const allFragments = flattenFragments(
|
|
70924
|
-
filename,
|
|
70925
|
-
{ requiredFragments: findRequiredFragments(operation.selectionSet) },
|
|
70926
|
-
fragments
|
|
70927
|
-
);
|
|
70928
|
-
documents[index].document = {
|
|
70929
|
-
...document,
|
|
70930
|
-
definitions: [
|
|
70931
|
-
operation,
|
|
70932
|
-
...allFragments.map((fragmentName) => fragments[fragmentName].definition)
|
|
70933
|
-
]
|
|
70934
|
-
};
|
|
70935
|
-
}
|
|
70936
|
-
}
|
|
70937
|
-
function collectFragments(config4, docs) {
|
|
70938
|
-
return docs.reduce((acc, doc) => {
|
|
70939
|
-
const definitions = doc.document.definitions.reduce(
|
|
70940
|
-
(prev, definition) => definition.kind !== "FragmentDefinition" ? prev : {
|
|
70941
|
-
...prev,
|
|
70942
|
-
[definition.name.value]: {
|
|
70943
|
-
definition,
|
|
70944
|
-
requiredFragments: findRequiredFragments(definition.selectionSet),
|
|
70945
|
-
document: doc
|
|
70946
|
-
}
|
|
70947
|
-
},
|
|
70948
|
-
{}
|
|
70949
|
-
);
|
|
70950
|
-
return {
|
|
70951
|
-
...acc,
|
|
70952
|
-
...definitions
|
|
70953
|
-
};
|
|
70954
|
-
}, {});
|
|
70955
|
-
}
|
|
70956
|
-
function findRequiredFragments(selectionSet) {
|
|
70957
|
-
if (selectionSet.selections.length === 0) {
|
|
70958
|
-
return [];
|
|
70959
|
-
}
|
|
70960
|
-
const referencedFragments = [];
|
|
70961
|
-
for (const selection2 of selectionSet.selections) {
|
|
70962
|
-
if (selection2.kind === import_graphql30.Kind.FRAGMENT_SPREAD) {
|
|
70963
|
-
referencedFragments.push(selection2.name.value);
|
|
70964
|
-
} else if (selection2.selectionSet) {
|
|
70965
|
-
referencedFragments.push(...findRequiredFragments(selection2.selectionSet));
|
|
70966
|
-
}
|
|
70967
|
-
}
|
|
70968
|
-
return referencedFragments;
|
|
70969
|
-
}
|
|
70970
|
-
function flattenFragments(filepath, operation, fragments) {
|
|
70971
|
-
const frags = /* @__PURE__ */ new Set();
|
|
70972
|
-
const remaining = [...operation.requiredFragments];
|
|
70973
|
-
while (remaining.length > 0) {
|
|
70974
|
-
const nextFragment = remaining.shift();
|
|
70975
|
-
if (!nextFragment) {
|
|
70976
|
-
continue;
|
|
70977
|
-
}
|
|
70978
|
-
if (!frags.has(nextFragment)) {
|
|
70979
|
-
frags.add(nextFragment);
|
|
70980
|
-
} else {
|
|
70981
|
-
continue;
|
|
70982
|
-
}
|
|
70983
|
-
const targetFragment = fragments[nextFragment];
|
|
70984
|
-
if (!targetFragment) {
|
|
70985
|
-
throw new HoudiniError({
|
|
70986
|
-
filepath,
|
|
70987
|
-
message: "compose: could not find definition for fragment " + nextFragment
|
|
70988
|
-
});
|
|
70989
|
-
}
|
|
70990
|
-
remaining.push(...targetFragment.requiredFragments);
|
|
70991
|
-
}
|
|
70992
|
-
return [...frags];
|
|
70993
|
-
}
|
|
70994
|
-
|
|
70995
71443
|
// src/codegen/transforms/schema.ts
|
|
70996
|
-
var
|
|
71444
|
+
var graphql22 = __toESM(require_graphql2(), 1);
|
|
70997
71445
|
async function graphqlExtensions(config4, documents) {
|
|
70998
71446
|
const internalSchema = `
|
|
70999
71447
|
enum CachePolicy {
|
|
@@ -71057,9 +71505,9 @@ directive @${config4.argumentsDirective} on FRAGMENT_DEFINITION
|
|
|
71057
71505
|
directive @${config4.cacheDirective}(${config4.cachePolicyArg}: CachePolicy, ${config4.cachePartialArg}: Boolean) on QUERY
|
|
71058
71506
|
|
|
71059
71507
|
"""
|
|
71060
|
-
@${config4.
|
|
71508
|
+
@${config4.loadDirective} is used to disable automatic fetch (no load, no auto fetch in component), you will have to do it manually.
|
|
71061
71509
|
"""
|
|
71062
|
-
directive @${config4.
|
|
71510
|
+
directive @${config4.loadDirective} on QUERY
|
|
71063
71511
|
|
|
71064
71512
|
"""
|
|
71065
71513
|
@${config4.maskEnableDirective} to enable masking on fragment (overwriting the global conf)
|
|
@@ -71071,19 +71519,19 @@ directive @${config4.maskEnableDirective} on FRAGMENT_SPREAD
|
|
|
71071
71519
|
"""
|
|
71072
71520
|
directive @${config4.maskDisableDirective} on FRAGMENT_SPREAD
|
|
71073
71521
|
`;
|
|
71074
|
-
let currentSchema =
|
|
71522
|
+
let currentSchema = graphql22.printSchema(config4.schema);
|
|
71075
71523
|
if (!currentSchema.includes(`directive @${config4.listDirective}`)) {
|
|
71076
71524
|
currentSchema += internalSchema;
|
|
71077
71525
|
}
|
|
71078
71526
|
config4.newSchema += internalSchema;
|
|
71079
|
-
config4.schema =
|
|
71527
|
+
config4.schema = graphql22.buildSchema(currentSchema);
|
|
71080
71528
|
}
|
|
71081
71529
|
|
|
71082
71530
|
// src/codegen/transforms/typename.ts
|
|
71083
|
-
var
|
|
71531
|
+
var graphql23 = __toESM(require_graphql2(), 1);
|
|
71084
71532
|
async function addTypename(config4, documents) {
|
|
71085
71533
|
for (const doc of documents) {
|
|
71086
|
-
doc.document =
|
|
71534
|
+
doc.document = graphql23.visit(doc.document, {
|
|
71087
71535
|
Field(node, key, parent, path2, ancestors) {
|
|
71088
71536
|
if (!node.selectionSet) {
|
|
71089
71537
|
return;
|
|
@@ -71095,7 +71543,7 @@ async function addTypename(config4, documents) {
|
|
|
71095
71543
|
);
|
|
71096
71544
|
const field = type.getFields()[node.name.value];
|
|
71097
71545
|
const fieldType = unwrapType(config4, field.type).type;
|
|
71098
|
-
if (
|
|
71546
|
+
if (graphql23.isInterfaceType(fieldType) || graphql23.isUnionType(fieldType)) {
|
|
71099
71547
|
return {
|
|
71100
71548
|
...node,
|
|
71101
71549
|
selectionSet: {
|
|
@@ -71103,9 +71551,9 @@ async function addTypename(config4, documents) {
|
|
|
71103
71551
|
selections: [
|
|
71104
71552
|
...node.selectionSet.selections,
|
|
71105
71553
|
{
|
|
71106
|
-
kind:
|
|
71554
|
+
kind: graphql23.Kind.FIELD,
|
|
71107
71555
|
name: {
|
|
71108
|
-
kind:
|
|
71556
|
+
kind: graphql23.Kind.NAME,
|
|
71109
71557
|
value: "__typename"
|
|
71110
71558
|
}
|
|
71111
71559
|
}
|
|
@@ -71119,10 +71567,10 @@ async function addTypename(config4, documents) {
|
|
|
71119
71567
|
}
|
|
71120
71568
|
|
|
71121
71569
|
// src/codegen/transforms/addID.ts
|
|
71122
|
-
var
|
|
71570
|
+
var graphql24 = __toESM(require_graphql2(), 1);
|
|
71123
71571
|
async function addID(config4, documents) {
|
|
71124
71572
|
for (const doc of documents) {
|
|
71125
|
-
doc.document =
|
|
71573
|
+
doc.document = graphql24.visit(doc.document, {
|
|
71126
71574
|
Field(node, key, parent, path2, ancestors) {
|
|
71127
71575
|
if (!node.selectionSet) {
|
|
71128
71576
|
return;
|
|
@@ -71135,7 +71583,7 @@ async function addID(config4, documents) {
|
|
|
71135
71583
|
const field = type.getFields()[node.name.value];
|
|
71136
71584
|
const fieldType = unwrapType(config4, field.type).type;
|
|
71137
71585
|
if (node.selectionSet?.selections.length > 0) {
|
|
71138
|
-
if (!
|
|
71586
|
+
if (!graphql24.isObjectType(fieldType) && !graphql24.isInterfaceType(fieldType)) {
|
|
71139
71587
|
return;
|
|
71140
71588
|
}
|
|
71141
71589
|
const keyFields = config4.keyFieldsForType(fieldType.name);
|
|
@@ -71150,9 +71598,9 @@ async function addID(config4, documents) {
|
|
|
71150
71598
|
continue;
|
|
71151
71599
|
}
|
|
71152
71600
|
selections.push({
|
|
71153
|
-
kind:
|
|
71601
|
+
kind: graphql24.Kind.FIELD,
|
|
71154
71602
|
name: {
|
|
71155
|
-
kind:
|
|
71603
|
+
kind: graphql24.Kind.NAME,
|
|
71156
71604
|
value: keyField
|
|
71157
71605
|
}
|
|
71158
71606
|
});
|
|
@@ -71170,266 +71618,6 @@ async function addID(config4, documents) {
|
|
|
71170
71618
|
}
|
|
71171
71619
|
}
|
|
71172
71620
|
|
|
71173
|
-
// src/codegen/transforms/fragmentVariables.ts
|
|
71174
|
-
var graphql24 = __toESM(require_graphql2(), 1);
|
|
71175
|
-
var GraphqlKinds2 = graphql24.Kind;
|
|
71176
|
-
async function fragmentVariables(config4, documents) {
|
|
71177
|
-
const fragments = collectFragments(config4, documents);
|
|
71178
|
-
const generatedFragments = {};
|
|
71179
|
-
const visitedFragments = /* @__PURE__ */ new Set();
|
|
71180
|
-
for (const doc2 of documents) {
|
|
71181
|
-
const operation = doc2.document.definitions.find(
|
|
71182
|
-
({ kind }) => kind === GraphqlKinds2.OPERATION_DEFINITION
|
|
71183
|
-
);
|
|
71184
|
-
if (!operation) {
|
|
71185
|
-
continue;
|
|
71186
|
-
}
|
|
71187
|
-
doc2.document = inlineFragmentArgs({
|
|
71188
|
-
config: config4,
|
|
71189
|
-
filepath: doc2.filename,
|
|
71190
|
-
fragmentDefinitions: fragments,
|
|
71191
|
-
document: doc2.document,
|
|
71192
|
-
generatedFragments,
|
|
71193
|
-
visitedFragments,
|
|
71194
|
-
scope: null
|
|
71195
|
-
});
|
|
71196
|
-
}
|
|
71197
|
-
const doc = {
|
|
71198
|
-
kind: graphql24.Kind.DOCUMENT,
|
|
71199
|
-
definitions: Object.values(generatedFragments)
|
|
71200
|
-
};
|
|
71201
|
-
documents.push({
|
|
71202
|
-
name: "generated::fragmentVariables",
|
|
71203
|
-
kind: "HoudiniFragment" /* Fragment */,
|
|
71204
|
-
document: doc,
|
|
71205
|
-
originalDocument: doc,
|
|
71206
|
-
generateStore: false,
|
|
71207
|
-
generateArtifact: false,
|
|
71208
|
-
filename: "generated::fragmentVariables",
|
|
71209
|
-
originalString: ""
|
|
71210
|
-
});
|
|
71211
|
-
}
|
|
71212
|
-
function inlineFragmentArgs({
|
|
71213
|
-
config: config4,
|
|
71214
|
-
filepath,
|
|
71215
|
-
fragmentDefinitions,
|
|
71216
|
-
document,
|
|
71217
|
-
generatedFragments,
|
|
71218
|
-
visitedFragments,
|
|
71219
|
-
scope,
|
|
71220
|
-
newName
|
|
71221
|
-
}) {
|
|
71222
|
-
if (!scope) {
|
|
71223
|
-
scope = operationScope(
|
|
71224
|
-
document.definitions.find(
|
|
71225
|
-
({ kind }) => kind === GraphqlKinds2.OPERATION_DEFINITION
|
|
71226
|
-
)
|
|
71227
|
-
);
|
|
71228
|
-
}
|
|
71229
|
-
const definitionArgs = fragmentArguments(
|
|
71230
|
-
config4,
|
|
71231
|
-
filepath,
|
|
71232
|
-
document
|
|
71233
|
-
).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
|
|
71234
|
-
const result = graphql24.visit(document, {
|
|
71235
|
-
FragmentSpread(node) {
|
|
71236
|
-
const { definition } = fragmentDefinitions[node.name.value];
|
|
71237
|
-
let { args, hash } = collectWithArguments(config4, filepath, node, scope);
|
|
71238
|
-
const newFragmentName = `${node.name.value}${hash}`;
|
|
71239
|
-
if (!visitedFragments.has(newFragmentName)) {
|
|
71240
|
-
visitedFragments.add(newFragmentName);
|
|
71241
|
-
const defaultArguments = collectDefaultArgumentValues(config4, filepath, definition);
|
|
71242
|
-
if (args) {
|
|
71243
|
-
for (const [field, value] of Object.entries(defaultArguments || {})) {
|
|
71244
|
-
if (!args[field]) {
|
|
71245
|
-
args[field] = value;
|
|
71246
|
-
}
|
|
71247
|
-
}
|
|
71248
|
-
generatedFragments[newFragmentName] = inlineFragmentArgs({
|
|
71249
|
-
config: config4,
|
|
71250
|
-
filepath,
|
|
71251
|
-
fragmentDefinitions,
|
|
71252
|
-
document: fragmentDefinitions[node.name.value].definition,
|
|
71253
|
-
generatedFragments,
|
|
71254
|
-
visitedFragments,
|
|
71255
|
-
scope: args,
|
|
71256
|
-
newName: newFragmentName
|
|
71257
|
-
});
|
|
71258
|
-
} else {
|
|
71259
|
-
const doc = fragmentDefinitions[node.name.value].document;
|
|
71260
|
-
const definitionIndex = doc.document.definitions.findIndex(
|
|
71261
|
-
(definition2) => definition2.kind === "FragmentDefinition" && definition2.name.value === node.name.value
|
|
71262
|
-
);
|
|
71263
|
-
const localDefinitions = [...doc.document.definitions];
|
|
71264
|
-
localDefinitions.splice(definitionIndex, 1);
|
|
71265
|
-
localDefinitions.push(
|
|
71266
|
-
inlineFragmentArgs({
|
|
71267
|
-
config: config4,
|
|
71268
|
-
filepath,
|
|
71269
|
-
fragmentDefinitions,
|
|
71270
|
-
document: fragmentDefinitions[node.name.value].definition,
|
|
71271
|
-
generatedFragments,
|
|
71272
|
-
visitedFragments,
|
|
71273
|
-
scope: defaultArguments,
|
|
71274
|
-
newName: ""
|
|
71275
|
-
})
|
|
71276
|
-
);
|
|
71277
|
-
doc.document = {
|
|
71278
|
-
...doc.document,
|
|
71279
|
-
definitions: localDefinitions
|
|
71280
|
-
};
|
|
71281
|
-
}
|
|
71282
|
-
if (node.name.value !== newFragmentName) {
|
|
71283
|
-
return {
|
|
71284
|
-
...node,
|
|
71285
|
-
name: {
|
|
71286
|
-
kind: "Name",
|
|
71287
|
-
value: newFragmentName
|
|
71288
|
-
}
|
|
71289
|
-
};
|
|
71290
|
-
}
|
|
71291
|
-
}
|
|
71292
|
-
},
|
|
71293
|
-
Argument(node) {
|
|
71294
|
-
const value = node.value;
|
|
71295
|
-
if (value.kind !== "Variable") {
|
|
71296
|
-
return;
|
|
71297
|
-
}
|
|
71298
|
-
if (!scope) {
|
|
71299
|
-
throw new HoudiniError({
|
|
71300
|
-
filepath,
|
|
71301
|
-
message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
|
|
71302
|
-
});
|
|
71303
|
-
}
|
|
71304
|
-
const newValue = scope[value.name.value];
|
|
71305
|
-
if (newValue) {
|
|
71306
|
-
return {
|
|
71307
|
-
...node,
|
|
71308
|
-
value: newValue
|
|
71309
|
-
};
|
|
71310
|
-
}
|
|
71311
|
-
if (definitionArgs[value.name.value] && definitionArgs[value.name.value].required) {
|
|
71312
|
-
throw new HoudiniError({
|
|
71313
|
-
filepath,
|
|
71314
|
-
message: "Missing value for required arg: " + value.name.value
|
|
71315
|
-
});
|
|
71316
|
-
}
|
|
71317
|
-
return null;
|
|
71318
|
-
}
|
|
71319
|
-
});
|
|
71320
|
-
if (newName) {
|
|
71321
|
-
result.name = {
|
|
71322
|
-
kind: graphql24.Kind.NAME,
|
|
71323
|
-
value: newName
|
|
71324
|
-
};
|
|
71325
|
-
}
|
|
71326
|
-
return result;
|
|
71327
|
-
}
|
|
71328
|
-
function withArguments(config4, node) {
|
|
71329
|
-
const withDirectives = node.directives?.filter(
|
|
71330
|
-
(directive) => directive.name.value === config4.withDirective
|
|
71331
|
-
);
|
|
71332
|
-
if (!withDirectives || withDirectives.length === 0) {
|
|
71333
|
-
return [];
|
|
71334
|
-
}
|
|
71335
|
-
return withDirectives.flatMap((directive) => directive.arguments || []);
|
|
71336
|
-
}
|
|
71337
|
-
function fragmentArguments(config4, filepath, definition) {
|
|
71338
|
-
const directives = definition.directives?.filter(
|
|
71339
|
-
(directive) => directive.name.value === config4.argumentsDirective
|
|
71340
|
-
);
|
|
71341
|
-
if (!directives || directives.length === 0) {
|
|
71342
|
-
return [];
|
|
71343
|
-
}
|
|
71344
|
-
return directives.flatMap(
|
|
71345
|
-
(directive) => directive.arguments?.flatMap((arg) => {
|
|
71346
|
-
if (arg.value.kind !== "ObjectValue") {
|
|
71347
|
-
throw new HoudiniError({
|
|
71348
|
-
filepath,
|
|
71349
|
-
message: "values of @argument must be objects"
|
|
71350
|
-
});
|
|
71351
|
-
}
|
|
71352
|
-
const typeArg = arg.value.fields?.find((arg2) => arg2.name.value === "type")?.value;
|
|
71353
|
-
if (!typeArg || typeArg.kind !== "StringValue") {
|
|
71354
|
-
return [];
|
|
71355
|
-
}
|
|
71356
|
-
let type = typeArg.value;
|
|
71357
|
-
let name2 = arg.name.value;
|
|
71358
|
-
let required = false;
|
|
71359
|
-
let defaultValue = arg.value.fields?.find((arg2) => arg2.name.value === "default")?.value || null;
|
|
71360
|
-
if (type[type.length - 1] === "!") {
|
|
71361
|
-
type = type.slice(0, -1);
|
|
71362
|
-
required = true;
|
|
71363
|
-
defaultValue = null;
|
|
71364
|
-
}
|
|
71365
|
-
return [
|
|
71366
|
-
{
|
|
71367
|
-
name: name2,
|
|
71368
|
-
type,
|
|
71369
|
-
required,
|
|
71370
|
-
defaultValue
|
|
71371
|
-
}
|
|
71372
|
-
];
|
|
71373
|
-
}) || []
|
|
71374
|
-
);
|
|
71375
|
-
}
|
|
71376
|
-
function collectDefaultArgumentValues(config4, filepath, definition) {
|
|
71377
|
-
let result = {};
|
|
71378
|
-
for (const { name: name2, required, defaultValue } of fragmentArguments(
|
|
71379
|
-
config4,
|
|
71380
|
-
filepath,
|
|
71381
|
-
definition
|
|
71382
|
-
)) {
|
|
71383
|
-
if (required || !defaultValue) {
|
|
71384
|
-
continue;
|
|
71385
|
-
}
|
|
71386
|
-
result[name2] = defaultValue;
|
|
71387
|
-
}
|
|
71388
|
-
return result;
|
|
71389
|
-
}
|
|
71390
|
-
function collectWithArguments(config4, filepath, node, scope = {}) {
|
|
71391
|
-
const withArgs = withArguments(config4, node);
|
|
71392
|
-
if (withArgs.length === 0) {
|
|
71393
|
-
return { args: null, hash: "" };
|
|
71394
|
-
}
|
|
71395
|
-
let args = {};
|
|
71396
|
-
for (const arg of withArgs) {
|
|
71397
|
-
let value = arg.value;
|
|
71398
|
-
if (value.kind === GraphqlKinds2.VARIABLE) {
|
|
71399
|
-
if (!scope || !scope[value.name.value]) {
|
|
71400
|
-
throw new HoudiniError({
|
|
71401
|
-
filepath,
|
|
71402
|
-
message: "Encountered undefined variable: " + value.name.value
|
|
71403
|
-
});
|
|
71404
|
-
}
|
|
71405
|
-
value = scope[value.name.value];
|
|
71406
|
-
}
|
|
71407
|
-
args[arg.name.value] = {
|
|
71408
|
-
...value,
|
|
71409
|
-
loc: void 0
|
|
71410
|
-
};
|
|
71411
|
-
}
|
|
71412
|
-
return {
|
|
71413
|
-
args,
|
|
71414
|
-
hash: "_" + murmurHash(JSON.stringify(args))
|
|
71415
|
-
};
|
|
71416
|
-
}
|
|
71417
|
-
function operationScope(operation) {
|
|
71418
|
-
return operation.variableDefinitions?.reduce(
|
|
71419
|
-
(scope, definition) => ({
|
|
71420
|
-
...scope,
|
|
71421
|
-
[definition.variable.name.value]: {
|
|
71422
|
-
kind: "Variable",
|
|
71423
|
-
name: {
|
|
71424
|
-
kind: "Name",
|
|
71425
|
-
value: definition.variable.name.value
|
|
71426
|
-
}
|
|
71427
|
-
}
|
|
71428
|
-
}),
|
|
71429
|
-
{}
|
|
71430
|
-
) || {};
|
|
71431
|
-
}
|
|
71432
|
-
|
|
71433
71621
|
// src/codegen/validators/typeCheck.ts
|
|
71434
71622
|
var graphql25 = __toESM(require_graphql2(), 1);
|
|
71435
71623
|
async function typeCheck(config4, docs) {
|