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