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/cmd-esm/index.js
CHANGED
|
@@ -69862,8 +69862,7 @@ var Config = class {
|
|
|
69862
69862
|
types: types16 = {},
|
|
69863
69863
|
logLevel,
|
|
69864
69864
|
defaultFragmentMasking = "enable",
|
|
69865
|
-
|
|
69866
|
-
schemaPollHeaders = {},
|
|
69865
|
+
watchSchema,
|
|
69867
69866
|
projectDir
|
|
69868
69867
|
} = this.configFile;
|
|
69869
69868
|
if (typeof schema === "string") {
|
|
@@ -69896,8 +69895,8 @@ var Config = class {
|
|
|
69896
69895
|
this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
|
|
69897
69896
|
this.defaultFragmentMasking = defaultFragmentMasking;
|
|
69898
69897
|
this.routesDir = join2(this.projectRoot, "src", "routes");
|
|
69899
|
-
this.schemaPollInterval =
|
|
69900
|
-
this.schemaPollHeaders =
|
|
69898
|
+
this.schemaPollInterval = watchSchema?.interval ?? 2e3;
|
|
69899
|
+
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
69901
69900
|
this.rootDir = join2(this.projectRoot, "$houdini");
|
|
69902
69901
|
if (defaultKeys) {
|
|
69903
69902
|
this.defaultKeys = defaultKeys;
|
|
@@ -69910,11 +69909,12 @@ var Config = class {
|
|
|
69910
69909
|
}
|
|
69911
69910
|
}
|
|
69912
69911
|
async apiURL() {
|
|
69913
|
-
|
|
69912
|
+
const apiURL = this.configFile.watchSchema?.url;
|
|
69913
|
+
if (!apiURL) {
|
|
69914
69914
|
return "";
|
|
69915
69915
|
}
|
|
69916
69916
|
const env = await this.getEnv();
|
|
69917
|
-
return this.processEnvValues(env,
|
|
69917
|
+
return this.processEnvValues(env, apiURL);
|
|
69918
69918
|
}
|
|
69919
69919
|
get include() {
|
|
69920
69920
|
if (this.configFile.include) {
|
|
@@ -70118,8 +70118,8 @@ var Config = class {
|
|
|
70118
70118
|
pluginDirectory(name2) {
|
|
70119
70119
|
return join2(this.pluginRootDirectory, name2);
|
|
70120
70120
|
}
|
|
70121
|
-
get
|
|
70122
|
-
return "
|
|
70121
|
+
get loadDirective() {
|
|
70122
|
+
return "load";
|
|
70123
70123
|
}
|
|
70124
70124
|
get maskEnableDirective() {
|
|
70125
70125
|
return "mask_enable";
|
|
@@ -70236,7 +70236,7 @@ var Config = class {
|
|
|
70236
70236
|
this.withDirective,
|
|
70237
70237
|
this.paginateDirective,
|
|
70238
70238
|
this.cacheDirective,
|
|
70239
|
-
this.
|
|
70239
|
+
this.loadDirective,
|
|
70240
70240
|
this.maskEnableDirective,
|
|
70241
70241
|
this.maskDisableDirective
|
|
70242
70242
|
].includes(name2.value) || this.isDeleteDirective(name2.value);
|
|
@@ -70825,7 +70825,7 @@ async function find_graphql(config2, parsedScript, walker) {
|
|
|
70825
70825
|
return;
|
|
70826
70826
|
}
|
|
70827
70827
|
const parsedTag = graphql4.parse(documentString);
|
|
70828
|
-
if (walker.where && !walker.where(parsedTag)) {
|
|
70828
|
+
if (walker.where && !walker.where(parsedTag, { node, parent })) {
|
|
70829
70829
|
return;
|
|
70830
70830
|
}
|
|
70831
70831
|
const definition = config2.extractDefinition(parsedTag);
|
|
@@ -70869,7 +70869,7 @@ async function find_graphql(config2, parsedScript, walker) {
|
|
|
70869
70869
|
var graphql27 = __toESM(require_graphql2(), 1);
|
|
70870
70870
|
|
|
70871
70871
|
// src/codegen/generators/artifacts/index.ts
|
|
70872
|
-
var
|
|
70872
|
+
var graphql14 = __toESM(require_graphql2(), 1);
|
|
70873
70873
|
var recast5 = __toESM(require_main2(), 1);
|
|
70874
70874
|
|
|
70875
70875
|
// src/codegen/utils/commonjs.ts
|
|
@@ -71127,159 +71127,534 @@ function murmurHash(str) {
|
|
|
71127
71127
|
return s2;
|
|
71128
71128
|
}
|
|
71129
71129
|
|
|
71130
|
-
// src/codegen/
|
|
71131
|
-
async function writeIndexFile(config2, docs) {
|
|
71132
|
-
const docsToGenerate = docs.filter((doc) => doc.generateArtifact).sort((a, b) => a.name.localeCompare(b.name));
|
|
71133
|
-
let body = config2.module === "esm" ? docsToGenerate.reduce(
|
|
71134
|
-
(content, doc) => content + `
|
|
71135
|
-
export { default as ${doc.name}} from './${doc.name}'`,
|
|
71136
|
-
""
|
|
71137
|
-
) : docsToGenerate.reduce(
|
|
71138
|
-
(content, doc) => content + `
|
|
71139
|
-
${exportDefaultFrom(`./${doc.name}`, doc.name)}`,
|
|
71140
|
-
cjsIndexFilePreamble
|
|
71141
|
-
);
|
|
71142
|
-
await fs_exports.writeFile(path_exports.join(config2.artifactDirectory, "index.js"), body);
|
|
71143
|
-
}
|
|
71144
|
-
|
|
71145
|
-
// src/codegen/generators/artifacts/inputs.ts
|
|
71130
|
+
// src/codegen/transforms/fragmentVariables.ts
|
|
71146
71131
|
var graphql5 = __toESM(require_graphql2(), 1);
|
|
71147
|
-
var recast3 = __toESM(require_main2(), 1);
|
|
71148
|
-
var AST3 = recast3.types.builders;
|
|
71149
|
-
function inputObject(config2, inputs) {
|
|
71150
|
-
const visitedTypes = /* @__PURE__ */ new Set();
|
|
71151
|
-
const inputObj = {
|
|
71152
|
-
fields: inputs.reduce((fields, input) => {
|
|
71153
|
-
const { type } = unwrapType(config2, input.type);
|
|
71154
|
-
return {
|
|
71155
|
-
...fields,
|
|
71156
|
-
[input.variable.name.value]: type.name
|
|
71157
|
-
};
|
|
71158
|
-
}, {}),
|
|
71159
|
-
types: {}
|
|
71160
|
-
};
|
|
71161
|
-
for (const input of inputs) {
|
|
71162
|
-
walkInputs(config2, visitedTypes, inputObj, input.type);
|
|
71163
|
-
}
|
|
71164
|
-
return inputObj;
|
|
71165
|
-
}
|
|
71166
|
-
function walkInputs(config2, visitedTypes, inputObj, rootType) {
|
|
71167
|
-
const { type } = unwrapType(config2, rootType);
|
|
71168
|
-
if (visitedTypes.has(type.name)) {
|
|
71169
|
-
return;
|
|
71170
|
-
}
|
|
71171
|
-
if (graphql5.isEnumType(type) || graphql5.isScalarType(type)) {
|
|
71172
|
-
return;
|
|
71173
|
-
}
|
|
71174
|
-
if (graphql5.isUnionType(type)) {
|
|
71175
|
-
return;
|
|
71176
|
-
}
|
|
71177
|
-
visitedTypes.add(type.name);
|
|
71178
|
-
inputObj.types[type.name] = Object.values(type.getFields()).reduce(
|
|
71179
|
-
(typeFields, field) => {
|
|
71180
|
-
const { type: fieldType } = unwrapType(config2, field.type);
|
|
71181
|
-
walkInputs(config2, visitedTypes, inputObj, fieldType);
|
|
71182
|
-
return {
|
|
71183
|
-
...typeFields,
|
|
71184
|
-
[field.name]: fieldType.toString()
|
|
71185
|
-
};
|
|
71186
|
-
},
|
|
71187
|
-
{}
|
|
71188
|
-
);
|
|
71189
|
-
}
|
|
71190
71132
|
|
|
71191
|
-
// src/codegen/
|
|
71192
|
-
var
|
|
71193
|
-
|
|
71194
|
-
|
|
71195
|
-
|
|
71196
|
-
|
|
71197
|
-
|
|
71198
|
-
|
|
71199
|
-
|
|
71200
|
-
|
|
71133
|
+
// src/codegen/transforms/composeQueries.ts
|
|
71134
|
+
var import_graphql30 = __toESM(require_graphql2(), 1);
|
|
71135
|
+
async function includeFragmentDefinitions(config2, documents) {
|
|
71136
|
+
const fragments = collectFragments(config2, documents);
|
|
71137
|
+
for (const [index, { name: name2, document, filename }] of documents.entries()) {
|
|
71138
|
+
const operation = document.definitions.find(
|
|
71139
|
+
({ kind }) => kind === import_graphql30.Kind.OPERATION_DEFINITION
|
|
71140
|
+
);
|
|
71141
|
+
if (!operation) {
|
|
71142
|
+
continue;
|
|
71143
|
+
}
|
|
71144
|
+
const allFragments = flattenFragments(
|
|
71145
|
+
filename,
|
|
71146
|
+
{ requiredFragments: findRequiredFragments(operation.selectionSet) },
|
|
71147
|
+
fragments
|
|
71148
|
+
);
|
|
71149
|
+
documents[index].document = {
|
|
71150
|
+
...document,
|
|
71151
|
+
definitions: [
|
|
71152
|
+
operation,
|
|
71153
|
+
...allFragments.map((fragmentName) => fragments[fragmentName].definition)
|
|
71154
|
+
]
|
|
71155
|
+
};
|
|
71201
71156
|
}
|
|
71202
|
-
|
|
71203
|
-
|
|
71204
|
-
|
|
71205
|
-
|
|
71206
|
-
)
|
|
71157
|
+
}
|
|
71158
|
+
function collectFragments(config2, docs) {
|
|
71159
|
+
return docs.reduce((acc, doc) => {
|
|
71160
|
+
const definitions = doc.document.definitions.reduce(
|
|
71161
|
+
(prev, definition) => definition.kind !== "FragmentDefinition" ? prev : {
|
|
71162
|
+
...prev,
|
|
71163
|
+
[definition.name.value]: {
|
|
71164
|
+
definition,
|
|
71165
|
+
requiredFragments: findRequiredFragments(definition.selectionSet),
|
|
71166
|
+
document: doc
|
|
71167
|
+
}
|
|
71168
|
+
},
|
|
71169
|
+
{}
|
|
71207
71170
|
);
|
|
71171
|
+
return {
|
|
71172
|
+
...acc,
|
|
71173
|
+
...definitions
|
|
71174
|
+
};
|
|
71175
|
+
}, {});
|
|
71176
|
+
}
|
|
71177
|
+
function findRequiredFragments(selectionSet) {
|
|
71178
|
+
if (selectionSet.selections.length === 0) {
|
|
71179
|
+
return [];
|
|
71208
71180
|
}
|
|
71209
|
-
|
|
71210
|
-
|
|
71211
|
-
|
|
71212
|
-
|
|
71213
|
-
|
|
71214
|
-
);
|
|
71181
|
+
const referencedFragments = [];
|
|
71182
|
+
for (const selection2 of selectionSet.selections) {
|
|
71183
|
+
if (selection2.kind === import_graphql30.Kind.FRAGMENT_SPREAD) {
|
|
71184
|
+
referencedFragments.push(selection2.name.value);
|
|
71185
|
+
} else if (selection2.selectionSet) {
|
|
71186
|
+
referencedFragments.push(...findRequiredFragments(selection2.selectionSet));
|
|
71215
71187
|
}
|
|
71216
|
-
return AST4.stringLiteral(value);
|
|
71217
71188
|
}
|
|
71218
|
-
return
|
|
71189
|
+
return referencedFragments;
|
|
71219
71190
|
}
|
|
71220
|
-
function
|
|
71221
|
-
|
|
71222
|
-
|
|
71223
|
-
|
|
71224
|
-
|
|
71191
|
+
function flattenFragments(filepath, operation, fragments) {
|
|
71192
|
+
const frags = /* @__PURE__ */ new Set();
|
|
71193
|
+
const remaining = [...operation.requiredFragments];
|
|
71194
|
+
while (remaining.length > 0) {
|
|
71195
|
+
const nextFragment = remaining.shift();
|
|
71196
|
+
if (!nextFragment) {
|
|
71197
|
+
continue;
|
|
71225
71198
|
}
|
|
71226
|
-
|
|
71227
|
-
|
|
71228
|
-
|
|
71229
|
-
|
|
71230
|
-
|
|
71231
|
-
|
|
71232
|
-
|
|
71233
|
-
|
|
71234
|
-
|
|
71235
|
-
|
|
71236
|
-
}
|
|
71237
|
-
fields[key].push(value);
|
|
71199
|
+
if (!frags.has(nextFragment)) {
|
|
71200
|
+
frags.add(nextFragment);
|
|
71201
|
+
} else {
|
|
71202
|
+
continue;
|
|
71203
|
+
}
|
|
71204
|
+
const targetFragment = fragments[nextFragment];
|
|
71205
|
+
if (!targetFragment) {
|
|
71206
|
+
throw new HoudiniError({
|
|
71207
|
+
filepath,
|
|
71208
|
+
message: "compose: could not find definition for fragment " + nextFragment
|
|
71209
|
+
});
|
|
71238
71210
|
}
|
|
71211
|
+
remaining.push(...targetFragment.requiredFragments);
|
|
71239
71212
|
}
|
|
71240
|
-
return
|
|
71241
|
-
Object.entries(fields).map(([key, value]) => [key, deepMerge(filepath, ...value)])
|
|
71242
|
-
);
|
|
71213
|
+
return [...frags];
|
|
71243
71214
|
}
|
|
71244
|
-
|
|
71245
|
-
|
|
71246
|
-
|
|
71247
|
-
|
|
71248
|
-
|
|
71249
|
-
|
|
71250
|
-
|
|
71251
|
-
|
|
71252
|
-
|
|
71253
|
-
|
|
71254
|
-
|
|
71255
|
-
|
|
71256
|
-
|
|
71257
|
-
|
|
71258
|
-
|
|
71259
|
-
|
|
71260
|
-
|
|
71261
|
-
|
|
71215
|
+
|
|
71216
|
+
// src/codegen/transforms/fragmentVariables.ts
|
|
71217
|
+
var GraphqlKinds2 = graphql5.Kind;
|
|
71218
|
+
async function fragmentVariables(config2, documents) {
|
|
71219
|
+
const fragments = collectFragments(config2, documents);
|
|
71220
|
+
const generatedFragments = {};
|
|
71221
|
+
const visitedFragments = /* @__PURE__ */ new Set();
|
|
71222
|
+
for (const doc2 of documents) {
|
|
71223
|
+
const operation = doc2.document.definitions.find(
|
|
71224
|
+
({ kind }) => kind === GraphqlKinds2.OPERATION_DEFINITION
|
|
71225
|
+
);
|
|
71226
|
+
if (!operation) {
|
|
71227
|
+
continue;
|
|
71228
|
+
}
|
|
71229
|
+
doc2.document = inlineFragmentArgs({
|
|
71230
|
+
config: config2,
|
|
71231
|
+
filepath: doc2.filename,
|
|
71232
|
+
fragmentDefinitions: fragments,
|
|
71233
|
+
document: doc2.document,
|
|
71234
|
+
generatedFragments,
|
|
71235
|
+
visitedFragments,
|
|
71236
|
+
scope: null
|
|
71237
|
+
});
|
|
71262
71238
|
}
|
|
71263
|
-
|
|
71239
|
+
const doc = {
|
|
71240
|
+
kind: graphql5.Kind.DOCUMENT,
|
|
71241
|
+
definitions: Object.values(generatedFragments)
|
|
71242
|
+
};
|
|
71243
|
+
documents.push({
|
|
71244
|
+
name: "generated::fragmentVariables",
|
|
71245
|
+
kind: "HoudiniFragment" /* Fragment */,
|
|
71246
|
+
document: doc,
|
|
71247
|
+
originalDocument: doc,
|
|
71248
|
+
generateStore: false,
|
|
71249
|
+
generateArtifact: false,
|
|
71250
|
+
filename: "generated::fragmentVariables",
|
|
71251
|
+
originalString: ""
|
|
71252
|
+
});
|
|
71264
71253
|
}
|
|
71265
|
-
|
|
71266
|
-
|
|
71267
|
-
|
|
71268
|
-
|
|
71269
|
-
|
|
71254
|
+
function inlineFragmentArgs({
|
|
71255
|
+
config: config2,
|
|
71256
|
+
filepath,
|
|
71257
|
+
fragmentDefinitions,
|
|
71258
|
+
document,
|
|
71259
|
+
generatedFragments,
|
|
71260
|
+
visitedFragments,
|
|
71261
|
+
scope,
|
|
71262
|
+
newName
|
|
71263
|
+
}) {
|
|
71264
|
+
if (!scope) {
|
|
71265
|
+
scope = operationScope(
|
|
71266
|
+
document.definitions.find(
|
|
71267
|
+
({ kind }) => kind === GraphqlKinds2.OPERATION_DEFINITION
|
|
71268
|
+
)
|
|
71269
|
+
);
|
|
71270
71270
|
}
|
|
71271
|
-
const
|
|
71272
|
-
|
|
71273
|
-
|
|
71274
|
-
|
|
71275
|
-
|
|
71276
|
-
|
|
71277
|
-
|
|
71278
|
-
|
|
71279
|
-
|
|
71280
|
-
}
|
|
71281
|
-
|
|
71282
|
-
|
|
71271
|
+
const definitionArgs = fragmentArguments(
|
|
71272
|
+
config2,
|
|
71273
|
+
filepath,
|
|
71274
|
+
document
|
|
71275
|
+
).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
|
|
71276
|
+
const result = graphql5.visit(document, {
|
|
71277
|
+
FragmentSpread(node) {
|
|
71278
|
+
const { definition } = fragmentDefinitions[node.name.value];
|
|
71279
|
+
let { args, hash } = collectWithArguments(config2, filepath, node, scope);
|
|
71280
|
+
const newFragmentName = `${node.name.value}${hash}`;
|
|
71281
|
+
if (!visitedFragments.has(newFragmentName)) {
|
|
71282
|
+
visitedFragments.add(newFragmentName);
|
|
71283
|
+
const defaultArguments = collectDefaultArgumentValues(config2, filepath, definition);
|
|
71284
|
+
if (args) {
|
|
71285
|
+
for (const [field, value] of Object.entries(defaultArguments || {})) {
|
|
71286
|
+
if (!args[field]) {
|
|
71287
|
+
args[field] = value;
|
|
71288
|
+
}
|
|
71289
|
+
}
|
|
71290
|
+
generatedFragments[newFragmentName] = inlineFragmentArgs({
|
|
71291
|
+
config: config2,
|
|
71292
|
+
filepath,
|
|
71293
|
+
fragmentDefinitions,
|
|
71294
|
+
document: fragmentDefinitions[node.name.value].definition,
|
|
71295
|
+
generatedFragments,
|
|
71296
|
+
visitedFragments,
|
|
71297
|
+
scope: args,
|
|
71298
|
+
newName: newFragmentName
|
|
71299
|
+
});
|
|
71300
|
+
} else {
|
|
71301
|
+
const doc = fragmentDefinitions[node.name.value].document;
|
|
71302
|
+
const definitionIndex = doc.document.definitions.findIndex(
|
|
71303
|
+
(definition2) => definition2.kind === "FragmentDefinition" && definition2.name.value === node.name.value
|
|
71304
|
+
);
|
|
71305
|
+
const localDefinitions = [...doc.document.definitions];
|
|
71306
|
+
localDefinitions.splice(definitionIndex, 1);
|
|
71307
|
+
localDefinitions.push(
|
|
71308
|
+
inlineFragmentArgs({
|
|
71309
|
+
config: config2,
|
|
71310
|
+
filepath,
|
|
71311
|
+
fragmentDefinitions,
|
|
71312
|
+
document: fragmentDefinitions[node.name.value].definition,
|
|
71313
|
+
generatedFragments,
|
|
71314
|
+
visitedFragments,
|
|
71315
|
+
scope: defaultArguments,
|
|
71316
|
+
newName: ""
|
|
71317
|
+
})
|
|
71318
|
+
);
|
|
71319
|
+
doc.document = {
|
|
71320
|
+
...doc.document,
|
|
71321
|
+
definitions: localDefinitions
|
|
71322
|
+
};
|
|
71323
|
+
}
|
|
71324
|
+
if (node.name.value !== newFragmentName) {
|
|
71325
|
+
return {
|
|
71326
|
+
...node,
|
|
71327
|
+
name: {
|
|
71328
|
+
kind: "Name",
|
|
71329
|
+
value: newFragmentName
|
|
71330
|
+
}
|
|
71331
|
+
};
|
|
71332
|
+
}
|
|
71333
|
+
}
|
|
71334
|
+
},
|
|
71335
|
+
Argument(node) {
|
|
71336
|
+
const value = node.value;
|
|
71337
|
+
if (value.kind !== "Variable") {
|
|
71338
|
+
return;
|
|
71339
|
+
}
|
|
71340
|
+
if (!scope) {
|
|
71341
|
+
throw new HoudiniError({
|
|
71342
|
+
filepath,
|
|
71343
|
+
message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
|
|
71344
|
+
});
|
|
71345
|
+
}
|
|
71346
|
+
const newValue = scope[value.name.value];
|
|
71347
|
+
if (newValue) {
|
|
71348
|
+
return {
|
|
71349
|
+
...node,
|
|
71350
|
+
value: newValue
|
|
71351
|
+
};
|
|
71352
|
+
}
|
|
71353
|
+
if (definitionArgs[value.name.value] && definitionArgs[value.name.value].required) {
|
|
71354
|
+
throw new HoudiniError({
|
|
71355
|
+
filepath,
|
|
71356
|
+
message: "Missing value for required arg: " + value.name.value
|
|
71357
|
+
});
|
|
71358
|
+
}
|
|
71359
|
+
return null;
|
|
71360
|
+
}
|
|
71361
|
+
});
|
|
71362
|
+
if (newName) {
|
|
71363
|
+
result.name = {
|
|
71364
|
+
kind: graphql5.Kind.NAME,
|
|
71365
|
+
value: newName
|
|
71366
|
+
};
|
|
71367
|
+
}
|
|
71368
|
+
return result;
|
|
71369
|
+
}
|
|
71370
|
+
function withArguments(config2, node) {
|
|
71371
|
+
const withDirectives = node.directives?.filter(
|
|
71372
|
+
(directive) => directive.name.value === config2.withDirective
|
|
71373
|
+
);
|
|
71374
|
+
if (!withDirectives || withDirectives.length === 0) {
|
|
71375
|
+
return [];
|
|
71376
|
+
}
|
|
71377
|
+
return withDirectives.flatMap((directive) => directive.arguments || []);
|
|
71378
|
+
}
|
|
71379
|
+
function fragmentArguments(config2, filepath, definition) {
|
|
71380
|
+
const directives = definition.directives?.filter(
|
|
71381
|
+
(directive) => directive.name.value === config2.argumentsDirective
|
|
71382
|
+
);
|
|
71383
|
+
if (!directives || directives.length === 0) {
|
|
71384
|
+
return [];
|
|
71385
|
+
}
|
|
71386
|
+
return directives.flatMap(
|
|
71387
|
+
(directive) => directive.arguments?.flatMap((arg) => {
|
|
71388
|
+
if (arg.value.kind !== "ObjectValue") {
|
|
71389
|
+
throw new HoudiniError({
|
|
71390
|
+
filepath,
|
|
71391
|
+
message: "values of @argument must be objects"
|
|
71392
|
+
});
|
|
71393
|
+
}
|
|
71394
|
+
const typeArg = arg.value.fields?.find((arg2) => arg2.name.value === "type")?.value;
|
|
71395
|
+
if (!typeArg || typeArg.kind !== "StringValue") {
|
|
71396
|
+
return [];
|
|
71397
|
+
}
|
|
71398
|
+
let type = typeArg.value;
|
|
71399
|
+
let name2 = arg.name.value;
|
|
71400
|
+
let required = false;
|
|
71401
|
+
let defaultValue = arg.value.fields?.find((arg2) => arg2.name.value === "default")?.value || null;
|
|
71402
|
+
if (type[type.length - 1] === "!") {
|
|
71403
|
+
type = type.slice(0, -1);
|
|
71404
|
+
required = true;
|
|
71405
|
+
defaultValue = null;
|
|
71406
|
+
}
|
|
71407
|
+
return [
|
|
71408
|
+
{
|
|
71409
|
+
name: name2,
|
|
71410
|
+
type,
|
|
71411
|
+
required,
|
|
71412
|
+
defaultValue
|
|
71413
|
+
}
|
|
71414
|
+
];
|
|
71415
|
+
}) || []
|
|
71416
|
+
);
|
|
71417
|
+
}
|
|
71418
|
+
function collectDefaultArgumentValues(config2, filepath, definition) {
|
|
71419
|
+
let result = {};
|
|
71420
|
+
for (const { name: name2, required, defaultValue } of fragmentArguments(
|
|
71421
|
+
config2,
|
|
71422
|
+
filepath,
|
|
71423
|
+
definition
|
|
71424
|
+
)) {
|
|
71425
|
+
if (required || !defaultValue) {
|
|
71426
|
+
continue;
|
|
71427
|
+
}
|
|
71428
|
+
result[name2] = defaultValue;
|
|
71429
|
+
}
|
|
71430
|
+
return result;
|
|
71431
|
+
}
|
|
71432
|
+
function collectWithArguments(config2, filepath, node, scope = {}) {
|
|
71433
|
+
const withArgs = withArguments(config2, node);
|
|
71434
|
+
if (withArgs.length === 0) {
|
|
71435
|
+
return { args: null, hash: "" };
|
|
71436
|
+
}
|
|
71437
|
+
let args = {};
|
|
71438
|
+
for (const arg of withArgs) {
|
|
71439
|
+
let value = arg.value;
|
|
71440
|
+
if (value.kind === GraphqlKinds2.VARIABLE) {
|
|
71441
|
+
if (!scope || !scope[value.name.value]) {
|
|
71442
|
+
throw new HoudiniError({
|
|
71443
|
+
filepath,
|
|
71444
|
+
message: "Encountered undefined variable: " + value.name.value
|
|
71445
|
+
});
|
|
71446
|
+
}
|
|
71447
|
+
value = scope[value.name.value];
|
|
71448
|
+
}
|
|
71449
|
+
args[arg.name.value] = {
|
|
71450
|
+
...value,
|
|
71451
|
+
loc: void 0
|
|
71452
|
+
};
|
|
71453
|
+
}
|
|
71454
|
+
return {
|
|
71455
|
+
args,
|
|
71456
|
+
hash: "_" + murmurHash(JSON.stringify(args))
|
|
71457
|
+
};
|
|
71458
|
+
}
|
|
71459
|
+
function operationScope(operation) {
|
|
71460
|
+
return operation.variableDefinitions?.reduce(
|
|
71461
|
+
(scope, definition) => ({
|
|
71462
|
+
...scope,
|
|
71463
|
+
[definition.variable.name.value]: {
|
|
71464
|
+
kind: "Variable",
|
|
71465
|
+
name: {
|
|
71466
|
+
kind: "Name",
|
|
71467
|
+
value: definition.variable.name.value
|
|
71468
|
+
}
|
|
71469
|
+
}
|
|
71470
|
+
}),
|
|
71471
|
+
{}
|
|
71472
|
+
) || {};
|
|
71473
|
+
}
|
|
71474
|
+
function fragmentArgumentsDefinitions(config2, filepath, definition) {
|
|
71475
|
+
const args = fragmentArguments(config2, filepath, definition);
|
|
71476
|
+
if (args.length === 0) {
|
|
71477
|
+
return [];
|
|
71478
|
+
}
|
|
71479
|
+
return args.map((arg) => {
|
|
71480
|
+
const innerType = {
|
|
71481
|
+
kind: "NamedType",
|
|
71482
|
+
name: {
|
|
71483
|
+
kind: "Name",
|
|
71484
|
+
value: arg.type
|
|
71485
|
+
}
|
|
71486
|
+
};
|
|
71487
|
+
return {
|
|
71488
|
+
kind: "VariableDefinition",
|
|
71489
|
+
type: arg.required ? innerType : {
|
|
71490
|
+
kind: "NonNullType",
|
|
71491
|
+
type: innerType
|
|
71492
|
+
},
|
|
71493
|
+
variable: {
|
|
71494
|
+
kind: "Variable",
|
|
71495
|
+
name: {
|
|
71496
|
+
kind: "Name",
|
|
71497
|
+
value: arg.name
|
|
71498
|
+
}
|
|
71499
|
+
},
|
|
71500
|
+
defaultValue: arg.defaultValue ?? void 0
|
|
71501
|
+
};
|
|
71502
|
+
});
|
|
71503
|
+
}
|
|
71504
|
+
|
|
71505
|
+
// src/codegen/generators/artifacts/indexFile.ts
|
|
71506
|
+
async function writeIndexFile(config2, docs) {
|
|
71507
|
+
const docsToGenerate = docs.filter((doc) => doc.generateArtifact).sort((a, b) => a.name.localeCompare(b.name));
|
|
71508
|
+
let body = config2.module === "esm" ? docsToGenerate.reduce(
|
|
71509
|
+
(content, doc) => content + `
|
|
71510
|
+
export { default as ${doc.name}} from './${doc.name}'`,
|
|
71511
|
+
""
|
|
71512
|
+
) : docsToGenerate.reduce(
|
|
71513
|
+
(content, doc) => content + `
|
|
71514
|
+
${exportDefaultFrom(`./${doc.name}`, doc.name)}`,
|
|
71515
|
+
cjsIndexFilePreamble
|
|
71516
|
+
);
|
|
71517
|
+
await fs_exports.writeFile(path_exports.join(config2.artifactDirectory, "index.js"), body);
|
|
71518
|
+
}
|
|
71519
|
+
|
|
71520
|
+
// src/codegen/generators/artifacts/inputs.ts
|
|
71521
|
+
var graphql6 = __toESM(require_graphql2(), 1);
|
|
71522
|
+
var recast3 = __toESM(require_main2(), 1);
|
|
71523
|
+
var AST3 = recast3.types.builders;
|
|
71524
|
+
function inputObject(config2, inputs) {
|
|
71525
|
+
const visitedTypes = /* @__PURE__ */ new Set();
|
|
71526
|
+
const inputObj = {
|
|
71527
|
+
fields: inputs.reduce((fields, input) => {
|
|
71528
|
+
const { type } = unwrapType(config2, input.type);
|
|
71529
|
+
return {
|
|
71530
|
+
...fields,
|
|
71531
|
+
[input.variable.name.value]: type.name
|
|
71532
|
+
};
|
|
71533
|
+
}, {}),
|
|
71534
|
+
types: {}
|
|
71535
|
+
};
|
|
71536
|
+
for (const input of inputs) {
|
|
71537
|
+
walkInputs(config2, visitedTypes, inputObj, input.type);
|
|
71538
|
+
}
|
|
71539
|
+
return inputObj;
|
|
71540
|
+
}
|
|
71541
|
+
function walkInputs(config2, visitedTypes, inputObj, rootType) {
|
|
71542
|
+
const { type } = unwrapType(config2, rootType);
|
|
71543
|
+
if (visitedTypes.has(type.name)) {
|
|
71544
|
+
return;
|
|
71545
|
+
}
|
|
71546
|
+
if (graphql6.isEnumType(type) || graphql6.isScalarType(type)) {
|
|
71547
|
+
return;
|
|
71548
|
+
}
|
|
71549
|
+
if (graphql6.isUnionType(type)) {
|
|
71550
|
+
return;
|
|
71551
|
+
}
|
|
71552
|
+
visitedTypes.add(type.name);
|
|
71553
|
+
inputObj.types[type.name] = Object.values(type.getFields()).reduce(
|
|
71554
|
+
(typeFields, field) => {
|
|
71555
|
+
const { type: fieldType } = unwrapType(config2, field.type);
|
|
71556
|
+
walkInputs(config2, visitedTypes, inputObj, fieldType);
|
|
71557
|
+
return {
|
|
71558
|
+
...typeFields,
|
|
71559
|
+
[field.name]: fieldType.toString()
|
|
71560
|
+
};
|
|
71561
|
+
},
|
|
71562
|
+
{}
|
|
71563
|
+
);
|
|
71564
|
+
}
|
|
71565
|
+
|
|
71566
|
+
// src/codegen/generators/artifacts/operations.ts
|
|
71567
|
+
var graphql8 = __toESM(require_graphql2(), 1);
|
|
71568
|
+
|
|
71569
|
+
// src/codegen/generators/artifacts/utils.ts
|
|
71570
|
+
var graphql7 = __toESM(require_graphql2(), 1);
|
|
71571
|
+
var recast4 = __toESM(require_main2(), 1);
|
|
71572
|
+
var AST4 = recast4.types.builders;
|
|
71573
|
+
function serializeValue(value) {
|
|
71574
|
+
if (Array.isArray(value)) {
|
|
71575
|
+
return AST4.arrayExpression(value.map(serializeValue));
|
|
71576
|
+
}
|
|
71577
|
+
if (typeof value === "object" && value !== null) {
|
|
71578
|
+
return AST4.objectExpression(
|
|
71579
|
+
Object.entries(value).filter(([, value2]) => typeof value2 !== "undefined").map(
|
|
71580
|
+
([key, value2]) => AST4.objectProperty(AST4.stringLiteral(key), serializeValue(value2))
|
|
71581
|
+
)
|
|
71582
|
+
);
|
|
71583
|
+
}
|
|
71584
|
+
if (typeof value === "string") {
|
|
71585
|
+
if (value.indexOf("\n") !== -1) {
|
|
71586
|
+
return AST4.templateLiteral(
|
|
71587
|
+
[AST4.templateElement({ raw: value, cooked: value }, true)],
|
|
71588
|
+
[]
|
|
71589
|
+
);
|
|
71590
|
+
}
|
|
71591
|
+
return AST4.stringLiteral(value);
|
|
71592
|
+
}
|
|
71593
|
+
return AST4.literal(value);
|
|
71594
|
+
}
|
|
71595
|
+
function deepMerge(filepath, ...targets) {
|
|
71596
|
+
if (typeof targets[0] !== "object") {
|
|
71597
|
+
const matches = targets.filter((val) => val !== targets[0]).length === 0;
|
|
71598
|
+
if (!matches) {
|
|
71599
|
+
throw new HoudiniError({ filepath, message: "could not merge: " + targets });
|
|
71600
|
+
}
|
|
71601
|
+
return targets[0];
|
|
71602
|
+
}
|
|
71603
|
+
if (Array.isArray(targets[0])) {
|
|
71604
|
+
return targets[0].concat(...targets.slice(1));
|
|
71605
|
+
}
|
|
71606
|
+
const fields = {};
|
|
71607
|
+
for (const target of targets) {
|
|
71608
|
+
for (const [key, value] of Object.entries(target)) {
|
|
71609
|
+
if (!fields[key]) {
|
|
71610
|
+
fields[key] = [];
|
|
71611
|
+
}
|
|
71612
|
+
fields[key].push(value);
|
|
71613
|
+
}
|
|
71614
|
+
}
|
|
71615
|
+
return Object.fromEntries(
|
|
71616
|
+
Object.entries(fields).map(([key, value]) => [key, deepMerge(filepath, ...value)])
|
|
71617
|
+
);
|
|
71618
|
+
}
|
|
71619
|
+
function convertValue(config2, val) {
|
|
71620
|
+
let value;
|
|
71621
|
+
let kind;
|
|
71622
|
+
if (val.kind === graphql7.Kind.INT) {
|
|
71623
|
+
value = parseInt(val.value, 10);
|
|
71624
|
+
kind = "Int";
|
|
71625
|
+
} else if (val.kind === graphql7.Kind.FLOAT) {
|
|
71626
|
+
value = parseFloat(val.value);
|
|
71627
|
+
kind = "Float";
|
|
71628
|
+
} else if (val.kind === graphql7.Kind.BOOLEAN) {
|
|
71629
|
+
value = val.value;
|
|
71630
|
+
kind = "Boolean";
|
|
71631
|
+
} else if (val.kind === graphql7.Kind.VARIABLE) {
|
|
71632
|
+
value = val.name.value;
|
|
71633
|
+
kind = "Variable";
|
|
71634
|
+
} else if (val.kind === graphql7.Kind.STRING) {
|
|
71635
|
+
value = val.value;
|
|
71636
|
+
kind = "String";
|
|
71637
|
+
}
|
|
71638
|
+
return { kind, value };
|
|
71639
|
+
}
|
|
71640
|
+
|
|
71641
|
+
// src/codegen/generators/artifacts/operations.ts
|
|
71642
|
+
function operationsByPath(config2, filepath, definition, filterTypes) {
|
|
71643
|
+
if (!definition) {
|
|
71644
|
+
return {};
|
|
71645
|
+
}
|
|
71646
|
+
const pathOperations = {};
|
|
71647
|
+
graphql8.visit(definition, {
|
|
71648
|
+
FragmentSpread(node, _, __, ___, ancestors) {
|
|
71649
|
+
if (!config2.isListFragment(node.name.value)) {
|
|
71650
|
+
return;
|
|
71651
|
+
}
|
|
71652
|
+
const path2 = ancestorKey(ancestors);
|
|
71653
|
+
if (!pathOperations[path2]) {
|
|
71654
|
+
pathOperations[path2] = [];
|
|
71655
|
+
}
|
|
71656
|
+
pathOperations[path2].push(
|
|
71657
|
+
operationObject({
|
|
71283
71658
|
config: config2,
|
|
71284
71659
|
filepath,
|
|
71285
71660
|
listName: config2.listNameFromFragment(node.name.value),
|
|
@@ -71428,7 +71803,7 @@ function ancestorKey(ancestors) {
|
|
|
71428
71803
|
}
|
|
71429
71804
|
|
|
71430
71805
|
// src/codegen/generators/artifacts/selection.ts
|
|
71431
|
-
var
|
|
71806
|
+
var graphql13 = __toESM(require_graphql2(), 1);
|
|
71432
71807
|
|
|
71433
71808
|
// ../../node_modules/.pnpm/@kitql+helper@0.5.0/node_modules/@kitql/helper/index.mjs
|
|
71434
71809
|
var config = {
|
|
@@ -71468,16 +71843,16 @@ function logYellow(str) {
|
|
|
71468
71843
|
}
|
|
71469
71844
|
|
|
71470
71845
|
// src/codegen/transforms/list.ts
|
|
71471
|
-
var
|
|
71846
|
+
var graphql11 = __toESM(require_graphql2(), 1);
|
|
71472
71847
|
|
|
71473
71848
|
// src/codegen/utils/objectIdentificationSelection.ts
|
|
71474
|
-
var
|
|
71849
|
+
var graphql9 = __toESM(require_graphql2(), 1);
|
|
71475
71850
|
var objectIdentificationSelection = (config2, type) => {
|
|
71476
71851
|
return config2.keyFieldsForType(type.name).map((key) => {
|
|
71477
71852
|
return {
|
|
71478
|
-
kind:
|
|
71853
|
+
kind: graphql9.Kind.FIELD,
|
|
71479
71854
|
name: {
|
|
71480
|
-
kind:
|
|
71855
|
+
kind: graphql9.Kind.NAME,
|
|
71481
71856
|
value: key
|
|
71482
71857
|
}
|
|
71483
71858
|
};
|
|
@@ -71485,7 +71860,7 @@ var objectIdentificationSelection = (config2, type) => {
|
|
|
71485
71860
|
};
|
|
71486
71861
|
|
|
71487
71862
|
// src/codegen/transforms/paginate.ts
|
|
71488
|
-
var
|
|
71863
|
+
var graphql10 = __toESM(require_graphql2(), 1);
|
|
71489
71864
|
async function paginate(config2, documents) {
|
|
71490
71865
|
const newDocs = [];
|
|
71491
71866
|
for (const doc of documents) {
|
|
@@ -71518,7 +71893,7 @@ async function paginate(config2, documents) {
|
|
|
71518
71893
|
};
|
|
71519
71894
|
let cursorType = "String";
|
|
71520
71895
|
let paginationPath = [];
|
|
71521
|
-
doc.document =
|
|
71896
|
+
doc.document = graphql10.visit(doc.document, {
|
|
71522
71897
|
Field(node, _, __, ___, ancestors) {
|
|
71523
71898
|
const paginateDirective = node.directives?.find(
|
|
71524
71899
|
(directive) => directive.name.value === config2.paginateDirective
|
|
@@ -71545,7 +71920,7 @@ async function paginate(config2, documents) {
|
|
|
71545
71920
|
flags.offset.enabled = offsetPagination;
|
|
71546
71921
|
flags.limit.enabled = offsetPagination;
|
|
71547
71922
|
paginationPath = ancestors.filter(
|
|
71548
|
-
(ancestor) => !Array.isArray(ancestor) && ancestor.kind ===
|
|
71923
|
+
(ancestor) => !Array.isArray(ancestor) && ancestor.kind === graphql10.Kind.FIELD
|
|
71549
71924
|
).concat(node).map((field) => field.alias?.value || field.name.value);
|
|
71550
71925
|
return {
|
|
71551
71926
|
...node,
|
|
@@ -71566,7 +71941,7 @@ async function paginate(config2, documents) {
|
|
|
71566
71941
|
refetchUpdate = "prepend" /* prepend */;
|
|
71567
71942
|
}
|
|
71568
71943
|
let fragment = "";
|
|
71569
|
-
doc.document =
|
|
71944
|
+
doc.document = graphql10.visit(doc.document, {
|
|
71570
71945
|
OperationDefinition(node) {
|
|
71571
71946
|
if (node.operation !== "query") {
|
|
71572
71947
|
throw new HoudiniError({
|
|
@@ -71620,9 +71995,9 @@ async function paginate(config2, documents) {
|
|
|
71620
71995
|
directives: [
|
|
71621
71996
|
...node.directives || [],
|
|
71622
71997
|
{
|
|
71623
|
-
kind:
|
|
71998
|
+
kind: graphql10.Kind.DIRECTIVE,
|
|
71624
71999
|
name: {
|
|
71625
|
-
kind:
|
|
72000
|
+
kind: graphql10.Kind.NAME,
|
|
71626
72001
|
value: config2.argumentsDirective
|
|
71627
72002
|
}
|
|
71628
72003
|
}
|
|
@@ -71685,16 +72060,16 @@ async function paginate(config2, documents) {
|
|
|
71685
72060
|
const paginationArgs = Object.entries(flags).filter(([_, { enabled }]) => enabled).map(([key, value]) => ({ name: key, ...value }));
|
|
71686
72061
|
const fragmentSpreadSelection = [
|
|
71687
72062
|
{
|
|
71688
|
-
kind:
|
|
72063
|
+
kind: graphql10.Kind.FRAGMENT_SPREAD,
|
|
71689
72064
|
name: {
|
|
71690
|
-
kind:
|
|
72065
|
+
kind: graphql10.Kind.NAME,
|
|
71691
72066
|
value: fragmentName
|
|
71692
72067
|
},
|
|
71693
72068
|
directives: [
|
|
71694
72069
|
{
|
|
71695
|
-
kind:
|
|
72070
|
+
kind: graphql10.Kind.DIRECTIVE,
|
|
71696
72071
|
name: {
|
|
71697
|
-
kind:
|
|
72072
|
+
kind: graphql10.Kind.NAME,
|
|
71698
72073
|
value: config2.withDirective
|
|
71699
72074
|
},
|
|
71700
72075
|
["arguments"]: paginationArgs.map(
|
|
@@ -71722,29 +72097,29 @@ async function paginate(config2, documents) {
|
|
|
71722
72097
|
});
|
|
71723
72098
|
const typeConfig = config2.typeConfig?.[fragment];
|
|
71724
72099
|
const queryDoc = {
|
|
71725
|
-
kind:
|
|
72100
|
+
kind: graphql10.Kind.DOCUMENT,
|
|
71726
72101
|
definitions: [
|
|
71727
72102
|
{
|
|
71728
|
-
kind:
|
|
72103
|
+
kind: graphql10.Kind.OPERATION_DEFINITION,
|
|
71729
72104
|
name: {
|
|
71730
|
-
kind:
|
|
72105
|
+
kind: graphql10.Kind.NAME,
|
|
71731
72106
|
value: refetchQueryName
|
|
71732
72107
|
},
|
|
71733
72108
|
operation: "query",
|
|
71734
72109
|
variableDefinitions: paginationArgs.map(
|
|
71735
72110
|
(arg) => ({
|
|
71736
|
-
kind:
|
|
72111
|
+
kind: graphql10.Kind.VARIABLE_DEFINITION,
|
|
71737
72112
|
type: {
|
|
71738
|
-
kind:
|
|
72113
|
+
kind: graphql10.Kind.NAMED_TYPE,
|
|
71739
72114
|
name: {
|
|
71740
|
-
kind:
|
|
72115
|
+
kind: graphql10.Kind.NAME,
|
|
71741
72116
|
value: arg.type
|
|
71742
72117
|
}
|
|
71743
72118
|
},
|
|
71744
72119
|
variable: {
|
|
71745
|
-
kind:
|
|
72120
|
+
kind: graphql10.Kind.VARIABLE,
|
|
71746
72121
|
name: {
|
|
71747
|
-
kind:
|
|
72122
|
+
kind: graphql10.Kind.NAME,
|
|
71748
72123
|
value: arg.name
|
|
71749
72124
|
}
|
|
71750
72125
|
},
|
|
@@ -71756,12 +72131,12 @@ async function paginate(config2, documents) {
|
|
|
71756
72131
|
).concat(
|
|
71757
72132
|
!nodeQuery ? [] : keys.map(
|
|
71758
72133
|
(key) => ({
|
|
71759
|
-
kind:
|
|
72134
|
+
kind: graphql10.Kind.VARIABLE_DEFINITION,
|
|
71760
72135
|
type: key.type,
|
|
71761
72136
|
variable: {
|
|
71762
|
-
kind:
|
|
72137
|
+
kind: graphql10.Kind.VARIABLE,
|
|
71763
72138
|
name: {
|
|
71764
|
-
kind:
|
|
72139
|
+
kind: graphql10.Kind.NAME,
|
|
71765
72140
|
value: key.name
|
|
71766
72141
|
}
|
|
71767
72142
|
}
|
|
@@ -71769,42 +72144,42 @@ async function paginate(config2, documents) {
|
|
|
71769
72144
|
)
|
|
71770
72145
|
),
|
|
71771
72146
|
selectionSet: {
|
|
71772
|
-
kind:
|
|
72147
|
+
kind: graphql10.Kind.SELECTION_SET,
|
|
71773
72148
|
selections: !nodeQuery ? fragmentSpreadSelection : [
|
|
71774
72149
|
{
|
|
71775
|
-
kind:
|
|
72150
|
+
kind: graphql10.Kind.FIELD,
|
|
71776
72151
|
name: {
|
|
71777
|
-
kind:
|
|
72152
|
+
kind: graphql10.Kind.NAME,
|
|
71778
72153
|
value: typeConfig?.resolve?.queryField || "node"
|
|
71779
72154
|
},
|
|
71780
72155
|
["arguments"]: keys.map((key) => ({
|
|
71781
|
-
kind:
|
|
72156
|
+
kind: graphql10.Kind.ARGUMENT,
|
|
71782
72157
|
name: {
|
|
71783
|
-
kind:
|
|
72158
|
+
kind: graphql10.Kind.NAME,
|
|
71784
72159
|
value: key.name
|
|
71785
72160
|
},
|
|
71786
72161
|
value: {
|
|
71787
|
-
kind:
|
|
72162
|
+
kind: graphql10.Kind.VARIABLE,
|
|
71788
72163
|
name: {
|
|
71789
|
-
kind:
|
|
72164
|
+
kind: graphql10.Kind.NAME,
|
|
71790
72165
|
value: key.name
|
|
71791
72166
|
}
|
|
71792
72167
|
}
|
|
71793
72168
|
})),
|
|
71794
72169
|
selectionSet: {
|
|
71795
|
-
kind:
|
|
72170
|
+
kind: graphql10.Kind.SELECTION_SET,
|
|
71796
72171
|
selections: [
|
|
71797
72172
|
{
|
|
71798
|
-
kind:
|
|
72173
|
+
kind: graphql10.Kind.FIELD,
|
|
71799
72174
|
name: {
|
|
71800
|
-
kind:
|
|
72175
|
+
kind: graphql10.Kind.NAME,
|
|
71801
72176
|
value: "__typename"
|
|
71802
72177
|
}
|
|
71803
72178
|
},
|
|
71804
72179
|
...(typeConfig?.keys || ["id"]).map((key) => ({
|
|
71805
|
-
kind:
|
|
72180
|
+
kind: graphql10.Kind.FIELD,
|
|
71806
72181
|
name: {
|
|
71807
|
-
kind:
|
|
72182
|
+
kind: graphql10.Kind.NAME,
|
|
71808
72183
|
value: key
|
|
71809
72184
|
}
|
|
71810
72185
|
})),
|
|
@@ -71866,15 +72241,15 @@ function replaceArgumentsWithVariables(args, flags) {
|
|
|
71866
72241
|
}
|
|
71867
72242
|
function variableAsArgument(name2, variable) {
|
|
71868
72243
|
return {
|
|
71869
|
-
kind:
|
|
72244
|
+
kind: graphql10.Kind.ARGUMENT,
|
|
71870
72245
|
name: {
|
|
71871
|
-
kind:
|
|
72246
|
+
kind: graphql10.Kind.NAME,
|
|
71872
72247
|
value: name2
|
|
71873
72248
|
},
|
|
71874
72249
|
value: {
|
|
71875
|
-
kind:
|
|
72250
|
+
kind: graphql10.Kind.VARIABLE,
|
|
71876
72251
|
name: {
|
|
71877
|
-
kind:
|
|
72252
|
+
kind: graphql10.Kind.NAME,
|
|
71878
72253
|
value: variable ?? name2
|
|
71879
72254
|
}
|
|
71880
72255
|
}
|
|
@@ -71882,18 +72257,18 @@ function variableAsArgument(name2, variable) {
|
|
|
71882
72257
|
}
|
|
71883
72258
|
function staticVariableDefinition(name2, type, defaultValue, variableName) {
|
|
71884
72259
|
return {
|
|
71885
|
-
kind:
|
|
72260
|
+
kind: graphql10.Kind.VARIABLE_DEFINITION,
|
|
71886
72261
|
type: {
|
|
71887
|
-
kind:
|
|
72262
|
+
kind: graphql10.Kind.NAMED_TYPE,
|
|
71888
72263
|
name: {
|
|
71889
|
-
kind:
|
|
72264
|
+
kind: graphql10.Kind.NAME,
|
|
71890
72265
|
value: type
|
|
71891
72266
|
}
|
|
71892
72267
|
},
|
|
71893
72268
|
variable: {
|
|
71894
|
-
kind:
|
|
72269
|
+
kind: graphql10.Kind.VARIABLE,
|
|
71895
72270
|
name: {
|
|
71896
|
-
kind:
|
|
72271
|
+
kind: graphql10.Kind.NAME,
|
|
71897
72272
|
value: variableName ?? name2
|
|
71898
72273
|
}
|
|
71899
72274
|
},
|
|
@@ -71905,9 +72280,9 @@ function staticVariableDefinition(name2, type, defaultValue, variableName) {
|
|
|
71905
72280
|
}
|
|
71906
72281
|
function argumentNode(name2, value) {
|
|
71907
72282
|
return {
|
|
71908
|
-
kind:
|
|
72283
|
+
kind: graphql10.Kind.ARGUMENT,
|
|
71909
72284
|
name: {
|
|
71910
|
-
kind:
|
|
72285
|
+
kind: graphql10.Kind.NAME,
|
|
71911
72286
|
value: name2
|
|
71912
72287
|
},
|
|
71913
72288
|
value: objectNode(value)
|
|
@@ -71915,16 +72290,16 @@ function argumentNode(name2, value) {
|
|
|
71915
72290
|
}
|
|
71916
72291
|
function objectNode([type, defaultValue]) {
|
|
71917
72292
|
const node = {
|
|
71918
|
-
kind:
|
|
72293
|
+
kind: graphql10.Kind.OBJECT,
|
|
71919
72294
|
fields: [
|
|
71920
72295
|
{
|
|
71921
|
-
kind:
|
|
72296
|
+
kind: graphql10.Kind.OBJECT_FIELD,
|
|
71922
72297
|
name: {
|
|
71923
|
-
kind:
|
|
72298
|
+
kind: graphql10.Kind.NAME,
|
|
71924
72299
|
value: "type"
|
|
71925
72300
|
},
|
|
71926
72301
|
value: {
|
|
71927
|
-
kind:
|
|
72302
|
+
kind: graphql10.Kind.STRING,
|
|
71928
72303
|
value: type
|
|
71929
72304
|
}
|
|
71930
72305
|
}
|
|
@@ -71932,8 +72307,8 @@ function objectNode([type, defaultValue]) {
|
|
|
71932
72307
|
};
|
|
71933
72308
|
if (defaultValue) {
|
|
71934
72309
|
node.fields.push({
|
|
71935
|
-
kind:
|
|
71936
|
-
name: { kind:
|
|
72310
|
+
kind: graphql10.Kind.OBJECT_FIELD,
|
|
72311
|
+
name: { kind: graphql10.Kind.NAME, value: "default" },
|
|
71937
72312
|
value: {
|
|
71938
72313
|
kind: typeof defaultValue === "number" ? "IntValue" : "StringValue",
|
|
71939
72314
|
value: defaultValue.toString()
|
|
@@ -71944,34 +72319,34 @@ function objectNode([type, defaultValue]) {
|
|
|
71944
72319
|
}
|
|
71945
72320
|
var pageInfoSelection = [
|
|
71946
72321
|
{
|
|
71947
|
-
kind:
|
|
72322
|
+
kind: graphql10.Kind.FIELD,
|
|
71948
72323
|
name: {
|
|
71949
|
-
kind:
|
|
72324
|
+
kind: graphql10.Kind.NAME,
|
|
71950
72325
|
value: "edges"
|
|
71951
72326
|
},
|
|
71952
72327
|
selectionSet: {
|
|
71953
|
-
kind:
|
|
72328
|
+
kind: graphql10.Kind.SELECTION_SET,
|
|
71954
72329
|
selections: [
|
|
71955
72330
|
{
|
|
71956
|
-
kind:
|
|
72331
|
+
kind: graphql10.Kind.FIELD,
|
|
71957
72332
|
name: {
|
|
71958
|
-
kind:
|
|
72333
|
+
kind: graphql10.Kind.NAME,
|
|
71959
72334
|
value: "cursor"
|
|
71960
72335
|
}
|
|
71961
72336
|
},
|
|
71962
72337
|
{
|
|
71963
|
-
kind:
|
|
72338
|
+
kind: graphql10.Kind.FIELD,
|
|
71964
72339
|
name: {
|
|
71965
|
-
kind:
|
|
72340
|
+
kind: graphql10.Kind.NAME,
|
|
71966
72341
|
value: "node"
|
|
71967
72342
|
},
|
|
71968
72343
|
selectionSet: {
|
|
71969
|
-
kind:
|
|
72344
|
+
kind: graphql10.Kind.SELECTION_SET,
|
|
71970
72345
|
selections: [
|
|
71971
72346
|
{
|
|
71972
|
-
kind:
|
|
72347
|
+
kind: graphql10.Kind.FIELD,
|
|
71973
72348
|
name: {
|
|
71974
|
-
kind:
|
|
72349
|
+
kind: graphql10.Kind.NAME,
|
|
71975
72350
|
value: "__typename"
|
|
71976
72351
|
}
|
|
71977
72352
|
}
|
|
@@ -71982,39 +72357,39 @@ var pageInfoSelection = [
|
|
|
71982
72357
|
}
|
|
71983
72358
|
},
|
|
71984
72359
|
{
|
|
71985
|
-
kind:
|
|
72360
|
+
kind: graphql10.Kind.FIELD,
|
|
71986
72361
|
name: {
|
|
71987
|
-
kind:
|
|
72362
|
+
kind: graphql10.Kind.NAME,
|
|
71988
72363
|
value: "pageInfo"
|
|
71989
72364
|
},
|
|
71990
72365
|
selectionSet: {
|
|
71991
|
-
kind:
|
|
72366
|
+
kind: graphql10.Kind.SELECTION_SET,
|
|
71992
72367
|
selections: [
|
|
71993
72368
|
{
|
|
71994
|
-
kind:
|
|
72369
|
+
kind: graphql10.Kind.FIELD,
|
|
71995
72370
|
name: {
|
|
71996
|
-
kind:
|
|
72371
|
+
kind: graphql10.Kind.NAME,
|
|
71997
72372
|
value: "hasPreviousPage"
|
|
71998
72373
|
}
|
|
71999
72374
|
},
|
|
72000
72375
|
{
|
|
72001
|
-
kind:
|
|
72376
|
+
kind: graphql10.Kind.FIELD,
|
|
72002
72377
|
name: {
|
|
72003
|
-
kind:
|
|
72378
|
+
kind: graphql10.Kind.NAME,
|
|
72004
72379
|
value: "hasNextPage"
|
|
72005
72380
|
}
|
|
72006
72381
|
},
|
|
72007
72382
|
{
|
|
72008
|
-
kind:
|
|
72383
|
+
kind: graphql10.Kind.FIELD,
|
|
72009
72384
|
name: {
|
|
72010
|
-
kind:
|
|
72385
|
+
kind: graphql10.Kind.NAME,
|
|
72011
72386
|
value: "startCursor"
|
|
72012
72387
|
}
|
|
72013
72388
|
},
|
|
72014
72389
|
{
|
|
72015
|
-
kind:
|
|
72390
|
+
kind: graphql10.Kind.FIELD,
|
|
72016
72391
|
name: {
|
|
72017
|
-
kind:
|
|
72392
|
+
kind: graphql10.Kind.NAME,
|
|
72018
72393
|
value: "endCursor"
|
|
72019
72394
|
}
|
|
72020
72395
|
}
|
|
@@ -72028,15 +72403,15 @@ async function addListFragments(config2, documents) {
|
|
|
72028
72403
|
const lists = {};
|
|
72029
72404
|
const errors = [];
|
|
72030
72405
|
for (const doc of documents) {
|
|
72031
|
-
doc.document =
|
|
72406
|
+
doc.document = graphql11.visit(doc.document, {
|
|
72032
72407
|
Directive(node, key, parent, path2, ancestors) {
|
|
72033
72408
|
if ([config2.listDirective, config2.paginateDirective].includes(node.name.value)) {
|
|
72034
72409
|
const nameArg = node.arguments?.find((arg) => arg.name.value === "name");
|
|
72035
72410
|
let error = {
|
|
72036
|
-
...new
|
|
72411
|
+
...new graphql11.GraphQLError(
|
|
72037
72412
|
"",
|
|
72038
72413
|
node,
|
|
72039
|
-
new
|
|
72414
|
+
new graphql11.Source(""),
|
|
72040
72415
|
node.loc ? [node.loc.start, node.loc.end] : null,
|
|
72041
72416
|
path2
|
|
72042
72417
|
),
|
|
@@ -72088,7 +72463,7 @@ async function addListFragments(config2, documents) {
|
|
|
72088
72463
|
{
|
|
72089
72464
|
kind: "Argument",
|
|
72090
72465
|
name: {
|
|
72091
|
-
kind:
|
|
72466
|
+
kind: graphql11.Kind.NAME,
|
|
72092
72467
|
value: "connection"
|
|
72093
72468
|
},
|
|
72094
72469
|
value: {
|
|
@@ -72138,7 +72513,7 @@ async function addListFragments(config2, documents) {
|
|
|
72138
72513
|
const validDeletes = [
|
|
72139
72514
|
...new Set(
|
|
72140
72515
|
Object.values(lists).map(({ type }) => {
|
|
72141
|
-
if (!(type instanceof
|
|
72516
|
+
if (!(type instanceof graphql11.GraphQLObjectType)) {
|
|
72142
72517
|
return "";
|
|
72143
72518
|
}
|
|
72144
72519
|
if (config2.keyFieldsForType(type.name).length !== 1) {
|
|
@@ -72152,7 +72527,7 @@ async function addListFragments(config2, documents) {
|
|
|
72152
72527
|
return;
|
|
72153
72528
|
}
|
|
72154
72529
|
const generatedDoc = {
|
|
72155
|
-
kind:
|
|
72530
|
+
kind: graphql11.Kind.DOCUMENT,
|
|
72156
72531
|
definitions: Object.entries(lists).flatMap(
|
|
72157
72532
|
([name2, { selection: selection2, type }]) => {
|
|
72158
72533
|
const schemaType = config2.schema.getType(type.name);
|
|
@@ -72160,7 +72535,7 @@ async function addListFragments(config2, documents) {
|
|
|
72160
72535
|
throw new HoudiniError({ message: "Lists must have a selection" });
|
|
72161
72536
|
}
|
|
72162
72537
|
const fragmentSelection = {
|
|
72163
|
-
kind:
|
|
72538
|
+
kind: graphql11.Kind.SELECTION_SET,
|
|
72164
72539
|
selections: [...selection2.selections]
|
|
72165
72540
|
};
|
|
72166
72541
|
if (schemaType && fragmentSelection && !fragmentSelection?.selections.find(
|
|
@@ -72175,14 +72550,14 @@ async function addListFragments(config2, documents) {
|
|
|
72175
72550
|
{
|
|
72176
72551
|
name: {
|
|
72177
72552
|
value: config2.listInsertFragment(name2),
|
|
72178
|
-
kind:
|
|
72553
|
+
kind: graphql11.Kind.NAME
|
|
72179
72554
|
},
|
|
72180
|
-
kind:
|
|
72555
|
+
kind: graphql11.Kind.FRAGMENT_DEFINITION,
|
|
72181
72556
|
selectionSet: fragmentSelection,
|
|
72182
72557
|
typeCondition: {
|
|
72183
|
-
kind:
|
|
72558
|
+
kind: graphql11.Kind.NAMED_TYPE,
|
|
72184
72559
|
name: {
|
|
72185
|
-
kind:
|
|
72560
|
+
kind: graphql11.Kind.NAME,
|
|
72186
72561
|
value: type.name
|
|
72187
72562
|
}
|
|
72188
72563
|
}
|
|
@@ -72190,32 +72565,32 @@ async function addListFragments(config2, documents) {
|
|
|
72190
72565
|
{
|
|
72191
72566
|
name: {
|
|
72192
72567
|
value: config2.listToggleFragment(name2),
|
|
72193
|
-
kind:
|
|
72568
|
+
kind: graphql11.Kind.NAME
|
|
72194
72569
|
},
|
|
72195
|
-
kind:
|
|
72570
|
+
kind: graphql11.Kind.FRAGMENT_DEFINITION,
|
|
72196
72571
|
selectionSet: fragmentSelection,
|
|
72197
72572
|
typeCondition: {
|
|
72198
|
-
kind:
|
|
72573
|
+
kind: graphql11.Kind.NAMED_TYPE,
|
|
72199
72574
|
name: {
|
|
72200
|
-
kind:
|
|
72575
|
+
kind: graphql11.Kind.NAME,
|
|
72201
72576
|
value: type.name
|
|
72202
72577
|
}
|
|
72203
72578
|
}
|
|
72204
72579
|
},
|
|
72205
72580
|
{
|
|
72206
|
-
kind:
|
|
72581
|
+
kind: graphql11.Kind.FRAGMENT_DEFINITION,
|
|
72207
72582
|
name: {
|
|
72208
72583
|
value: config2.listRemoveFragment(name2),
|
|
72209
|
-
kind:
|
|
72584
|
+
kind: graphql11.Kind.NAME
|
|
72210
72585
|
},
|
|
72211
72586
|
selectionSet: {
|
|
72212
|
-
kind:
|
|
72587
|
+
kind: graphql11.Kind.SELECTION_SET,
|
|
72213
72588
|
selections: [...objectIdentificationSelection(config2, type)]
|
|
72214
72589
|
},
|
|
72215
72590
|
typeCondition: {
|
|
72216
|
-
kind:
|
|
72591
|
+
kind: graphql11.Kind.NAMED_TYPE,
|
|
72217
72592
|
name: {
|
|
72218
|
-
kind:
|
|
72593
|
+
kind: graphql11.Kind.NAME,
|
|
72219
72594
|
value: type.name
|
|
72220
72595
|
}
|
|
72221
72596
|
}
|
|
@@ -72224,14 +72599,14 @@ async function addListFragments(config2, documents) {
|
|
|
72224
72599
|
}
|
|
72225
72600
|
).concat(
|
|
72226
72601
|
...validDeletes.map((typeName) => ({
|
|
72227
|
-
kind:
|
|
72602
|
+
kind: graphql11.Kind.DIRECTIVE_DEFINITION,
|
|
72228
72603
|
name: {
|
|
72229
|
-
kind:
|
|
72604
|
+
kind: graphql11.Kind.NAME,
|
|
72230
72605
|
value: config2.listDeleteDirective(typeName)
|
|
72231
72606
|
},
|
|
72232
72607
|
locations: [
|
|
72233
72608
|
{
|
|
72234
|
-
kind:
|
|
72609
|
+
kind: graphql11.Kind.NAME,
|
|
72235
72610
|
value: "FIELD"
|
|
72236
72611
|
}
|
|
72237
72612
|
],
|
|
@@ -72239,8 +72614,8 @@ async function addListFragments(config2, documents) {
|
|
|
72239
72614
|
}))
|
|
72240
72615
|
)
|
|
72241
72616
|
};
|
|
72242
|
-
config2.newSchema += "\n" + generatedDoc.definitions.filter((c) => c.kind !== "FragmentDefinition").map(
|
|
72243
|
-
config2.newDocuments += "\n" + generatedDoc.definitions.filter((c) => c.kind === "FragmentDefinition").map(
|
|
72617
|
+
config2.newSchema += "\n" + generatedDoc.definitions.filter((c) => c.kind !== "FragmentDefinition").map(graphql11.print).join("\n\n");
|
|
72618
|
+
config2.newDocuments += "\n" + generatedDoc.definitions.filter((c) => c.kind === "FragmentDefinition").map(graphql11.print).join("\n\n");
|
|
72244
72619
|
documents.push({
|
|
72245
72620
|
name: "generated::lists",
|
|
72246
72621
|
kind: "HoudiniFragment" /* Fragment */,
|
|
@@ -72325,11 +72700,11 @@ var nodeNotDefinedMessage = (config2) => `Looks like you are trying to use the $
|
|
|
72325
72700
|
For more information, visit this link: ${siteURL}/guides/pagination`;
|
|
72326
72701
|
|
|
72327
72702
|
// src/codegen/generators/artifacts/fieldKey.ts
|
|
72328
|
-
var
|
|
72703
|
+
var graphql12 = __toESM(require_graphql2(), 1);
|
|
72329
72704
|
function fieldKey(config2, field) {
|
|
72330
72705
|
const attributeName = field.alias?.value || field.name.value;
|
|
72331
|
-
const printed =
|
|
72332
|
-
const secondParse =
|
|
72706
|
+
const printed = graphql12.print(field);
|
|
72707
|
+
const secondParse = graphql12.parse(`{${printed}}`).definitions[0].selectionSet.selections[0];
|
|
72333
72708
|
const paginated = !!field.directives?.find(
|
|
72334
72709
|
(directive) => directive.name.value === config2.paginateDirective
|
|
72335
72710
|
);
|
|
@@ -72424,8 +72799,8 @@ function selection({
|
|
|
72424
72799
|
const typeConditionName = field.typeCondition.name.value;
|
|
72425
72800
|
const typeCondition = config2.schema.getType(typeConditionName);
|
|
72426
72801
|
const possibleTypes = [];
|
|
72427
|
-
if (!
|
|
72428
|
-
} else if (
|
|
72802
|
+
if (!graphql13.isAbstractType(typeCondition)) {
|
|
72803
|
+
} else if (graphql13.isAbstractType(parentType)) {
|
|
72429
72804
|
const possibleParentTypes = config2.schema.getPossibleTypes(parentType).map((type) => type.name);
|
|
72430
72805
|
for (const possible of config2.schema.getPossibleTypes(typeCondition)) {
|
|
72431
72806
|
if (possibleParentTypes.includes(possible.name)) {
|
|
@@ -72473,7 +72848,7 @@ function selection({
|
|
|
72473
72848
|
} else {
|
|
72474
72849
|
let typeRef = type.getFields()[field.name.value].type;
|
|
72475
72850
|
fieldType = getRootType(typeRef);
|
|
72476
|
-
nullable = !
|
|
72851
|
+
nullable = !graphql13.isNonNullType(typeRef);
|
|
72477
72852
|
}
|
|
72478
72853
|
const typeName = fieldType.toString();
|
|
72479
72854
|
const pathSoFar = path2.concat(attributeName);
|
|
@@ -72538,7 +72913,7 @@ function selection({
|
|
|
72538
72913
|
{}
|
|
72539
72914
|
);
|
|
72540
72915
|
}
|
|
72541
|
-
if (
|
|
72916
|
+
if (graphql13.isInterfaceType(fieldType) || graphql13.isUnionType(fieldType)) {
|
|
72542
72917
|
fieldObj.abstract = true;
|
|
72543
72918
|
}
|
|
72544
72919
|
object.fields = {
|
|
@@ -72595,7 +72970,7 @@ function artifactGenerator(stats) {
|
|
|
72595
72970
|
return async function(config2, docs) {
|
|
72596
72971
|
const filterTypes = {};
|
|
72597
72972
|
for (const doc of docs) {
|
|
72598
|
-
|
|
72973
|
+
graphql14.visit(doc.document, {
|
|
72599
72974
|
Directive(node, _, __, ___, ancestors) {
|
|
72600
72975
|
if (node.name.value !== config2.listDirective) {
|
|
72601
72976
|
return;
|
|
@@ -72654,7 +73029,7 @@ function artifactGenerator(stats) {
|
|
|
72654
73029
|
return;
|
|
72655
73030
|
}
|
|
72656
73031
|
const usedVariableNames = /* @__PURE__ */ new Set();
|
|
72657
|
-
let documentWithoutInternalDirectives =
|
|
73032
|
+
let documentWithoutInternalDirectives = graphql14.visit(document, {
|
|
72658
73033
|
Directive(node) {
|
|
72659
73034
|
if (config2.isInternalDirective(node)) {
|
|
72660
73035
|
return null;
|
|
@@ -72667,7 +73042,7 @@ function artifactGenerator(stats) {
|
|
|
72667
73042
|
}
|
|
72668
73043
|
}
|
|
72669
73044
|
});
|
|
72670
|
-
let documentWithoutExtraVariables =
|
|
73045
|
+
let documentWithoutExtraVariables = graphql14.visit(
|
|
72671
73046
|
documentWithoutInternalDirectives,
|
|
72672
73047
|
{
|
|
72673
73048
|
VariableDefinition(variableDefinitionNode) {
|
|
@@ -72678,13 +73053,13 @@ function artifactGenerator(stats) {
|
|
|
72678
73053
|
}
|
|
72679
73054
|
}
|
|
72680
73055
|
);
|
|
72681
|
-
let rawString =
|
|
73056
|
+
let rawString = graphql14.print(documentWithoutExtraVariables);
|
|
72682
73057
|
let docKind = doc.kind;
|
|
72683
73058
|
const operations = document.definitions.filter(
|
|
72684
|
-
({ kind }) => kind ===
|
|
73059
|
+
({ kind }) => kind === graphql14.Kind.OPERATION_DEFINITION
|
|
72685
73060
|
);
|
|
72686
73061
|
const fragments = document.definitions.filter(
|
|
72687
|
-
({ kind }) => kind ===
|
|
73062
|
+
({ kind }) => kind === graphql14.Kind.FRAGMENT_DEFINITION
|
|
72688
73063
|
);
|
|
72689
73064
|
let rootType = "";
|
|
72690
73065
|
let selectionSet;
|
|
@@ -72717,7 +73092,13 @@ function artifactGenerator(stats) {
|
|
|
72717
73092
|
rootType = matchingFragment.typeCondition.name.value;
|
|
72718
73093
|
selectionSet = matchingFragment.selectionSet;
|
|
72719
73094
|
}
|
|
72720
|
-
|
|
73095
|
+
let inputs = operations[0]?.variableDefinitions;
|
|
73096
|
+
let directive = fragments[0]?.directives?.find(
|
|
73097
|
+
(directive2) => directive2.name.value === config2.argumentsDirective
|
|
73098
|
+
);
|
|
73099
|
+
if (docKind === "HoudiniFragment" /* Fragment */ && directive) {
|
|
73100
|
+
inputs = fragmentArgumentsDefinitions(config2, doc.filename, fragments[0]);
|
|
73101
|
+
}
|
|
72721
73102
|
const mergedSelection = flattenSelections({
|
|
72722
73103
|
config: config2,
|
|
72723
73104
|
filepath: doc.filename,
|
|
@@ -72778,7 +73159,7 @@ function artifactGenerator(stats) {
|
|
|
72778
73159
|
}
|
|
72779
73160
|
if (docKind === "HoudiniQuery") {
|
|
72780
73161
|
const cacheDirective = operations[0].directives?.find(
|
|
72781
|
-
(
|
|
73162
|
+
(directive2) => directive2.name.value === config2.cacheDirective
|
|
72782
73163
|
);
|
|
72783
73164
|
if (cacheDirective) {
|
|
72784
73165
|
const args = cacheDirective.arguments?.reduce(
|
|
@@ -72994,19 +73375,19 @@ async function generatePluginRuntime(config2, plugin) {
|
|
|
72994
73375
|
);
|
|
72995
73376
|
}
|
|
72996
73377
|
|
|
72997
|
-
// src/codegen/generators/typescript/
|
|
72998
|
-
var
|
|
73378
|
+
// src/codegen/generators/typescript/documentTypes.ts
|
|
73379
|
+
var recast11 = __toESM(require_main2(), 1);
|
|
72999
73380
|
|
|
73000
73381
|
// src/codegen/generators/typescript/addReferencedInputTypes.ts
|
|
73001
|
-
var
|
|
73382
|
+
var graphql17 = __toESM(require_graphql2(), 1);
|
|
73002
73383
|
var recast9 = __toESM(require_main2(), 1);
|
|
73003
73384
|
|
|
73004
73385
|
// src/codegen/generators/typescript/typeReference.ts
|
|
73005
|
-
var
|
|
73386
|
+
var graphql16 = __toESM(require_graphql2(), 1);
|
|
73006
73387
|
var recast8 = __toESM(require_main2(), 1);
|
|
73007
73388
|
|
|
73008
73389
|
// src/codegen/generators/typescript/types.ts
|
|
73009
|
-
var
|
|
73390
|
+
var graphql15 = __toESM(require_graphql2(), 1);
|
|
73010
73391
|
var recast7 = __toESM(require_main2(), 1);
|
|
73011
73392
|
var AST7 = recast7.types.builders;
|
|
73012
73393
|
function readonlyProperty(prop, enable = true) {
|
|
@@ -73022,351 +73403,104 @@ function nullableField(inner, input = false) {
|
|
|
73022
73403
|
}
|
|
73023
73404
|
return AST7.tsUnionType(members);
|
|
73024
73405
|
}
|
|
73025
|
-
function scalarPropertyValue(config2, missingScalars, target) {
|
|
73026
|
-
switch (target.name) {
|
|
73027
|
-
case "String": {
|
|
73028
|
-
return AST7.tsStringKeyword();
|
|
73029
|
-
}
|
|
73030
|
-
case "Int": {
|
|
73031
|
-
return AST7.tsNumberKeyword();
|
|
73032
|
-
}
|
|
73033
|
-
case "Float": {
|
|
73034
|
-
return AST7.tsNumberKeyword();
|
|
73035
|
-
}
|
|
73036
|
-
case "Boolean": {
|
|
73037
|
-
return AST7.tsBooleanKeyword();
|
|
73038
|
-
}
|
|
73039
|
-
case "ID": {
|
|
73040
|
-
return AST7.tsStringKeyword();
|
|
73041
|
-
}
|
|
73042
|
-
default: {
|
|
73043
|
-
if (
|
|
73044
|
-
return scalarPropertyValue(
|
|
73045
|
-
config2,
|
|
73046
|
-
missingScalars,
|
|
73047
|
-
target.ofType
|
|
73048
|
-
);
|
|
73049
|
-
}
|
|
73050
|
-
if (config2.scalars?.[target.name]) {
|
|
73051
|
-
return AST7.tsTypeReference(AST7.identifier(config2.scalars?.[target.name].type));
|
|
73052
|
-
}
|
|
73053
|
-
missingScalars.add(target.name);
|
|
73054
|
-
return AST7.tsAnyKeyword();
|
|
73055
|
-
}
|
|
73056
|
-
}
|
|
73057
|
-
}
|
|
73058
|
-
|
|
73059
|
-
// src/codegen/generators/typescript/typeReference.ts
|
|
73060
|
-
var AST8 = recast8.types.builders;
|
|
73061
|
-
function tsTypeReference(config2, missingScalars, definition) {
|
|
73062
|
-
const { type, wrappers } = unwrapType(config2, definition.type);
|
|
73063
|
-
let result;
|
|
73064
|
-
if (graphql15.isScalarType(type)) {
|
|
73065
|
-
result = scalarPropertyValue(config2, missingScalars, type);
|
|
73066
|
-
} else {
|
|
73067
|
-
result = AST8.tsTypeReference(AST8.identifier(type.name));
|
|
73068
|
-
}
|
|
73069
|
-
for (const toWrap of wrappers) {
|
|
73070
|
-
if (toWrap === "NonNull" /* NonNull */) {
|
|
73071
|
-
continue;
|
|
73072
|
-
} else if (toWrap === "Nullable" /* Nullable */) {
|
|
73073
|
-
result = nullableField(result, true);
|
|
73074
|
-
} else if (toWrap === "List" /* List */) {
|
|
73075
|
-
result = AST8.tsArrayType(AST8.tsParenthesizedType(result));
|
|
73076
|
-
}
|
|
73077
|
-
}
|
|
73078
|
-
return result;
|
|
73079
|
-
}
|
|
73080
|
-
|
|
73081
|
-
// src/codegen/generators/typescript/addReferencedInputTypes.ts
|
|
73082
|
-
var AST9 = recast9.types.builders;
|
|
73083
|
-
function addReferencedInputTypes(config2, filepath, body, visitedTypes, missingScalars, rootType) {
|
|
73084
|
-
const { type } = unwrapType(config2, rootType);
|
|
73085
|
-
if (graphql16.isScalarType(type)) {
|
|
73086
|
-
return;
|
|
73087
|
-
}
|
|
73088
|
-
if (visitedTypes.has(type.name)) {
|
|
73089
|
-
return;
|
|
73090
|
-
}
|
|
73091
|
-
if (graphql16.isUnionType(type)) {
|
|
73092
|
-
throw new HoudiniError({ filepath, message: "Input Unions are not supported yet. Sorry!" });
|
|
73093
|
-
}
|
|
73094
|
-
visitedTypes.add(type.name);
|
|
73095
|
-
if (graphql16.isEnumType(type)) {
|
|
73096
|
-
ensureImports({
|
|
73097
|
-
config: config2,
|
|
73098
|
-
body,
|
|
73099
|
-
import: [type.name],
|
|
73100
|
-
sourceModule: "$houdini/graphql/enums",
|
|
73101
|
-
importKind: "type"
|
|
73102
|
-
});
|
|
73103
|
-
return;
|
|
73104
|
-
}
|
|
73105
|
-
const members = [];
|
|
73106
|
-
for (const field of Object.values(type.getFields())) {
|
|
73107
|
-
addReferencedInputTypes(config2, filepath, body, visitedTypes, missingScalars, field.type);
|
|
73108
|
-
members.push(
|
|
73109
|
-
AST9.tsPropertySignature(
|
|
73110
|
-
AST9.identifier(field.name),
|
|
73111
|
-
AST9.tsTypeAnnotation(tsTypeReference(config2, missingScalars, field)),
|
|
73112
|
-
graphql16.isNullableType(field.type)
|
|
73113
|
-
)
|
|
73114
|
-
);
|
|
73115
|
-
}
|
|
73116
|
-
body.push(AST9.tsTypeAliasDeclaration(AST9.identifier(type.name), AST9.tsTypeLiteral(members)));
|
|
73117
|
-
}
|
|
73118
|
-
|
|
73119
|
-
// src/codegen/generators/typescript/imperativeCache.ts
|
|
73120
|
-
var graphql17 = __toESM(require_graphql2(), 1);
|
|
73121
|
-
var recast10 = __toESM(require_main2(), 1);
|
|
73122
|
-
var AST10 = recast10.types.builders;
|
|
73123
|
-
async function imperativeCacheTypef(config2, docs) {
|
|
73124
|
-
const target = path_exports.join(config2.runtimeDirectory, "generated.d.ts");
|
|
73125
|
-
const body = [];
|
|
73126
|
-
const declaration = AST10.tsTypeAliasDeclaration(
|
|
73127
|
-
AST10.identifier(CacheTypeDefName),
|
|
73128
|
-
AST10.tsTypeLiteral([
|
|
73129
|
-
AST10.tsPropertySignature(
|
|
73130
|
-
AST10.identifier("types"),
|
|
73131
|
-
AST10.tsTypeAnnotation(typeDefinitions(config2, body))
|
|
73132
|
-
),
|
|
73133
|
-
AST10.tsPropertySignature(
|
|
73134
|
-
AST10.identifier("lists"),
|
|
73135
|
-
AST10.tsTypeAnnotation(listDefinitions(config2, docs))
|
|
73136
|
-
)
|
|
73137
|
-
])
|
|
73138
|
-
);
|
|
73139
|
-
declaration.declare = true;
|
|
73140
|
-
const importRecord = AST10.importDeclaration(
|
|
73141
|
-
[AST10.importSpecifier(AST10.identifier("Record"))],
|
|
73142
|
-
AST10.stringLiteral("./public/record")
|
|
73143
|
-
);
|
|
73144
|
-
importRecord.importKind = "type";
|
|
73145
|
-
await fs_exports.writeFile(
|
|
73146
|
-
target,
|
|
73147
|
-
recast10.prettyPrint(
|
|
73148
|
-
AST10.program([importRecord, ...body, AST10.exportNamedDeclaration(declaration)])
|
|
73149
|
-
).code
|
|
73150
|
-
);
|
|
73151
|
-
}
|
|
73152
|
-
function typeDefinitions(config2, body) {
|
|
73153
|
-
const operationTypes = [config2.schema.getMutationType(), config2.schema.getSubscriptionType()].filter(Boolean).map((type) => type?.name);
|
|
73154
|
-
const visitedTypes = /* @__PURE__ */ new Set();
|
|
73155
|
-
const types16 = Object.values(config2.schema.getTypeMap()).filter(
|
|
73156
|
-
(type) => !graphql17.isAbstractType(type) && !graphql17.isScalarType(type) && !graphql17.isEnumType(type) && !graphql17.isInputObjectType(type) && !type.name.startsWith("__") && !operationTypes.includes(type.name)
|
|
73157
|
-
);
|
|
73158
|
-
return AST10.tsTypeLiteral(
|
|
73159
|
-
types16.map((type) => {
|
|
73160
|
-
let typeName = type.name;
|
|
73161
|
-
if (config2.schema.getQueryType() && config2.schema.getQueryType()?.name === type.name) {
|
|
73162
|
-
typeName = "__ROOT__";
|
|
73163
|
-
}
|
|
73164
|
-
let idFields = AST10.tsNeverKeyword();
|
|
73165
|
-
const keys = keyFieldsForType(config2.configFile, type.name);
|
|
73166
|
-
if (graphql17.isObjectType(type) && keys.length > 0 && keys.every((key) => type.getFields()[key])) {
|
|
73167
|
-
idFields = AST10.tsTypeLiteral(
|
|
73168
|
-
keys.map((key) => {
|
|
73169
|
-
const fieldType = type.getFields()[key];
|
|
73170
|
-
const unwrapped = unwrapType(config2, fieldType.type);
|
|
73171
|
-
return AST10.tsPropertySignature(
|
|
73172
|
-
AST10.identifier(key),
|
|
73173
|
-
AST10.tsTypeAnnotation(
|
|
73174
|
-
scalarPropertyValue(config2, /* @__PURE__ */ new Set(), unwrapped.type)
|
|
73175
|
-
)
|
|
73176
|
-
);
|
|
73177
|
-
})
|
|
73178
|
-
);
|
|
73179
|
-
} else if (typeName === "__ROOT__") {
|
|
73180
|
-
idFields = AST10.tsTypeLiteral([]);
|
|
73181
|
-
}
|
|
73182
|
-
let fields = AST10.tsTypeLiteral([]);
|
|
73183
|
-
if (graphql17.isObjectType(type)) {
|
|
73184
|
-
fields = AST10.tsTypeLiteral(
|
|
73185
|
-
Object.entries(type.getFields()).map(
|
|
73186
|
-
([key, fieldType]) => {
|
|
73187
|
-
const unwrapped = unwrapType(config2, fieldType.type);
|
|
73188
|
-
let typeOptions = AST10.tsUnionType([]);
|
|
73189
|
-
if (graphql17.isScalarType(unwrapped.type)) {
|
|
73190
|
-
typeOptions.types.push(
|
|
73191
|
-
scalarPropertyValue(config2, /* @__PURE__ */ new Set(), unwrapped.type)
|
|
73192
|
-
);
|
|
73193
|
-
} else if (graphql17.isEnumType(unwrapped.type)) {
|
|
73194
|
-
typeOptions.types.push(
|
|
73195
|
-
AST10.tsTypeReference(AST10.identifier(unwrapped.type.name))
|
|
73196
|
-
);
|
|
73197
|
-
} else if (!graphql17.isAbstractType(unwrapped.type)) {
|
|
73198
|
-
typeOptions.types.push(record(unwrapped.type.name));
|
|
73199
|
-
} else {
|
|
73200
|
-
typeOptions.types.push(
|
|
73201
|
-
...config2.schema.getPossibleTypes(unwrapped.type).map((type2) => record(type2.name))
|
|
73202
|
-
);
|
|
73203
|
-
}
|
|
73204
|
-
for (const wrapper of unwrapped.wrappers) {
|
|
73205
|
-
if (wrapper === "Nullable" /* Nullable */) {
|
|
73206
|
-
typeOptions = AST10.tsParenthesizedType(
|
|
73207
|
-
AST10.tsUnionType([typeOptions, AST10.tsNullKeyword()])
|
|
73208
|
-
);
|
|
73209
|
-
} else if (wrapper === "List" /* List */) {
|
|
73210
|
-
typeOptions = AST10.tsArrayType(
|
|
73211
|
-
AST10.tsParenthesizedType(typeOptions)
|
|
73212
|
-
);
|
|
73213
|
-
}
|
|
73214
|
-
}
|
|
73215
|
-
if (typeOptions.type === "TSParenthesizedType") {
|
|
73216
|
-
typeOptions = typeOptions.typeAnnotation;
|
|
73217
|
-
}
|
|
73218
|
-
let args = AST10.tsNeverKeyword();
|
|
73219
|
-
if (fieldType.args?.length > 0) {
|
|
73220
|
-
args = AST10.tsTypeLiteral(
|
|
73221
|
-
fieldType.args.map((arg) => {
|
|
73222
|
-
addReferencedInputTypes(
|
|
73223
|
-
config2,
|
|
73224
|
-
"",
|
|
73225
|
-
body,
|
|
73226
|
-
visitedTypes,
|
|
73227
|
-
/* @__PURE__ */ new Set(),
|
|
73228
|
-
arg.type
|
|
73229
|
-
);
|
|
73230
|
-
const prop = AST10.tsPropertySignature(
|
|
73231
|
-
AST10.identifier(arg.name),
|
|
73232
|
-
AST10.tsTypeAnnotation(
|
|
73233
|
-
tsTypeReference(config2, /* @__PURE__ */ new Set(), arg)
|
|
73234
|
-
)
|
|
73235
|
-
);
|
|
73236
|
-
const unwrapped2 = unwrapType(config2, arg.type);
|
|
73237
|
-
prop.optional = unwrapped2.wrappers[unwrapped2.wrappers.length - 1] === "Nullable" /* Nullable */;
|
|
73238
|
-
return prop;
|
|
73239
|
-
})
|
|
73240
|
-
);
|
|
73241
|
-
}
|
|
73242
|
-
return AST10.tsPropertySignature(
|
|
73243
|
-
AST10.identifier(key),
|
|
73244
|
-
AST10.tsTypeAnnotation(
|
|
73245
|
-
AST10.tsTypeLiteral([
|
|
73246
|
-
AST10.tsPropertySignature(
|
|
73247
|
-
AST10.identifier("type"),
|
|
73248
|
-
AST10.tsTypeAnnotation(typeOptions)
|
|
73249
|
-
),
|
|
73250
|
-
AST10.tsPropertySignature(
|
|
73251
|
-
AST10.identifier("args"),
|
|
73252
|
-
AST10.tsTypeAnnotation(args)
|
|
73253
|
-
)
|
|
73254
|
-
])
|
|
73255
|
-
)
|
|
73256
|
-
);
|
|
73257
|
-
}
|
|
73258
|
-
)
|
|
73259
|
-
);
|
|
73260
|
-
}
|
|
73261
|
-
return AST10.tsPropertySignature(
|
|
73262
|
-
AST10.identifier(typeName),
|
|
73263
|
-
AST10.tsTypeAnnotation(
|
|
73264
|
-
AST10.tsTypeLiteral([
|
|
73265
|
-
AST10.tsPropertySignature(
|
|
73266
|
-
AST10.identifier("idFields"),
|
|
73267
|
-
AST10.tsTypeAnnotation(idFields)
|
|
73268
|
-
),
|
|
73269
|
-
AST10.tsPropertySignature(
|
|
73270
|
-
AST10.identifier("fields"),
|
|
73271
|
-
AST10.tsTypeAnnotation(fields)
|
|
73272
|
-
)
|
|
73273
|
-
])
|
|
73274
|
-
)
|
|
73275
|
-
);
|
|
73276
|
-
})
|
|
73277
|
-
);
|
|
73278
|
-
}
|
|
73279
|
-
function listDefinitions(config2, docs) {
|
|
73280
|
-
const lists = [];
|
|
73281
|
-
const visitedLists = /* @__PURE__ */ new Set();
|
|
73282
|
-
for (const doc of docs) {
|
|
73283
|
-
graphql17.visit(doc.document, {
|
|
73284
|
-
Directive(node, key, parent, path2, ancestors) {
|
|
73285
|
-
if (![config2.listDirective, config2.paginateDirective].includes(node.name.value)) {
|
|
73286
|
-
return;
|
|
73287
|
-
}
|
|
73288
|
-
const nameArg = node.arguments?.find((arg) => arg.name.value === "name");
|
|
73289
|
-
const nameValue = nameArg?.value?.value || "";
|
|
73290
|
-
if (!nameValue || visitedLists.has(nameValue)) {
|
|
73291
|
-
return;
|
|
73292
|
-
}
|
|
73293
|
-
visitedLists.add(nameValue);
|
|
73294
|
-
const parentType = parentTypeFromAncestors(
|
|
73295
|
-
config2.schema,
|
|
73296
|
-
doc.filename,
|
|
73297
|
-
ancestors.slice(0, -1)
|
|
73298
|
-
);
|
|
73299
|
-
const targetField = ancestors[ancestors.length - 1];
|
|
73300
|
-
const targetFieldDefinition = parentType.getFields()[targetField.name.value];
|
|
73301
|
-
const { type: listType } = unwrapType(config2, targetFieldDefinition.type);
|
|
73302
|
-
const possibleTypes = [];
|
|
73303
|
-
if (graphql17.isAbstractType(listType)) {
|
|
73304
|
-
possibleTypes.push(
|
|
73305
|
-
...config2.schema.getPossibleTypes(listType).map((possible) => possible.name)
|
|
73306
|
-
);
|
|
73307
|
-
} else {
|
|
73308
|
-
possibleTypes.push(listType.name);
|
|
73309
|
-
}
|
|
73310
|
-
lists.push(
|
|
73311
|
-
AST10.tsPropertySignature(
|
|
73312
|
-
AST10.identifier(nameValue),
|
|
73313
|
-
AST10.tsTypeAnnotation(
|
|
73314
|
-
AST10.tsTypeLiteral([
|
|
73315
|
-
AST10.tsPropertySignature(
|
|
73316
|
-
AST10.identifier("types"),
|
|
73317
|
-
AST10.tsTypeAnnotation(
|
|
73318
|
-
AST10.tsUnionType(
|
|
73319
|
-
possibleTypes.map(
|
|
73320
|
-
(possible) => AST10.tsLiteralType(AST10.stringLiteral(possible))
|
|
73321
|
-
)
|
|
73322
|
-
)
|
|
73323
|
-
)
|
|
73324
|
-
),
|
|
73325
|
-
AST10.tsPropertySignature(
|
|
73326
|
-
AST10.identifier("filters"),
|
|
73327
|
-
AST10.tsTypeAnnotation(
|
|
73328
|
-
targetFieldDefinition.args.length === 0 ? AST10.tsNeverKeyword() : AST10.tsTypeLiteral(
|
|
73329
|
-
targetFieldDefinition.args.map((arg) => {
|
|
73330
|
-
const argDef = AST10.tsPropertySignature(
|
|
73331
|
-
AST10.identifier(arg.name),
|
|
73332
|
-
AST10.tsTypeAnnotation(
|
|
73333
|
-
tsTypeReference(
|
|
73334
|
-
config2,
|
|
73335
|
-
/* @__PURE__ */ new Set(),
|
|
73336
|
-
arg
|
|
73337
|
-
)
|
|
73338
|
-
)
|
|
73339
|
-
);
|
|
73340
|
-
argDef.optional = true;
|
|
73341
|
-
return argDef;
|
|
73342
|
-
})
|
|
73343
|
-
)
|
|
73344
|
-
)
|
|
73345
|
-
)
|
|
73346
|
-
])
|
|
73347
|
-
)
|
|
73348
|
-
)
|
|
73406
|
+
function scalarPropertyValue(config2, missingScalars, target) {
|
|
73407
|
+
switch (target.name) {
|
|
73408
|
+
case "String": {
|
|
73409
|
+
return AST7.tsStringKeyword();
|
|
73410
|
+
}
|
|
73411
|
+
case "Int": {
|
|
73412
|
+
return AST7.tsNumberKeyword();
|
|
73413
|
+
}
|
|
73414
|
+
case "Float": {
|
|
73415
|
+
return AST7.tsNumberKeyword();
|
|
73416
|
+
}
|
|
73417
|
+
case "Boolean": {
|
|
73418
|
+
return AST7.tsBooleanKeyword();
|
|
73419
|
+
}
|
|
73420
|
+
case "ID": {
|
|
73421
|
+
return AST7.tsStringKeyword();
|
|
73422
|
+
}
|
|
73423
|
+
default: {
|
|
73424
|
+
if (graphql15.isNonNullType(target) && "ofType" in target) {
|
|
73425
|
+
return scalarPropertyValue(
|
|
73426
|
+
config2,
|
|
73427
|
+
missingScalars,
|
|
73428
|
+
target.ofType
|
|
73349
73429
|
);
|
|
73350
73430
|
}
|
|
73351
|
-
|
|
73431
|
+
if (config2.scalars?.[target.name]) {
|
|
73432
|
+
return AST7.tsTypeReference(AST7.identifier(config2.scalars?.[target.name].type));
|
|
73433
|
+
}
|
|
73434
|
+
missingScalars.add(target.name);
|
|
73435
|
+
return AST7.tsAnyKeyword();
|
|
73436
|
+
}
|
|
73352
73437
|
}
|
|
73353
|
-
return AST10.tsTypeLiteral(lists);
|
|
73354
73438
|
}
|
|
73355
|
-
|
|
73356
|
-
|
|
73357
|
-
|
|
73358
|
-
|
|
73359
|
-
|
|
73360
|
-
|
|
73361
|
-
|
|
73362
|
-
|
|
73363
|
-
|
|
73439
|
+
|
|
73440
|
+
// src/codegen/generators/typescript/typeReference.ts
|
|
73441
|
+
var AST8 = recast8.types.builders;
|
|
73442
|
+
function tsTypeReference(config2, missingScalars, definition) {
|
|
73443
|
+
const { type, wrappers } = unwrapType(config2, definition.type);
|
|
73444
|
+
let result;
|
|
73445
|
+
if (graphql16.isScalarType(type)) {
|
|
73446
|
+
result = scalarPropertyValue(config2, missingScalars, type);
|
|
73447
|
+
} else {
|
|
73448
|
+
result = AST8.tsTypeReference(AST8.identifier(type.name));
|
|
73449
|
+
}
|
|
73450
|
+
for (const toWrap of wrappers) {
|
|
73451
|
+
if (toWrap === "NonNull" /* NonNull */) {
|
|
73452
|
+
continue;
|
|
73453
|
+
} else if (toWrap === "Nullable" /* Nullable */) {
|
|
73454
|
+
result = nullableField(result, true);
|
|
73455
|
+
} else if (toWrap === "List" /* List */) {
|
|
73456
|
+
result = AST8.tsArrayType(AST8.tsParenthesizedType(result));
|
|
73457
|
+
}
|
|
73458
|
+
}
|
|
73459
|
+
return result;
|
|
73460
|
+
}
|
|
73461
|
+
|
|
73462
|
+
// src/codegen/generators/typescript/addReferencedInputTypes.ts
|
|
73463
|
+
var AST9 = recast9.types.builders;
|
|
73464
|
+
function addReferencedInputTypes(config2, filepath, body, visitedTypes, missingScalars, rootType) {
|
|
73465
|
+
const { type } = unwrapType(config2, rootType);
|
|
73466
|
+
if (graphql17.isScalarType(type)) {
|
|
73467
|
+
return;
|
|
73468
|
+
}
|
|
73469
|
+
if (visitedTypes.has(type.name)) {
|
|
73470
|
+
return;
|
|
73471
|
+
}
|
|
73472
|
+
if (graphql17.isUnionType(type)) {
|
|
73473
|
+
throw new HoudiniError({ filepath, message: "Input Unions are not supported yet. Sorry!" });
|
|
73474
|
+
}
|
|
73475
|
+
visitedTypes.add(type.name);
|
|
73476
|
+
if (graphql17.isEnumType(type)) {
|
|
73477
|
+
ensureImports({
|
|
73478
|
+
config: config2,
|
|
73479
|
+
body,
|
|
73480
|
+
import: [type.name],
|
|
73481
|
+
sourceModule: "$houdini/graphql/enums",
|
|
73482
|
+
importKind: "type"
|
|
73483
|
+
});
|
|
73484
|
+
return;
|
|
73485
|
+
}
|
|
73486
|
+
const members = [];
|
|
73487
|
+
for (const field of Object.values(type.getFields())) {
|
|
73488
|
+
addReferencedInputTypes(config2, filepath, body, visitedTypes, missingScalars, field.type);
|
|
73489
|
+
members.push(
|
|
73490
|
+
AST9.tsPropertySignature(
|
|
73491
|
+
AST9.identifier(field.name),
|
|
73492
|
+
AST9.tsTypeAnnotation(tsTypeReference(config2, missingScalars, field)),
|
|
73493
|
+
graphql17.isNullableType(field.type)
|
|
73494
|
+
)
|
|
73495
|
+
);
|
|
73496
|
+
}
|
|
73497
|
+
body.push(AST9.tsTypeAliasDeclaration(AST9.identifier(type.name), AST9.tsTypeLiteral(members)));
|
|
73364
73498
|
}
|
|
73365
73499
|
|
|
73366
73500
|
// src/codegen/generators/typescript/inlineType.ts
|
|
73367
73501
|
var graphql18 = __toESM(require_graphql2(), 1);
|
|
73368
|
-
var
|
|
73369
|
-
var
|
|
73502
|
+
var recast10 = __toESM(require_main2(), 1);
|
|
73503
|
+
var AST10 = recast10.types.builders;
|
|
73370
73504
|
var fragmentKey = "$fragments";
|
|
73371
73505
|
function inlineType({
|
|
73372
73506
|
config: config2,
|
|
@@ -73395,7 +73529,7 @@ function inlineType({
|
|
|
73395
73529
|
});
|
|
73396
73530
|
visitedTypes.add(type.name);
|
|
73397
73531
|
}
|
|
73398
|
-
result =
|
|
73532
|
+
result = AST10.tsTypeReference(AST10.identifier(type.name));
|
|
73399
73533
|
} else if (selections) {
|
|
73400
73534
|
const rootObj = type;
|
|
73401
73535
|
const inlineFragments = {};
|
|
@@ -73446,7 +73580,7 @@ function inlineType({
|
|
|
73446
73580
|
selectedFields.push(selection2);
|
|
73447
73581
|
}
|
|
73448
73582
|
}
|
|
73449
|
-
result =
|
|
73583
|
+
result = AST10.tsTypeLiteral([
|
|
73450
73584
|
...(selectedFields || []).filter(
|
|
73451
73585
|
(field) => field.kind === "Field"
|
|
73452
73586
|
).map((selection2) => {
|
|
@@ -73466,9 +73600,9 @@ function inlineType({
|
|
|
73466
73600
|
allOptional
|
|
73467
73601
|
});
|
|
73468
73602
|
const prop = readonlyProperty(
|
|
73469
|
-
|
|
73470
|
-
|
|
73471
|
-
|
|
73603
|
+
AST10.tsPropertySignature(
|
|
73604
|
+
AST10.identifier(attributeName),
|
|
73605
|
+
AST10.tsTypeAnnotation(attributeType)
|
|
73472
73606
|
),
|
|
73473
73607
|
allowReadonly
|
|
73474
73608
|
);
|
|
@@ -73482,15 +73616,15 @@ function inlineType({
|
|
|
73482
73616
|
if (includeFragments && fragmentSpreads && fragmentSpreads.length) {
|
|
73483
73617
|
result.members.push(
|
|
73484
73618
|
readonlyProperty(
|
|
73485
|
-
|
|
73486
|
-
|
|
73487
|
-
|
|
73488
|
-
|
|
73619
|
+
AST10.tsPropertySignature(
|
|
73620
|
+
AST10.identifier(fragmentKey),
|
|
73621
|
+
AST10.tsTypeAnnotation(
|
|
73622
|
+
AST10.tsTypeLiteral(
|
|
73489
73623
|
(fragmentSpreads || []).map(
|
|
73490
|
-
(fragmentSpread) =>
|
|
73491
|
-
|
|
73492
|
-
|
|
73493
|
-
|
|
73624
|
+
(fragmentSpread) => AST10.tsPropertySignature(
|
|
73625
|
+
AST10.identifier(fragmentSpread.name.value),
|
|
73626
|
+
AST10.tsTypeAnnotation(
|
|
73627
|
+
AST10.tsLiteralType(AST10.booleanLiteral(true))
|
|
73494
73628
|
)
|
|
73495
73629
|
)
|
|
73496
73630
|
)
|
|
@@ -73536,9 +73670,9 @@ function inlineType({
|
|
|
73536
73670
|
}
|
|
73537
73671
|
objectType.members.push(
|
|
73538
73672
|
readonlyProperty(
|
|
73539
|
-
|
|
73540
|
-
|
|
73541
|
-
|
|
73673
|
+
AST10.tsPropertySignature(
|
|
73674
|
+
AST10.identifier("__typename"),
|
|
73675
|
+
AST10.tsTypeAnnotation(AST10.tsLiteralType(AST10.stringLiteral(typeName)))
|
|
73542
73676
|
),
|
|
73543
73677
|
allowReadonly
|
|
73544
73678
|
)
|
|
@@ -73549,8 +73683,8 @@ function inlineType({
|
|
|
73549
73683
|
if (Object.keys(inlineFragmentSelections).length > 0) {
|
|
73550
73684
|
let selectionTypes = Object.entries(inlineFragmentSelections).map(
|
|
73551
73685
|
([typeName, { type: type2, tsType }]) => {
|
|
73552
|
-
return
|
|
73553
|
-
|
|
73686
|
+
return AST10.tsParenthesizedType(
|
|
73687
|
+
AST10.tsIntersectionType(
|
|
73554
73688
|
[tsType].flatMap((type3) => {
|
|
73555
73689
|
if (type3.type === "TSUnionType") {
|
|
73556
73690
|
return type3.types.filter(
|
|
@@ -73563,9 +73697,9 @@ function inlineType({
|
|
|
73563
73697
|
);
|
|
73564
73698
|
}
|
|
73565
73699
|
);
|
|
73566
|
-
result =
|
|
73700
|
+
result = AST10.tsIntersectionType([
|
|
73567
73701
|
result,
|
|
73568
|
-
|
|
73702
|
+
AST10.tsParenthesizedType(AST10.tsUnionType(selectionTypes))
|
|
73569
73703
|
]);
|
|
73570
73704
|
}
|
|
73571
73705
|
} else {
|
|
@@ -73577,7 +73711,7 @@ function inlineType({
|
|
|
73577
73711
|
} else if (toWrap === "NonNull" /* NonNull */) {
|
|
73578
73712
|
continue;
|
|
73579
73713
|
} else if (toWrap === "List" /* List */) {
|
|
73580
|
-
result =
|
|
73714
|
+
result = AST10.tsArrayType(AST10.tsParenthesizedType(result));
|
|
73581
73715
|
}
|
|
73582
73716
|
}
|
|
73583
73717
|
return result;
|
|
@@ -73621,9 +73755,9 @@ function selectionTypeInfo(schema, filepath, rootType, selection2) {
|
|
|
73621
73755
|
return { field, type: selectionType };
|
|
73622
73756
|
}
|
|
73623
73757
|
|
|
73624
|
-
// src/codegen/generators/typescript/
|
|
73625
|
-
var
|
|
73626
|
-
async function
|
|
73758
|
+
// src/codegen/generators/typescript/documentTypes.ts
|
|
73759
|
+
var AST11 = recast11.types.builders;
|
|
73760
|
+
async function generateDocumentTypes(config2, docs) {
|
|
73627
73761
|
const typePaths = [];
|
|
73628
73762
|
const fragmentDefinitions = {};
|
|
73629
73763
|
for (const document of docs) {
|
|
@@ -73640,7 +73774,7 @@ async function typescriptGenerator(config2, docs) {
|
|
|
73640
73774
|
return;
|
|
73641
73775
|
}
|
|
73642
73776
|
const typeDefPath = config2.artifactTypePath(originalDocument);
|
|
73643
|
-
const program3 =
|
|
73777
|
+
const program3 = AST11.program([]);
|
|
73644
73778
|
const visitedTypes = /* @__PURE__ */ new Set();
|
|
73645
73779
|
let definition = originalDocument.definitions.find(
|
|
73646
73780
|
(def) => (def.kind === "OperationDefinition" || def.kind === "FragmentDefinition") && def.name?.value === name2
|
|
@@ -73673,21 +73807,21 @@ async function typescriptGenerator(config2, docs) {
|
|
|
73673
73807
|
missingScalars
|
|
73674
73808
|
);
|
|
73675
73809
|
}
|
|
73676
|
-
await fs_exports.writeFile(typeDefPath,
|
|
73810
|
+
await fs_exports.writeFile(typeDefPath, recast11.print(program3).code);
|
|
73677
73811
|
typePaths.push(typeDefPath);
|
|
73678
73812
|
})
|
|
73679
73813
|
);
|
|
73680
|
-
const typeIndex =
|
|
73814
|
+
const typeIndex = AST11.program(
|
|
73681
73815
|
typePaths.sort((a, b) => a.localeCompare(b)).map((typePath) => {
|
|
73682
|
-
return
|
|
73683
|
-
|
|
73816
|
+
return AST11.exportAllDeclaration(
|
|
73817
|
+
AST11.literal(
|
|
73684
73818
|
"./" + path_exports.relative(path_exports.resolve(config2.typeIndexPath, ".."), typePath).replace(/\.[^/.]+\.[^/.]+$/, "")
|
|
73685
73819
|
),
|
|
73686
73820
|
null
|
|
73687
73821
|
);
|
|
73688
73822
|
}).concat([
|
|
73689
|
-
|
|
73690
|
-
|
|
73823
|
+
AST11.exportAllDeclaration(AST11.literal("./runtime"), null),
|
|
73824
|
+
AST11.exportAllDeclaration(AST11.literal("./graphql"), null)
|
|
73691
73825
|
])
|
|
73692
73826
|
);
|
|
73693
73827
|
const export_default_as = ({ module, as }) => `
|
|
@@ -73696,7 +73830,7 @@ export { default as ${as} } from "${module}"
|
|
|
73696
73830
|
const export_star_from = ({ module }) => `
|
|
73697
73831
|
export * from "${module}"
|
|
73698
73832
|
`;
|
|
73699
|
-
let indexContent =
|
|
73833
|
+
let indexContent = recast11.print(typeIndex).code;
|
|
73700
73834
|
for (const plugin of config2.plugins) {
|
|
73701
73835
|
if (!plugin.index_file) {
|
|
73702
73836
|
continue;
|
|
@@ -73717,7 +73851,6 @@ export * from "${module}"
|
|
|
73717
73851
|
}
|
|
73718
73852
|
}
|
|
73719
73853
|
await fs_exports.writeFile(config2.typeIndexPath, indexContent);
|
|
73720
|
-
await imperativeCacheTypef(config2, docs);
|
|
73721
73854
|
if (missingScalars.size > 0) {
|
|
73722
73855
|
console.warn(`\u26A0\uFE0F Missing definitions for the following scalars: ${[...missingScalars].join(
|
|
73723
73856
|
", "
|
|
@@ -73759,23 +73892,23 @@ async function generateOperationTypeDefs(config2, filepath, body, definition, se
|
|
|
73759
73892
|
const optimisticTypeName = `${definition.name.value}$optimistic`;
|
|
73760
73893
|
const hasInputs = definition.variableDefinitions && definition.variableDefinitions.length > 0;
|
|
73761
73894
|
body.push(
|
|
73762
|
-
|
|
73763
|
-
|
|
73764
|
-
|
|
73765
|
-
|
|
73895
|
+
AST11.exportNamedDeclaration(
|
|
73896
|
+
AST11.tsTypeAliasDeclaration(
|
|
73897
|
+
AST11.identifier(definition.name.value),
|
|
73898
|
+
AST11.tsTypeLiteral([
|
|
73766
73899
|
readonlyProperty(
|
|
73767
|
-
|
|
73768
|
-
|
|
73769
|
-
|
|
73900
|
+
AST11.tsPropertySignature(
|
|
73901
|
+
AST11.stringLiteral("input"),
|
|
73902
|
+
AST11.tsTypeAnnotation(AST11.tsTypeReference(AST11.identifier(inputTypeName)))
|
|
73770
73903
|
)
|
|
73771
73904
|
),
|
|
73772
73905
|
readonlyProperty(
|
|
73773
|
-
|
|
73774
|
-
|
|
73775
|
-
|
|
73776
|
-
definition.operation === "mutation" ?
|
|
73777
|
-
|
|
73778
|
-
|
|
73906
|
+
AST11.tsPropertySignature(
|
|
73907
|
+
AST11.stringLiteral("result"),
|
|
73908
|
+
AST11.tsTypeAnnotation(
|
|
73909
|
+
definition.operation === "mutation" ? AST11.tsTypeReference(AST11.identifier(shapeTypeName)) : AST11.tsUnionType([
|
|
73910
|
+
AST11.tsTypeReference(AST11.identifier(shapeTypeName)),
|
|
73911
|
+
AST11.tsUndefinedKeyword()
|
|
73779
73912
|
])
|
|
73780
73913
|
)
|
|
73781
73914
|
)
|
|
@@ -73783,9 +73916,9 @@ async function generateOperationTypeDefs(config2, filepath, body, definition, se
|
|
|
73783
73916
|
])
|
|
73784
73917
|
)
|
|
73785
73918
|
),
|
|
73786
|
-
|
|
73787
|
-
|
|
73788
|
-
|
|
73919
|
+
AST11.exportNamedDeclaration(
|
|
73920
|
+
AST11.tsTypeAliasDeclaration(
|
|
73921
|
+
AST11.identifier(shapeTypeName),
|
|
73789
73922
|
inlineType({
|
|
73790
73923
|
config: config2,
|
|
73791
73924
|
filepath,
|
|
@@ -73813,15 +73946,15 @@ async function generateOperationTypeDefs(config2, filepath, body, definition, se
|
|
|
73813
73946
|
);
|
|
73814
73947
|
}
|
|
73815
73948
|
body.push(
|
|
73816
|
-
|
|
73817
|
-
|
|
73818
|
-
|
|
73819
|
-
|
|
73949
|
+
AST11.exportNamedDeclaration(
|
|
73950
|
+
AST11.tsTypeAliasDeclaration(
|
|
73951
|
+
AST11.identifier(inputTypeName),
|
|
73952
|
+
AST11.tsTypeLiteral(
|
|
73820
73953
|
(definition.variableDefinitions || []).map(
|
|
73821
73954
|
(definition2) => {
|
|
73822
|
-
return
|
|
73823
|
-
|
|
73824
|
-
|
|
73955
|
+
return AST11.tsPropertySignature(
|
|
73956
|
+
AST11.identifier(definition2.variable.name.value),
|
|
73957
|
+
AST11.tsTypeAnnotation(
|
|
73825
73958
|
tsTypeReference(config2, missingScalars, definition2)
|
|
73826
73959
|
),
|
|
73827
73960
|
definition2.type.kind !== "NonNullType"
|
|
@@ -73834,16 +73967,16 @@ async function generateOperationTypeDefs(config2, filepath, body, definition, se
|
|
|
73834
73967
|
);
|
|
73835
73968
|
} else {
|
|
73836
73969
|
body.push(
|
|
73837
|
-
|
|
73838
|
-
|
|
73970
|
+
AST11.exportNamedDeclaration(
|
|
73971
|
+
AST11.tsTypeAliasDeclaration(AST11.identifier(inputTypeName), AST11.tsNullKeyword())
|
|
73839
73972
|
)
|
|
73840
73973
|
);
|
|
73841
73974
|
}
|
|
73842
73975
|
if (definition.operation === "mutation") {
|
|
73843
73976
|
body.push(
|
|
73844
|
-
|
|
73845
|
-
|
|
73846
|
-
|
|
73977
|
+
AST11.exportNamedDeclaration(
|
|
73978
|
+
AST11.tsTypeAliasDeclaration(
|
|
73979
|
+
AST11.identifier(optimisticTypeName),
|
|
73847
73980
|
inlineType({
|
|
73848
73981
|
config: config2,
|
|
73849
73982
|
filepath,
|
|
@@ -73869,65 +74002,463 @@ async function generateFragmentTypeDefs(config2, filepath, body, selections, def
|
|
|
73869
74002
|
}
|
|
73870
74003
|
const propTypeName = definition.name.value;
|
|
73871
74004
|
const shapeTypeName = `${definition.name.value}$data`;
|
|
74005
|
+
const inputTypeName = `${definition.name.value}$input`;
|
|
73872
74006
|
const type = config2.schema.getType(definition.typeCondition.name.value);
|
|
73873
74007
|
if (!type) {
|
|
73874
74008
|
throw new Error("Should not get here");
|
|
73875
74009
|
}
|
|
74010
|
+
let extraExports = [];
|
|
74011
|
+
let directive = definition.directives?.find(
|
|
74012
|
+
(directive2) => directive2.name.value === config2.argumentsDirective
|
|
74013
|
+
);
|
|
74014
|
+
if (directive) {
|
|
74015
|
+
extraExports.push(
|
|
74016
|
+
AST11.exportNamedDeclaration(
|
|
74017
|
+
AST11.tsTypeAliasDeclaration(
|
|
74018
|
+
AST11.identifier(inputTypeName),
|
|
74019
|
+
AST11.tsTypeLiteral(
|
|
74020
|
+
(fragmentArgumentsDefinitions(config2, filepath, definition) || []).map(
|
|
74021
|
+
(definition2) => {
|
|
74022
|
+
return AST11.tsPropertySignature(
|
|
74023
|
+
AST11.identifier(definition2.variable.name.value),
|
|
74024
|
+
AST11.tsTypeAnnotation(
|
|
74025
|
+
tsTypeReference(config2, missingScalars, definition2)
|
|
74026
|
+
),
|
|
74027
|
+
definition2.type.kind !== "NonNullType"
|
|
74028
|
+
);
|
|
74029
|
+
}
|
|
74030
|
+
)
|
|
74031
|
+
)
|
|
74032
|
+
)
|
|
74033
|
+
)
|
|
74034
|
+
);
|
|
74035
|
+
}
|
|
73876
74036
|
body.push(
|
|
73877
|
-
|
|
73878
|
-
|
|
73879
|
-
|
|
73880
|
-
|
|
74037
|
+
...extraExports,
|
|
74038
|
+
AST11.exportNamedDeclaration(
|
|
74039
|
+
AST11.tsTypeAliasDeclaration(
|
|
74040
|
+
AST11.identifier(propTypeName),
|
|
74041
|
+
AST11.tsTypeLiteral([
|
|
73881
74042
|
readonlyProperty(
|
|
73882
|
-
|
|
73883
|
-
|
|
73884
|
-
|
|
73885
|
-
|
|
74043
|
+
AST11.tsPropertySignature(
|
|
74044
|
+
AST11.stringLiteral("shape"),
|
|
74045
|
+
AST11.tsTypeAnnotation(
|
|
74046
|
+
AST11.tsTypeReference(AST11.identifier(shapeTypeName))
|
|
73886
74047
|
),
|
|
73887
74048
|
true
|
|
73888
74049
|
)
|
|
73889
74050
|
),
|
|
73890
74051
|
readonlyProperty(
|
|
73891
|
-
|
|
73892
|
-
|
|
74052
|
+
AST11.tsPropertySignature(
|
|
74053
|
+
AST11.stringLiteral(fragmentKey),
|
|
74054
|
+
AST11.tsTypeAnnotation(
|
|
74055
|
+
AST11.tsTypeLiteral([
|
|
74056
|
+
AST11.tsPropertySignature(
|
|
74057
|
+
AST11.stringLiteral(propTypeName),
|
|
74058
|
+
AST11.tsTypeAnnotation(
|
|
74059
|
+
AST11.tsLiteralType(AST11.booleanLiteral(true))
|
|
74060
|
+
)
|
|
74061
|
+
)
|
|
74062
|
+
])
|
|
74063
|
+
)
|
|
74064
|
+
)
|
|
74065
|
+
)
|
|
74066
|
+
])
|
|
74067
|
+
)
|
|
74068
|
+
),
|
|
74069
|
+
AST11.exportNamedDeclaration(
|
|
74070
|
+
AST11.tsTypeAliasDeclaration(
|
|
74071
|
+
AST11.identifier(shapeTypeName),
|
|
74072
|
+
inlineType({
|
|
74073
|
+
config: config2,
|
|
74074
|
+
filepath,
|
|
74075
|
+
rootType: type,
|
|
74076
|
+
selections,
|
|
74077
|
+
root: true,
|
|
74078
|
+
allowReadonly: true,
|
|
74079
|
+
body,
|
|
74080
|
+
visitedTypes,
|
|
74081
|
+
missingScalars,
|
|
74082
|
+
includeFragments: true
|
|
74083
|
+
})
|
|
74084
|
+
)
|
|
74085
|
+
)
|
|
74086
|
+
);
|
|
74087
|
+
}
|
|
74088
|
+
}
|
|
74089
|
+
|
|
74090
|
+
// src/codegen/generators/typescript/imperativeTypeDef.ts
|
|
74091
|
+
var graphql19 = __toESM(require_graphql2(), 1);
|
|
74092
|
+
var recast12 = __toESM(require_main2(), 1);
|
|
74093
|
+
var AST12 = recast12.types.builders;
|
|
74094
|
+
async function imperativeCacheTypef(config2, docs) {
|
|
74095
|
+
const returnType = (doc) => config2.plugins.find((plugin) => plugin.graphql_tag_return)?.graphql_tag_return?.({
|
|
74096
|
+
config: config2,
|
|
74097
|
+
doc,
|
|
74098
|
+
ensure_import({ identifier, module }) {
|
|
74099
|
+
ensureImports({
|
|
74100
|
+
config: config2,
|
|
74101
|
+
body,
|
|
74102
|
+
sourceModule: module,
|
|
74103
|
+
import: [identifier]
|
|
74104
|
+
});
|
|
74105
|
+
}
|
|
74106
|
+
}) ?? "any";
|
|
74107
|
+
const target = path_exports.join(config2.runtimeDirectory, "generated.d.ts");
|
|
74108
|
+
const body = [];
|
|
74109
|
+
const declaration = AST12.tsTypeAliasDeclaration(
|
|
74110
|
+
AST12.identifier(CacheTypeDefName),
|
|
74111
|
+
AST12.tsTypeLiteral([
|
|
74112
|
+
AST12.tsPropertySignature(
|
|
74113
|
+
AST12.identifier("types"),
|
|
74114
|
+
AST12.tsTypeAnnotation(typeDefinitions(config2, body, docs, returnType))
|
|
74115
|
+
),
|
|
74116
|
+
AST12.tsPropertySignature(
|
|
74117
|
+
AST12.identifier("lists"),
|
|
74118
|
+
AST12.tsTypeAnnotation(listDefinitions(config2, docs))
|
|
74119
|
+
),
|
|
74120
|
+
AST12.tsPropertySignature(
|
|
74121
|
+
AST12.identifier("queries"),
|
|
74122
|
+
AST12.tsTypeAnnotation(queryDefinitions(config2, body, docs, returnType))
|
|
74123
|
+
)
|
|
74124
|
+
])
|
|
74125
|
+
);
|
|
74126
|
+
declaration.declare = true;
|
|
74127
|
+
const importRecord = AST12.importDeclaration(
|
|
74128
|
+
[AST12.importSpecifier(AST12.identifier("Record"))],
|
|
74129
|
+
AST12.stringLiteral("./public/record")
|
|
74130
|
+
);
|
|
74131
|
+
importRecord.importKind = "type";
|
|
74132
|
+
await fs_exports.writeFile(
|
|
74133
|
+
target,
|
|
74134
|
+
recast12.prettyPrint(
|
|
74135
|
+
AST12.program([importRecord, ...body, AST12.exportNamedDeclaration(declaration)])
|
|
74136
|
+
).code
|
|
74137
|
+
);
|
|
74138
|
+
}
|
|
74139
|
+
function typeDefinitions(config2, body, docs, returnType) {
|
|
74140
|
+
const operationTypes = [config2.schema.getMutationType(), config2.schema.getSubscriptionType()].filter(Boolean).map((type) => type?.name);
|
|
74141
|
+
const visitedTypes = /* @__PURE__ */ new Set();
|
|
74142
|
+
const types16 = Object.values(config2.schema.getTypeMap()).filter(
|
|
74143
|
+
(type) => !graphql19.isAbstractType(type) && !graphql19.isScalarType(type) && !graphql19.isEnumType(type) && !graphql19.isInputObjectType(type) && !type.name.startsWith("__") && !operationTypes.includes(type.name)
|
|
74144
|
+
);
|
|
74145
|
+
const fragmentMap = fragmentListMap(
|
|
74146
|
+
config2,
|
|
74147
|
+
types16.map((type) => type.name),
|
|
74148
|
+
body,
|
|
74149
|
+
docs,
|
|
74150
|
+
returnType
|
|
74151
|
+
);
|
|
74152
|
+
return AST12.tsTypeLiteral(
|
|
74153
|
+
types16.map((type) => {
|
|
74154
|
+
let typeName = type.name;
|
|
74155
|
+
if (config2.schema.getQueryType() && config2.schema.getQueryType()?.name === type.name) {
|
|
74156
|
+
typeName = "__ROOT__";
|
|
74157
|
+
}
|
|
74158
|
+
let idFields = AST12.tsNeverKeyword();
|
|
74159
|
+
const keys = keyFieldsForType(config2.configFile, type.name);
|
|
74160
|
+
if (graphql19.isObjectType(type) && keys.length > 0 && keys.every((key) => type.getFields()[key])) {
|
|
74161
|
+
idFields = AST12.tsTypeLiteral(
|
|
74162
|
+
keys.map((key) => {
|
|
74163
|
+
const fieldType = type.getFields()[key];
|
|
74164
|
+
const unwrapped = unwrapType(config2, fieldType.type);
|
|
74165
|
+
return AST12.tsPropertySignature(
|
|
74166
|
+
AST12.identifier(key),
|
|
74167
|
+
AST12.tsTypeAnnotation(
|
|
74168
|
+
scalarPropertyValue(config2, /* @__PURE__ */ new Set(), unwrapped.type)
|
|
74169
|
+
)
|
|
74170
|
+
);
|
|
74171
|
+
})
|
|
74172
|
+
);
|
|
74173
|
+
} else if (typeName === "__ROOT__") {
|
|
74174
|
+
idFields = AST12.tsTypeLiteral([]);
|
|
74175
|
+
}
|
|
74176
|
+
let fields = AST12.tsTypeLiteral([]);
|
|
74177
|
+
if (graphql19.isObjectType(type)) {
|
|
74178
|
+
fields = AST12.tsTypeLiteral(
|
|
74179
|
+
Object.entries(type.getFields()).map(
|
|
74180
|
+
([key, fieldType]) => {
|
|
74181
|
+
const unwrapped = unwrapType(config2, fieldType.type);
|
|
74182
|
+
let typeOptions = AST12.tsUnionType([]);
|
|
74183
|
+
if (graphql19.isScalarType(unwrapped.type)) {
|
|
74184
|
+
typeOptions.types.push(
|
|
74185
|
+
scalarPropertyValue(config2, /* @__PURE__ */ new Set(), unwrapped.type)
|
|
74186
|
+
);
|
|
74187
|
+
} else if (graphql19.isEnumType(unwrapped.type)) {
|
|
74188
|
+
typeOptions.types.push(
|
|
74189
|
+
AST12.tsTypeReference(AST12.identifier(unwrapped.type.name))
|
|
74190
|
+
);
|
|
74191
|
+
} else if (!graphql19.isAbstractType(unwrapped.type)) {
|
|
74192
|
+
typeOptions.types.push(record(unwrapped.type.name));
|
|
74193
|
+
} else {
|
|
74194
|
+
typeOptions.types.push(
|
|
74195
|
+
...config2.schema.getPossibleTypes(unwrapped.type).map((type2) => record(type2.name))
|
|
74196
|
+
);
|
|
74197
|
+
}
|
|
74198
|
+
for (const wrapper of unwrapped.wrappers) {
|
|
74199
|
+
if (wrapper === "Nullable" /* Nullable */) {
|
|
74200
|
+
typeOptions = AST12.tsParenthesizedType(
|
|
74201
|
+
AST12.tsUnionType([typeOptions, AST12.tsNullKeyword()])
|
|
74202
|
+
);
|
|
74203
|
+
} else if (wrapper === "List" /* List */) {
|
|
74204
|
+
typeOptions = AST12.tsArrayType(
|
|
74205
|
+
AST12.tsParenthesizedType(typeOptions)
|
|
74206
|
+
);
|
|
74207
|
+
}
|
|
74208
|
+
}
|
|
74209
|
+
if (typeOptions.type === "TSParenthesizedType") {
|
|
74210
|
+
typeOptions = typeOptions.typeAnnotation;
|
|
74211
|
+
}
|
|
74212
|
+
let args = AST12.tsNeverKeyword();
|
|
74213
|
+
if (fieldType.args?.length > 0) {
|
|
74214
|
+
args = AST12.tsTypeLiteral(
|
|
74215
|
+
fieldType.args.map((arg) => {
|
|
74216
|
+
addReferencedInputTypes(
|
|
74217
|
+
config2,
|
|
74218
|
+
"",
|
|
74219
|
+
body,
|
|
74220
|
+
visitedTypes,
|
|
74221
|
+
/* @__PURE__ */ new Set(),
|
|
74222
|
+
arg.type
|
|
74223
|
+
);
|
|
74224
|
+
const prop = AST12.tsPropertySignature(
|
|
74225
|
+
AST12.identifier(arg.name),
|
|
74226
|
+
AST12.tsTypeAnnotation(
|
|
74227
|
+
tsTypeReference(config2, /* @__PURE__ */ new Set(), arg)
|
|
74228
|
+
)
|
|
74229
|
+
);
|
|
74230
|
+
const unwrapped2 = unwrapType(config2, arg.type);
|
|
74231
|
+
prop.optional = unwrapped2.wrappers[unwrapped2.wrappers.length - 1] === "Nullable" /* Nullable */;
|
|
74232
|
+
return prop;
|
|
74233
|
+
})
|
|
74234
|
+
);
|
|
74235
|
+
}
|
|
74236
|
+
return AST12.tsPropertySignature(
|
|
74237
|
+
AST12.identifier(key),
|
|
73893
74238
|
AST12.tsTypeAnnotation(
|
|
73894
74239
|
AST12.tsTypeLiteral([
|
|
73895
74240
|
AST12.tsPropertySignature(
|
|
73896
|
-
AST12.
|
|
73897
|
-
AST12.tsTypeAnnotation(
|
|
73898
|
-
|
|
73899
|
-
|
|
74241
|
+
AST12.identifier("type"),
|
|
74242
|
+
AST12.tsTypeAnnotation(typeOptions)
|
|
74243
|
+
),
|
|
74244
|
+
AST12.tsPropertySignature(
|
|
74245
|
+
AST12.identifier("args"),
|
|
74246
|
+
AST12.tsTypeAnnotation(args)
|
|
73900
74247
|
)
|
|
73901
74248
|
])
|
|
73902
74249
|
)
|
|
73903
|
-
)
|
|
74250
|
+
);
|
|
74251
|
+
}
|
|
74252
|
+
)
|
|
74253
|
+
);
|
|
74254
|
+
}
|
|
74255
|
+
return AST12.tsPropertySignature(
|
|
74256
|
+
AST12.identifier(typeName),
|
|
74257
|
+
AST12.tsTypeAnnotation(
|
|
74258
|
+
AST12.tsTypeLiteral([
|
|
74259
|
+
AST12.tsPropertySignature(
|
|
74260
|
+
AST12.identifier("idFields"),
|
|
74261
|
+
AST12.tsTypeAnnotation(idFields)
|
|
74262
|
+
),
|
|
74263
|
+
AST12.tsPropertySignature(
|
|
74264
|
+
AST12.identifier("fields"),
|
|
74265
|
+
AST12.tsTypeAnnotation(fields)
|
|
74266
|
+
),
|
|
74267
|
+
AST12.tsPropertySignature(
|
|
74268
|
+
AST12.identifier("fragments"),
|
|
74269
|
+
AST12.tsTypeAnnotation(fragmentMap[typeName] ?? AST12.tsTupleType([]))
|
|
73904
74270
|
)
|
|
73905
74271
|
])
|
|
73906
74272
|
)
|
|
74273
|
+
);
|
|
74274
|
+
})
|
|
74275
|
+
);
|
|
74276
|
+
}
|
|
74277
|
+
function listDefinitions(config2, docs) {
|
|
74278
|
+
const lists = [];
|
|
74279
|
+
const visitedLists = /* @__PURE__ */ new Set();
|
|
74280
|
+
for (const doc of docs) {
|
|
74281
|
+
graphql19.visit(doc.document, {
|
|
74282
|
+
Directive(node, key, parent, path2, ancestors) {
|
|
74283
|
+
if (![config2.listDirective, config2.paginateDirective].includes(node.name.value)) {
|
|
74284
|
+
return;
|
|
74285
|
+
}
|
|
74286
|
+
const nameArg = node.arguments?.find((arg) => arg.name.value === "name");
|
|
74287
|
+
const nameValue = nameArg?.value?.value || "";
|
|
74288
|
+
if (!nameValue || visitedLists.has(nameValue)) {
|
|
74289
|
+
return;
|
|
74290
|
+
}
|
|
74291
|
+
visitedLists.add(nameValue);
|
|
74292
|
+
const parentType = parentTypeFromAncestors(
|
|
74293
|
+
config2.schema,
|
|
74294
|
+
doc.filename,
|
|
74295
|
+
ancestors.slice(0, -1)
|
|
74296
|
+
);
|
|
74297
|
+
const targetField = ancestors[ancestors.length - 1];
|
|
74298
|
+
const targetFieldDefinition = parentType.getFields()[targetField.name.value];
|
|
74299
|
+
const { type: listType } = unwrapType(config2, targetFieldDefinition.type);
|
|
74300
|
+
const possibleTypes = [];
|
|
74301
|
+
if (graphql19.isAbstractType(listType)) {
|
|
74302
|
+
possibleTypes.push(
|
|
74303
|
+
...config2.schema.getPossibleTypes(listType).map((possible) => possible.name)
|
|
74304
|
+
);
|
|
74305
|
+
} else {
|
|
74306
|
+
possibleTypes.push(listType.name);
|
|
74307
|
+
}
|
|
74308
|
+
lists.push(
|
|
74309
|
+
AST12.tsPropertySignature(
|
|
74310
|
+
AST12.identifier(nameValue),
|
|
74311
|
+
AST12.tsTypeAnnotation(
|
|
74312
|
+
AST12.tsTypeLiteral([
|
|
74313
|
+
AST12.tsPropertySignature(
|
|
74314
|
+
AST12.identifier("types"),
|
|
74315
|
+
AST12.tsTypeAnnotation(
|
|
74316
|
+
AST12.tsUnionType(
|
|
74317
|
+
possibleTypes.map(
|
|
74318
|
+
(possible) => AST12.tsLiteralType(AST12.stringLiteral(possible))
|
|
74319
|
+
)
|
|
74320
|
+
)
|
|
74321
|
+
)
|
|
74322
|
+
),
|
|
74323
|
+
AST12.tsPropertySignature(
|
|
74324
|
+
AST12.identifier("filters"),
|
|
74325
|
+
AST12.tsTypeAnnotation(
|
|
74326
|
+
targetFieldDefinition.args.length === 0 ? AST12.tsNeverKeyword() : AST12.tsTypeLiteral(
|
|
74327
|
+
targetFieldDefinition.args.map((arg) => {
|
|
74328
|
+
const argDef = AST12.tsPropertySignature(
|
|
74329
|
+
AST12.identifier(arg.name),
|
|
74330
|
+
AST12.tsTypeAnnotation(
|
|
74331
|
+
tsTypeReference(
|
|
74332
|
+
config2,
|
|
74333
|
+
/* @__PURE__ */ new Set(),
|
|
74334
|
+
arg
|
|
74335
|
+
)
|
|
74336
|
+
)
|
|
74337
|
+
);
|
|
74338
|
+
argDef.optional = true;
|
|
74339
|
+
return argDef;
|
|
74340
|
+
})
|
|
74341
|
+
)
|
|
74342
|
+
)
|
|
74343
|
+
)
|
|
74344
|
+
])
|
|
74345
|
+
)
|
|
74346
|
+
)
|
|
74347
|
+
);
|
|
74348
|
+
}
|
|
74349
|
+
});
|
|
74350
|
+
}
|
|
74351
|
+
return AST12.tsTypeLiteral(lists);
|
|
74352
|
+
}
|
|
74353
|
+
function queryDefinitions(config2, body, docs, returnType) {
|
|
74354
|
+
return AST12.tsTupleType(
|
|
74355
|
+
docs.reduce((prev, doc) => {
|
|
74356
|
+
if (doc.kind !== "HoudiniQuery" /* Query */ || !doc.generateStore) {
|
|
74357
|
+
return prev;
|
|
74358
|
+
}
|
|
74359
|
+
const definition = doc.document.definitions.find(
|
|
74360
|
+
(def) => def.kind === "OperationDefinition" && def.operation === "query"
|
|
74361
|
+
);
|
|
74362
|
+
if (!definition) {
|
|
74363
|
+
return prev;
|
|
74364
|
+
}
|
|
74365
|
+
const runtimeType = returnType(doc);
|
|
74366
|
+
const [shapeType, inputType] = ensureImports({
|
|
74367
|
+
config: config2,
|
|
74368
|
+
body,
|
|
74369
|
+
sourceModule: path_exports.relative(
|
|
74370
|
+
config2.runtimeDirectory,
|
|
74371
|
+
config2.artifactImportPath(doc.name)
|
|
74372
|
+
),
|
|
74373
|
+
import: [`${doc.name}$result`, `${doc.name}$input`]
|
|
74374
|
+
});
|
|
74375
|
+
return prev.concat(
|
|
74376
|
+
AST12.tsTupleType([
|
|
74377
|
+
AST12.tsTypeReference(AST12.identifier(runtimeType)),
|
|
74378
|
+
AST12.tsTypeReference(AST12.identifier(shapeType)),
|
|
74379
|
+
AST12.tsTypeReference(AST12.identifier(inputType))
|
|
74380
|
+
])
|
|
74381
|
+
);
|
|
74382
|
+
}, [])
|
|
74383
|
+
);
|
|
74384
|
+
}
|
|
74385
|
+
function fragmentListMap(config2, concreteTypes, body, docs, return_type) {
|
|
74386
|
+
return docs.reduce((prev, doc) => {
|
|
74387
|
+
if (doc.kind !== "HoudiniFragment" /* Fragment */) {
|
|
74388
|
+
return prev;
|
|
74389
|
+
}
|
|
74390
|
+
const definition = doc.document.definitions.find(
|
|
74391
|
+
(def) => def.kind === "FragmentDefinition" && def.name.value === doc.name
|
|
74392
|
+
);
|
|
74393
|
+
if (!definition || !concreteTypes.includes(definition.typeCondition.name.value)) {
|
|
74394
|
+
return prev;
|
|
74395
|
+
}
|
|
74396
|
+
const typeName = definition.typeCondition.name.value;
|
|
74397
|
+
const previousValue = prev[typeName]?.elementTypes ?? [];
|
|
74398
|
+
const tagResult = return_type(doc);
|
|
74399
|
+
const [shapeType] = ensureImports({
|
|
74400
|
+
config: config2,
|
|
74401
|
+
body,
|
|
74402
|
+
sourceModule: path_exports.relative(
|
|
74403
|
+
config2.runtimeDirectory,
|
|
74404
|
+
config2.artifactImportPath(doc.name)
|
|
73907
74405
|
),
|
|
73908
|
-
|
|
73909
|
-
|
|
73910
|
-
|
|
73911
|
-
|
|
74406
|
+
import: [`${definition.name.value}$data`]
|
|
74407
|
+
});
|
|
74408
|
+
let inputType = AST12.tsNeverKeyword();
|
|
74409
|
+
let directive = definition.directives?.find(
|
|
74410
|
+
(directive2) => directive2.name.value === config2.argumentsDirective
|
|
74411
|
+
);
|
|
74412
|
+
if (directive) {
|
|
74413
|
+
inputType = AST12.tsTypeReference(
|
|
74414
|
+
AST12.identifier(
|
|
74415
|
+
ensureImports({
|
|
73912
74416
|
config: config2,
|
|
73913
|
-
filepath,
|
|
73914
|
-
rootType: type,
|
|
73915
|
-
selections,
|
|
73916
|
-
root: true,
|
|
73917
|
-
allowReadonly: true,
|
|
73918
74417
|
body,
|
|
73919
|
-
|
|
73920
|
-
|
|
73921
|
-
|
|
73922
|
-
|
|
74418
|
+
sourceModule: path_exports.relative(
|
|
74419
|
+
config2.runtimeDirectory,
|
|
74420
|
+
config2.artifactImportPath(doc.name)
|
|
74421
|
+
),
|
|
74422
|
+
import: [`${definition.name.value}$input`]
|
|
74423
|
+
})[0]
|
|
74424
|
+
)
|
|
74425
|
+
);
|
|
74426
|
+
}
|
|
74427
|
+
return {
|
|
74428
|
+
...prev,
|
|
74429
|
+
[typeName]: AST12.tsTupleType(
|
|
74430
|
+
previousValue.concat(
|
|
74431
|
+
AST12.tsTupleType([
|
|
74432
|
+
AST12.tsTypeReference(AST12.identifier(tagResult)),
|
|
74433
|
+
AST12.tsTypeReference(AST12.identifier(shapeType)),
|
|
74434
|
+
inputType
|
|
74435
|
+
])
|
|
73923
74436
|
)
|
|
73924
74437
|
)
|
|
73925
|
-
|
|
73926
|
-
}
|
|
74438
|
+
};
|
|
74439
|
+
}, {});
|
|
74440
|
+
}
|
|
74441
|
+
var CacheTypeDefName = "CacheTypeDef";
|
|
74442
|
+
function record(name2) {
|
|
74443
|
+
return AST12.tsTypeReference(
|
|
74444
|
+
AST12.identifier("Record"),
|
|
74445
|
+
AST12.tsTypeParameterInstantiation([
|
|
74446
|
+
AST12.tsTypeReference(AST12.identifier(CacheTypeDefName)),
|
|
74447
|
+
AST12.tsLiteralType(AST12.stringLiteral(name2))
|
|
74448
|
+
])
|
|
74449
|
+
);
|
|
74450
|
+
}
|
|
74451
|
+
|
|
74452
|
+
// src/codegen/generators/typescript/index.ts
|
|
74453
|
+
async function typescriptGenerator(config2, docs) {
|
|
74454
|
+
await Promise.all([
|
|
74455
|
+
generateDocumentTypes(config2, docs),
|
|
74456
|
+
imperativeCacheTypef(config2, docs)
|
|
74457
|
+
]);
|
|
73927
74458
|
}
|
|
73928
74459
|
|
|
73929
74460
|
// src/codegen/generators/persistedQueries/index.ts
|
|
73930
|
-
var
|
|
74461
|
+
var graphql20 = __toESM(require_graphql2(), 1);
|
|
73931
74462
|
async function persistOutputGenerator(config2, docs) {
|
|
73932
74463
|
if (typeof config2.persistedQueryPath !== "string" || config2.persistedQueryPath.length === 0)
|
|
73933
74464
|
return;
|
|
@@ -73939,8 +74470,8 @@ async function persistOutputGenerator(config2, docs) {
|
|
|
73939
74470
|
if (!generateArtifact) {
|
|
73940
74471
|
return acc;
|
|
73941
74472
|
}
|
|
73942
|
-
let rawString =
|
|
73943
|
-
|
|
74473
|
+
let rawString = graphql20.print(
|
|
74474
|
+
graphql20.visit(document, {
|
|
73944
74475
|
Directive(node) {
|
|
73945
74476
|
if (config2.isInternalDirective(node)) {
|
|
73946
74477
|
return null;
|
|
@@ -73949,7 +74480,7 @@ async function persistOutputGenerator(config2, docs) {
|
|
|
73949
74480
|
})
|
|
73950
74481
|
);
|
|
73951
74482
|
const operations = document.definitions.filter(
|
|
73952
|
-
({ kind }) => kind ===
|
|
74483
|
+
({ kind }) => kind === graphql20.Kind.OPERATION_DEFINITION
|
|
73953
74484
|
);
|
|
73954
74485
|
if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
|
|
73955
74486
|
acc[hashDocument(rawString)] = rawString;
|
|
@@ -73962,11 +74493,11 @@ async function persistOutputGenerator(config2, docs) {
|
|
|
73962
74493
|
}
|
|
73963
74494
|
|
|
73964
74495
|
// src/codegen/generators/definitions/enums.ts
|
|
73965
|
-
var
|
|
74496
|
+
var graphql21 = __toESM(require_graphql2(), 1);
|
|
73966
74497
|
var recast13 = __toESM(require_main2(), 1);
|
|
73967
74498
|
var AST13 = recast13.types.builders;
|
|
73968
74499
|
async function definitionsGenerator(config2) {
|
|
73969
|
-
const enums =
|
|
74500
|
+
const enums = graphql21.parse(graphql21.printSchema(config2.schema)).definitions.filter(
|
|
73970
74501
|
(definition) => definition.kind === "EnumTypeDefinition"
|
|
73971
74502
|
).filter((def) => !config2.isInternalEnum(def));
|
|
73972
74503
|
const runtimeDefinitions = recast13.print(
|
|
@@ -74040,107 +74571,24 @@ async function writeIndexFile2(config2, docs) {
|
|
|
74040
74571
|
export_default_as,
|
|
74041
74572
|
export_star_from,
|
|
74042
74573
|
plugin_root: config2.pluginDirectory(plugin.name),
|
|
74043
|
-
typedef: false,
|
|
74044
|
-
documents: docs
|
|
74045
|
-
});
|
|
74046
|
-
}
|
|
74047
|
-
if (plugin.include_runtime) {
|
|
74048
|
-
body += export_star_from({
|
|
74049
|
-
module: relative2(config2.pluginRuntimeDirectory(plugin.name))
|
|
74050
|
-
});
|
|
74051
|
-
}
|
|
74052
|
-
if (!plugin.index_file) {
|
|
74053
|
-
continue;
|
|
74054
|
-
}
|
|
74055
|
-
}
|
|
74056
|
-
await fs_exports.writeFile(path_exports.join(config2.rootDir, "index.js"), body);
|
|
74057
|
-
}
|
|
74058
|
-
|
|
74059
|
-
// src/codegen/transforms/composeQueries.ts
|
|
74060
|
-
var import_graphql30 = __toESM(require_graphql2(), 1);
|
|
74061
|
-
async function includeFragmentDefinitions(config2, documents) {
|
|
74062
|
-
const fragments = collectFragments(config2, documents);
|
|
74063
|
-
for (const [index, { name: name2, document, filename }] of documents.entries()) {
|
|
74064
|
-
const operation = document.definitions.find(
|
|
74065
|
-
({ kind }) => kind === import_graphql30.Kind.OPERATION_DEFINITION
|
|
74066
|
-
);
|
|
74067
|
-
if (!operation) {
|
|
74068
|
-
continue;
|
|
74069
|
-
}
|
|
74070
|
-
const allFragments = flattenFragments(
|
|
74071
|
-
filename,
|
|
74072
|
-
{ requiredFragments: findRequiredFragments(operation.selectionSet) },
|
|
74073
|
-
fragments
|
|
74074
|
-
);
|
|
74075
|
-
documents[index].document = {
|
|
74076
|
-
...document,
|
|
74077
|
-
definitions: [
|
|
74078
|
-
operation,
|
|
74079
|
-
...allFragments.map((fragmentName) => fragments[fragmentName].definition)
|
|
74080
|
-
]
|
|
74081
|
-
};
|
|
74082
|
-
}
|
|
74083
|
-
}
|
|
74084
|
-
function collectFragments(config2, docs) {
|
|
74085
|
-
return docs.reduce((acc, doc) => {
|
|
74086
|
-
const definitions = doc.document.definitions.reduce(
|
|
74087
|
-
(prev, definition) => definition.kind !== "FragmentDefinition" ? prev : {
|
|
74088
|
-
...prev,
|
|
74089
|
-
[definition.name.value]: {
|
|
74090
|
-
definition,
|
|
74091
|
-
requiredFragments: findRequiredFragments(definition.selectionSet),
|
|
74092
|
-
document: doc
|
|
74093
|
-
}
|
|
74094
|
-
},
|
|
74095
|
-
{}
|
|
74096
|
-
);
|
|
74097
|
-
return {
|
|
74098
|
-
...acc,
|
|
74099
|
-
...definitions
|
|
74100
|
-
};
|
|
74101
|
-
}, {});
|
|
74102
|
-
}
|
|
74103
|
-
function findRequiredFragments(selectionSet) {
|
|
74104
|
-
if (selectionSet.selections.length === 0) {
|
|
74105
|
-
return [];
|
|
74106
|
-
}
|
|
74107
|
-
const referencedFragments = [];
|
|
74108
|
-
for (const selection2 of selectionSet.selections) {
|
|
74109
|
-
if (selection2.kind === import_graphql30.Kind.FRAGMENT_SPREAD) {
|
|
74110
|
-
referencedFragments.push(selection2.name.value);
|
|
74111
|
-
} else if (selection2.selectionSet) {
|
|
74112
|
-
referencedFragments.push(...findRequiredFragments(selection2.selectionSet));
|
|
74113
|
-
}
|
|
74114
|
-
}
|
|
74115
|
-
return referencedFragments;
|
|
74116
|
-
}
|
|
74117
|
-
function flattenFragments(filepath, operation, fragments) {
|
|
74118
|
-
const frags = /* @__PURE__ */ new Set();
|
|
74119
|
-
const remaining = [...operation.requiredFragments];
|
|
74120
|
-
while (remaining.length > 0) {
|
|
74121
|
-
const nextFragment = remaining.shift();
|
|
74122
|
-
if (!nextFragment) {
|
|
74123
|
-
continue;
|
|
74124
|
-
}
|
|
74125
|
-
if (!frags.has(nextFragment)) {
|
|
74126
|
-
frags.add(nextFragment);
|
|
74127
|
-
} else {
|
|
74128
|
-
continue;
|
|
74574
|
+
typedef: false,
|
|
74575
|
+
documents: docs
|
|
74576
|
+
});
|
|
74129
74577
|
}
|
|
74130
|
-
|
|
74131
|
-
|
|
74132
|
-
|
|
74133
|
-
filepath,
|
|
74134
|
-
message: "compose: could not find definition for fragment " + nextFragment
|
|
74578
|
+
if (plugin.include_runtime) {
|
|
74579
|
+
body += export_star_from({
|
|
74580
|
+
module: relative2(config2.pluginRuntimeDirectory(plugin.name))
|
|
74135
74581
|
});
|
|
74136
74582
|
}
|
|
74137
|
-
|
|
74583
|
+
if (!plugin.index_file) {
|
|
74584
|
+
continue;
|
|
74585
|
+
}
|
|
74138
74586
|
}
|
|
74139
|
-
|
|
74587
|
+
await fs_exports.writeFile(path_exports.join(config2.rootDir, "index.js"), body);
|
|
74140
74588
|
}
|
|
74141
74589
|
|
|
74142
74590
|
// src/codegen/transforms/schema.ts
|
|
74143
|
-
var
|
|
74591
|
+
var graphql22 = __toESM(require_graphql2(), 1);
|
|
74144
74592
|
async function graphqlExtensions(config2, documents) {
|
|
74145
74593
|
const internalSchema = `
|
|
74146
74594
|
enum CachePolicy {
|
|
@@ -74174,407 +74622,147 @@ directive @${config2.listAppendDirective} on FRAGMENT_SPREAD
|
|
|
74174
74622
|
|
|
74175
74623
|
"""
|
|
74176
74624
|
@${config2.listAllListsDirective} is used to tell the runtime to add the result to all list
|
|
74177
|
-
"""
|
|
74178
|
-
directive @${config2.listAllListsDirective} on FRAGMENT_SPREAD
|
|
74179
|
-
|
|
74180
|
-
"""
|
|
74181
|
-
@${config2.listParentDirective} is used to provide a parentID without specifying position or in situations
|
|
74182
|
-
where it doesn't make sense (eg when deleting a node.)
|
|
74183
|
-
"""
|
|
74184
|
-
directive @${config2.listParentDirective}(value: ID!) on FRAGMENT_SPREAD
|
|
74185
|
-
|
|
74186
|
-
"""
|
|
74187
|
-
@${config2.whenDirective} is used to provide a conditional or in situations where it doesn't make sense (eg when removing or deleting a node.)
|
|
74188
|
-
"""
|
|
74189
|
-
directive @${config2.whenDirective} on FRAGMENT_SPREAD
|
|
74190
|
-
|
|
74191
|
-
"""
|
|
74192
|
-
@${config2.whenNotDirective} is used to provide a conditional or in situations where it doesn't make sense (eg when removing or deleting a node.)
|
|
74193
|
-
"""
|
|
74194
|
-
directive @${config2.whenNotDirective} on FRAGMENT_SPREAD
|
|
74195
|
-
|
|
74196
|
-
"""
|
|
74197
|
-
@${config2.argumentsDirective} is used to define the arguments of a fragment
|
|
74198
|
-
"""
|
|
74199
|
-
directive @${config2.argumentsDirective} on FRAGMENT_DEFINITION
|
|
74200
|
-
|
|
74201
|
-
"""
|
|
74202
|
-
@${config2.cacheDirective} is used to specify cache rules for a query
|
|
74203
|
-
"""
|
|
74204
|
-
directive @${config2.cacheDirective}(${config2.cachePolicyArg}: CachePolicy, ${config2.cachePartialArg}: Boolean) on QUERY
|
|
74205
|
-
|
|
74206
|
-
"""
|
|
74207
|
-
@${config2.
|
|
74208
|
-
"""
|
|
74209
|
-
directive @${config2.
|
|
74210
|
-
|
|
74211
|
-
"""
|
|
74212
|
-
@${config2.maskEnableDirective} to enable masking on fragment (overwriting the global conf)
|
|
74213
|
-
"""
|
|
74214
|
-
directive @${config2.maskEnableDirective} on FRAGMENT_SPREAD
|
|
74215
|
-
|
|
74216
|
-
"""
|
|
74217
|
-
@${config2.maskDisableDirective} to disable masking on fragment (overwriting the global conf)
|
|
74218
|
-
"""
|
|
74219
|
-
directive @${config2.maskDisableDirective} on FRAGMENT_SPREAD
|
|
74220
|
-
`;
|
|
74221
|
-
let currentSchema =
|
|
74222
|
-
if (!currentSchema.includes(`directive @${config2.listDirective}`)) {
|
|
74223
|
-
currentSchema += internalSchema;
|
|
74224
|
-
}
|
|
74225
|
-
config2.newSchema += internalSchema;
|
|
74226
|
-
config2.schema =
|
|
74227
|
-
}
|
|
74228
|
-
|
|
74229
|
-
// src/codegen/transforms/typename.ts
|
|
74230
|
-
var
|
|
74231
|
-
async function addTypename(config2, documents) {
|
|
74232
|
-
for (const doc of documents) {
|
|
74233
|
-
doc.document =
|
|
74234
|
-
Field(node, key, parent, path2, ancestors) {
|
|
74235
|
-
if (!node.selectionSet) {
|
|
74236
|
-
return;
|
|
74237
|
-
}
|
|
74238
|
-
const type = parentTypeFromAncestors(
|
|
74239
|
-
config2.schema,
|
|
74240
|
-
doc.filename,
|
|
74241
|
-
ancestors.slice(0, -1)
|
|
74242
|
-
);
|
|
74243
|
-
const field = type.getFields()[node.name.value];
|
|
74244
|
-
const fieldType = unwrapType(config2, field.type).type;
|
|
74245
|
-
if (graphql22.isInterfaceType(fieldType) || graphql22.isUnionType(fieldType)) {
|
|
74246
|
-
return {
|
|
74247
|
-
...node,
|
|
74248
|
-
selectionSet: {
|
|
74249
|
-
...node.selectionSet,
|
|
74250
|
-
selections: [
|
|
74251
|
-
...node.selectionSet.selections,
|
|
74252
|
-
{
|
|
74253
|
-
kind: graphql22.Kind.FIELD,
|
|
74254
|
-
name: {
|
|
74255
|
-
kind: graphql22.Kind.NAME,
|
|
74256
|
-
value: "__typename"
|
|
74257
|
-
}
|
|
74258
|
-
}
|
|
74259
|
-
]
|
|
74260
|
-
}
|
|
74261
|
-
};
|
|
74262
|
-
}
|
|
74263
|
-
}
|
|
74264
|
-
});
|
|
74265
|
-
}
|
|
74266
|
-
}
|
|
74267
|
-
|
|
74268
|
-
// src/codegen/transforms/addID.ts
|
|
74269
|
-
var graphql23 = __toESM(require_graphql2(), 1);
|
|
74270
|
-
async function addID(config2, documents) {
|
|
74271
|
-
for (const doc of documents) {
|
|
74272
|
-
doc.document = graphql23.visit(doc.document, {
|
|
74273
|
-
Field(node, key, parent, path2, ancestors) {
|
|
74274
|
-
if (!node.selectionSet) {
|
|
74275
|
-
return;
|
|
74276
|
-
}
|
|
74277
|
-
const type = parentTypeFromAncestors(
|
|
74278
|
-
config2.schema,
|
|
74279
|
-
doc.filename,
|
|
74280
|
-
ancestors.slice(0, -1)
|
|
74281
|
-
);
|
|
74282
|
-
const field = type.getFields()[node.name.value];
|
|
74283
|
-
const fieldType = unwrapType(config2, field.type).type;
|
|
74284
|
-
if (node.selectionSet?.selections.length > 0) {
|
|
74285
|
-
if (!graphql23.isObjectType(fieldType) && !graphql23.isInterfaceType(fieldType)) {
|
|
74286
|
-
return;
|
|
74287
|
-
}
|
|
74288
|
-
const keyFields = config2.keyFieldsForType(fieldType.name);
|
|
74289
|
-
if (keyFields.find((key2) => !fieldType.getFields()[key2])) {
|
|
74290
|
-
return;
|
|
74291
|
-
}
|
|
74292
|
-
const selections = [...node.selectionSet.selections];
|
|
74293
|
-
for (const keyField of keyFields) {
|
|
74294
|
-
if (node.selectionSet.selections.find(
|
|
74295
|
-
(selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
|
|
74296
|
-
)) {
|
|
74297
|
-
continue;
|
|
74298
|
-
}
|
|
74299
|
-
selections.push({
|
|
74300
|
-
kind: graphql23.Kind.FIELD,
|
|
74301
|
-
name: {
|
|
74302
|
-
kind: graphql23.Kind.NAME,
|
|
74303
|
-
value: keyField
|
|
74304
|
-
}
|
|
74305
|
-
});
|
|
74306
|
-
}
|
|
74307
|
-
return {
|
|
74308
|
-
...node,
|
|
74309
|
-
selectionSet: {
|
|
74310
|
-
...node.selectionSet,
|
|
74311
|
-
selections
|
|
74312
|
-
}
|
|
74313
|
-
};
|
|
74314
|
-
}
|
|
74315
|
-
}
|
|
74316
|
-
});
|
|
74317
|
-
}
|
|
74318
|
-
}
|
|
74319
|
-
|
|
74320
|
-
// src/codegen/transforms/fragmentVariables.ts
|
|
74321
|
-
var graphql24 = __toESM(require_graphql2(), 1);
|
|
74322
|
-
var GraphqlKinds2 = graphql24.Kind;
|
|
74323
|
-
async function fragmentVariables(config2, documents) {
|
|
74324
|
-
const fragments = collectFragments(config2, documents);
|
|
74325
|
-
const generatedFragments = {};
|
|
74326
|
-
const visitedFragments = /* @__PURE__ */ new Set();
|
|
74327
|
-
for (const doc2 of documents) {
|
|
74328
|
-
const operation = doc2.document.definitions.find(
|
|
74329
|
-
({ kind }) => kind === GraphqlKinds2.OPERATION_DEFINITION
|
|
74330
|
-
);
|
|
74331
|
-
if (!operation) {
|
|
74332
|
-
continue;
|
|
74333
|
-
}
|
|
74334
|
-
doc2.document = inlineFragmentArgs({
|
|
74335
|
-
config: config2,
|
|
74336
|
-
filepath: doc2.filename,
|
|
74337
|
-
fragmentDefinitions: fragments,
|
|
74338
|
-
document: doc2.document,
|
|
74339
|
-
generatedFragments,
|
|
74340
|
-
visitedFragments,
|
|
74341
|
-
scope: null
|
|
74342
|
-
});
|
|
74343
|
-
}
|
|
74344
|
-
const doc = {
|
|
74345
|
-
kind: graphql24.Kind.DOCUMENT,
|
|
74346
|
-
definitions: Object.values(generatedFragments)
|
|
74347
|
-
};
|
|
74348
|
-
documents.push({
|
|
74349
|
-
name: "generated::fragmentVariables",
|
|
74350
|
-
kind: "HoudiniFragment" /* Fragment */,
|
|
74351
|
-
document: doc,
|
|
74352
|
-
originalDocument: doc,
|
|
74353
|
-
generateStore: false,
|
|
74354
|
-
generateArtifact: false,
|
|
74355
|
-
filename: "generated::fragmentVariables",
|
|
74356
|
-
originalString: ""
|
|
74357
|
-
});
|
|
74358
|
-
}
|
|
74359
|
-
function inlineFragmentArgs({
|
|
74360
|
-
config: config2,
|
|
74361
|
-
filepath,
|
|
74362
|
-
fragmentDefinitions,
|
|
74363
|
-
document,
|
|
74364
|
-
generatedFragments,
|
|
74365
|
-
visitedFragments,
|
|
74366
|
-
scope,
|
|
74367
|
-
newName
|
|
74368
|
-
}) {
|
|
74369
|
-
if (!scope) {
|
|
74370
|
-
scope = operationScope(
|
|
74371
|
-
document.definitions.find(
|
|
74372
|
-
({ kind }) => kind === GraphqlKinds2.OPERATION_DEFINITION
|
|
74373
|
-
)
|
|
74374
|
-
);
|
|
74375
|
-
}
|
|
74376
|
-
const definitionArgs = fragmentArguments(
|
|
74377
|
-
config2,
|
|
74378
|
-
filepath,
|
|
74379
|
-
document
|
|
74380
|
-
).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
|
|
74381
|
-
const result = graphql24.visit(document, {
|
|
74382
|
-
FragmentSpread(node) {
|
|
74383
|
-
const { definition } = fragmentDefinitions[node.name.value];
|
|
74384
|
-
let { args, hash } = collectWithArguments(config2, filepath, node, scope);
|
|
74385
|
-
const newFragmentName = `${node.name.value}${hash}`;
|
|
74386
|
-
if (!visitedFragments.has(newFragmentName)) {
|
|
74387
|
-
visitedFragments.add(newFragmentName);
|
|
74388
|
-
const defaultArguments = collectDefaultArgumentValues(config2, filepath, definition);
|
|
74389
|
-
if (args) {
|
|
74390
|
-
for (const [field, value] of Object.entries(defaultArguments || {})) {
|
|
74391
|
-
if (!args[field]) {
|
|
74392
|
-
args[field] = value;
|
|
74393
|
-
}
|
|
74394
|
-
}
|
|
74395
|
-
generatedFragments[newFragmentName] = inlineFragmentArgs({
|
|
74396
|
-
config: config2,
|
|
74397
|
-
filepath,
|
|
74398
|
-
fragmentDefinitions,
|
|
74399
|
-
document: fragmentDefinitions[node.name.value].definition,
|
|
74400
|
-
generatedFragments,
|
|
74401
|
-
visitedFragments,
|
|
74402
|
-
scope: args,
|
|
74403
|
-
newName: newFragmentName
|
|
74404
|
-
});
|
|
74405
|
-
} else {
|
|
74406
|
-
const doc = fragmentDefinitions[node.name.value].document;
|
|
74407
|
-
const definitionIndex = doc.document.definitions.findIndex(
|
|
74408
|
-
(definition2) => definition2.kind === "FragmentDefinition" && definition2.name.value === node.name.value
|
|
74409
|
-
);
|
|
74410
|
-
const localDefinitions = [...doc.document.definitions];
|
|
74411
|
-
localDefinitions.splice(definitionIndex, 1);
|
|
74412
|
-
localDefinitions.push(
|
|
74413
|
-
inlineFragmentArgs({
|
|
74414
|
-
config: config2,
|
|
74415
|
-
filepath,
|
|
74416
|
-
fragmentDefinitions,
|
|
74417
|
-
document: fragmentDefinitions[node.name.value].definition,
|
|
74418
|
-
generatedFragments,
|
|
74419
|
-
visitedFragments,
|
|
74420
|
-
scope: defaultArguments,
|
|
74421
|
-
newName: ""
|
|
74422
|
-
})
|
|
74423
|
-
);
|
|
74424
|
-
doc.document = {
|
|
74425
|
-
...doc.document,
|
|
74426
|
-
definitions: localDefinitions
|
|
74427
|
-
};
|
|
74625
|
+
"""
|
|
74626
|
+
directive @${config2.listAllListsDirective} on FRAGMENT_SPREAD
|
|
74627
|
+
|
|
74628
|
+
"""
|
|
74629
|
+
@${config2.listParentDirective} is used to provide a parentID without specifying position or in situations
|
|
74630
|
+
where it doesn't make sense (eg when deleting a node.)
|
|
74631
|
+
"""
|
|
74632
|
+
directive @${config2.listParentDirective}(value: ID!) on FRAGMENT_SPREAD
|
|
74633
|
+
|
|
74634
|
+
"""
|
|
74635
|
+
@${config2.whenDirective} is used to provide a conditional or in situations where it doesn't make sense (eg when removing or deleting a node.)
|
|
74636
|
+
"""
|
|
74637
|
+
directive @${config2.whenDirective} on FRAGMENT_SPREAD
|
|
74638
|
+
|
|
74639
|
+
"""
|
|
74640
|
+
@${config2.whenNotDirective} is used to provide a conditional or in situations where it doesn't make sense (eg when removing or deleting a node.)
|
|
74641
|
+
"""
|
|
74642
|
+
directive @${config2.whenNotDirective} on FRAGMENT_SPREAD
|
|
74643
|
+
|
|
74644
|
+
"""
|
|
74645
|
+
@${config2.argumentsDirective} is used to define the arguments of a fragment
|
|
74646
|
+
"""
|
|
74647
|
+
directive @${config2.argumentsDirective} on FRAGMENT_DEFINITION
|
|
74648
|
+
|
|
74649
|
+
"""
|
|
74650
|
+
@${config2.cacheDirective} is used to specify cache rules for a query
|
|
74651
|
+
"""
|
|
74652
|
+
directive @${config2.cacheDirective}(${config2.cachePolicyArg}: CachePolicy, ${config2.cachePartialArg}: Boolean) on QUERY
|
|
74653
|
+
|
|
74654
|
+
"""
|
|
74655
|
+
@${config2.loadDirective} is used to disable automatic fetch (no load, no auto fetch in component), you will have to do it manually.
|
|
74656
|
+
"""
|
|
74657
|
+
directive @${config2.loadDirective} on QUERY
|
|
74658
|
+
|
|
74659
|
+
"""
|
|
74660
|
+
@${config2.maskEnableDirective} to enable masking on fragment (overwriting the global conf)
|
|
74661
|
+
"""
|
|
74662
|
+
directive @${config2.maskEnableDirective} on FRAGMENT_SPREAD
|
|
74663
|
+
|
|
74664
|
+
"""
|
|
74665
|
+
@${config2.maskDisableDirective} to disable masking on fragment (overwriting the global conf)
|
|
74666
|
+
"""
|
|
74667
|
+
directive @${config2.maskDisableDirective} on FRAGMENT_SPREAD
|
|
74668
|
+
`;
|
|
74669
|
+
let currentSchema = graphql22.printSchema(config2.schema);
|
|
74670
|
+
if (!currentSchema.includes(`directive @${config2.listDirective}`)) {
|
|
74671
|
+
currentSchema += internalSchema;
|
|
74672
|
+
}
|
|
74673
|
+
config2.newSchema += internalSchema;
|
|
74674
|
+
config2.schema = graphql22.buildSchema(currentSchema);
|
|
74675
|
+
}
|
|
74676
|
+
|
|
74677
|
+
// src/codegen/transforms/typename.ts
|
|
74678
|
+
var graphql23 = __toESM(require_graphql2(), 1);
|
|
74679
|
+
async function addTypename(config2, documents) {
|
|
74680
|
+
for (const doc of documents) {
|
|
74681
|
+
doc.document = graphql23.visit(doc.document, {
|
|
74682
|
+
Field(node, key, parent, path2, ancestors) {
|
|
74683
|
+
if (!node.selectionSet) {
|
|
74684
|
+
return;
|
|
74428
74685
|
}
|
|
74429
|
-
|
|
74686
|
+
const type = parentTypeFromAncestors(
|
|
74687
|
+
config2.schema,
|
|
74688
|
+
doc.filename,
|
|
74689
|
+
ancestors.slice(0, -1)
|
|
74690
|
+
);
|
|
74691
|
+
const field = type.getFields()[node.name.value];
|
|
74692
|
+
const fieldType = unwrapType(config2, field.type).type;
|
|
74693
|
+
if (graphql23.isInterfaceType(fieldType) || graphql23.isUnionType(fieldType)) {
|
|
74430
74694
|
return {
|
|
74431
74695
|
...node,
|
|
74432
|
-
|
|
74433
|
-
|
|
74434
|
-
|
|
74696
|
+
selectionSet: {
|
|
74697
|
+
...node.selectionSet,
|
|
74698
|
+
selections: [
|
|
74699
|
+
...node.selectionSet.selections,
|
|
74700
|
+
{
|
|
74701
|
+
kind: graphql23.Kind.FIELD,
|
|
74702
|
+
name: {
|
|
74703
|
+
kind: graphql23.Kind.NAME,
|
|
74704
|
+
value: "__typename"
|
|
74705
|
+
}
|
|
74706
|
+
}
|
|
74707
|
+
]
|
|
74435
74708
|
}
|
|
74436
74709
|
};
|
|
74437
74710
|
}
|
|
74438
74711
|
}
|
|
74439
|
-
}
|
|
74440
|
-
Argument(node) {
|
|
74441
|
-
const value = node.value;
|
|
74442
|
-
if (value.kind !== "Variable") {
|
|
74443
|
-
return;
|
|
74444
|
-
}
|
|
74445
|
-
if (!scope) {
|
|
74446
|
-
throw new HoudiniError({
|
|
74447
|
-
filepath,
|
|
74448
|
-
message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
|
|
74449
|
-
});
|
|
74450
|
-
}
|
|
74451
|
-
const newValue = scope[value.name.value];
|
|
74452
|
-
if (newValue) {
|
|
74453
|
-
return {
|
|
74454
|
-
...node,
|
|
74455
|
-
value: newValue
|
|
74456
|
-
};
|
|
74457
|
-
}
|
|
74458
|
-
if (definitionArgs[value.name.value] && definitionArgs[value.name.value].required) {
|
|
74459
|
-
throw new HoudiniError({
|
|
74460
|
-
filepath,
|
|
74461
|
-
message: "Missing value for required arg: " + value.name.value
|
|
74462
|
-
});
|
|
74463
|
-
}
|
|
74464
|
-
return null;
|
|
74465
|
-
}
|
|
74466
|
-
});
|
|
74467
|
-
if (newName) {
|
|
74468
|
-
result.name = {
|
|
74469
|
-
kind: graphql24.Kind.NAME,
|
|
74470
|
-
value: newName
|
|
74471
|
-
};
|
|
74472
|
-
}
|
|
74473
|
-
return result;
|
|
74474
|
-
}
|
|
74475
|
-
function withArguments(config2, node) {
|
|
74476
|
-
const withDirectives = node.directives?.filter(
|
|
74477
|
-
(directive) => directive.name.value === config2.withDirective
|
|
74478
|
-
);
|
|
74479
|
-
if (!withDirectives || withDirectives.length === 0) {
|
|
74480
|
-
return [];
|
|
74712
|
+
});
|
|
74481
74713
|
}
|
|
74482
|
-
return withDirectives.flatMap((directive) => directive.arguments || []);
|
|
74483
74714
|
}
|
|
74484
|
-
|
|
74485
|
-
|
|
74486
|
-
|
|
74487
|
-
|
|
74488
|
-
|
|
74489
|
-
|
|
74490
|
-
|
|
74491
|
-
|
|
74492
|
-
|
|
74493
|
-
if (arg.value.kind !== "ObjectValue") {
|
|
74494
|
-
throw new HoudiniError({
|
|
74495
|
-
filepath,
|
|
74496
|
-
message: "values of @argument must be objects"
|
|
74497
|
-
});
|
|
74498
|
-
}
|
|
74499
|
-
const typeArg = arg.value.fields?.find((arg2) => arg2.name.value === "type")?.value;
|
|
74500
|
-
if (!typeArg || typeArg.kind !== "StringValue") {
|
|
74501
|
-
return [];
|
|
74502
|
-
}
|
|
74503
|
-
let type = typeArg.value;
|
|
74504
|
-
let name2 = arg.name.value;
|
|
74505
|
-
let required = false;
|
|
74506
|
-
let defaultValue = arg.value.fields?.find((arg2) => arg2.name.value === "default")?.value || null;
|
|
74507
|
-
if (type[type.length - 1] === "!") {
|
|
74508
|
-
type = type.slice(0, -1);
|
|
74509
|
-
required = true;
|
|
74510
|
-
defaultValue = null;
|
|
74511
|
-
}
|
|
74512
|
-
return [
|
|
74513
|
-
{
|
|
74514
|
-
name: name2,
|
|
74515
|
-
type,
|
|
74516
|
-
required,
|
|
74517
|
-
defaultValue
|
|
74715
|
+
|
|
74716
|
+
// src/codegen/transforms/addID.ts
|
|
74717
|
+
var graphql24 = __toESM(require_graphql2(), 1);
|
|
74718
|
+
async function addID(config2, documents) {
|
|
74719
|
+
for (const doc of documents) {
|
|
74720
|
+
doc.document = graphql24.visit(doc.document, {
|
|
74721
|
+
Field(node, key, parent, path2, ancestors) {
|
|
74722
|
+
if (!node.selectionSet) {
|
|
74723
|
+
return;
|
|
74518
74724
|
}
|
|
74519
|
-
|
|
74520
|
-
|
|
74521
|
-
|
|
74522
|
-
|
|
74523
|
-
|
|
74524
|
-
|
|
74525
|
-
|
|
74526
|
-
|
|
74527
|
-
|
|
74528
|
-
|
|
74529
|
-
|
|
74530
|
-
|
|
74531
|
-
|
|
74532
|
-
|
|
74533
|
-
|
|
74534
|
-
|
|
74535
|
-
|
|
74536
|
-
|
|
74537
|
-
|
|
74538
|
-
|
|
74539
|
-
|
|
74540
|
-
|
|
74541
|
-
|
|
74542
|
-
|
|
74543
|
-
|
|
74544
|
-
|
|
74545
|
-
|
|
74546
|
-
|
|
74547
|
-
|
|
74548
|
-
|
|
74549
|
-
|
|
74550
|
-
|
|
74551
|
-
|
|
74552
|
-
|
|
74553
|
-
|
|
74554
|
-
|
|
74555
|
-
|
|
74556
|
-
loc: void 0
|
|
74557
|
-
};
|
|
74558
|
-
}
|
|
74559
|
-
return {
|
|
74560
|
-
args,
|
|
74561
|
-
hash: "_" + murmurHash(JSON.stringify(args))
|
|
74562
|
-
};
|
|
74563
|
-
}
|
|
74564
|
-
function operationScope(operation) {
|
|
74565
|
-
return operation.variableDefinitions?.reduce(
|
|
74566
|
-
(scope, definition) => ({
|
|
74567
|
-
...scope,
|
|
74568
|
-
[definition.variable.name.value]: {
|
|
74569
|
-
kind: "Variable",
|
|
74570
|
-
name: {
|
|
74571
|
-
kind: "Name",
|
|
74572
|
-
value: definition.variable.name.value
|
|
74725
|
+
const type = parentTypeFromAncestors(
|
|
74726
|
+
config2.schema,
|
|
74727
|
+
doc.filename,
|
|
74728
|
+
ancestors.slice(0, -1)
|
|
74729
|
+
);
|
|
74730
|
+
const field = type.getFields()[node.name.value];
|
|
74731
|
+
const fieldType = unwrapType(config2, field.type).type;
|
|
74732
|
+
if (node.selectionSet?.selections.length > 0) {
|
|
74733
|
+
if (!graphql24.isObjectType(fieldType) && !graphql24.isInterfaceType(fieldType)) {
|
|
74734
|
+
return;
|
|
74735
|
+
}
|
|
74736
|
+
const keyFields = config2.keyFieldsForType(fieldType.name);
|
|
74737
|
+
if (keyFields.find((key2) => !fieldType.getFields()[key2])) {
|
|
74738
|
+
return;
|
|
74739
|
+
}
|
|
74740
|
+
const selections = [...node.selectionSet.selections];
|
|
74741
|
+
for (const keyField of keyFields) {
|
|
74742
|
+
if (node.selectionSet.selections.find(
|
|
74743
|
+
(selection2) => selection2.kind === "Field" && !selection2.alias && selection2.name.value === keyField
|
|
74744
|
+
)) {
|
|
74745
|
+
continue;
|
|
74746
|
+
}
|
|
74747
|
+
selections.push({
|
|
74748
|
+
kind: graphql24.Kind.FIELD,
|
|
74749
|
+
name: {
|
|
74750
|
+
kind: graphql24.Kind.NAME,
|
|
74751
|
+
value: keyField
|
|
74752
|
+
}
|
|
74753
|
+
});
|
|
74754
|
+
}
|
|
74755
|
+
return {
|
|
74756
|
+
...node,
|
|
74757
|
+
selectionSet: {
|
|
74758
|
+
...node.selectionSet,
|
|
74759
|
+
selections
|
|
74760
|
+
}
|
|
74761
|
+
};
|
|
74573
74762
|
}
|
|
74574
74763
|
}
|
|
74575
|
-
})
|
|
74576
|
-
|
|
74577
|
-
) || {};
|
|
74764
|
+
});
|
|
74765
|
+
}
|
|
74578
74766
|
}
|
|
74579
74767
|
|
|
74580
74768
|
// src/codegen/validators/typeCheck.ts
|
|
@@ -75927,7 +76115,9 @@ var writeConfigFile = async ({
|
|
|
75927
76115
|
}) => {
|
|
75928
76116
|
const config2 = {};
|
|
75929
76117
|
if (url !== null) {
|
|
75930
|
-
config2.
|
|
76118
|
+
config2.watchSchema = {
|
|
76119
|
+
url
|
|
76120
|
+
};
|
|
75931
76121
|
}
|
|
75932
76122
|
if (schemaPath !== "./schema.graphql") {
|
|
75933
76123
|
config2.schemaPath = schemaPath;
|
|
@@ -76093,8 +76283,8 @@ async function updatePackageJSON(targetPath) {
|
|
|
76093
76283
|
}
|
|
76094
76284
|
packageJSON.devDependencies = {
|
|
76095
76285
|
...packageJSON.devDependencies,
|
|
76096
|
-
houdini: "^1.0.0-next.
|
|
76097
|
-
"houdini-svelte": "^1.0.0-next.
|
|
76286
|
+
houdini: "^1.0.0-next.3",
|
|
76287
|
+
"houdini-svelte": "^1.0.0-next.3",
|
|
76098
76288
|
graphql: "^15.8.0"
|
|
76099
76289
|
};
|
|
76100
76290
|
await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
|