houdini 1.0.0-next.2 → 1.0.0-next.4
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 +1417 -1231
- package/build/cmd-esm/index.js +1417 -1231
- package/build/codegen/generators/artifacts/selection.d.ts +3 -3
- 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 +1262 -1078
- package/build/codegen-esm/index.js +1262 -1078
- 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/cache.d.ts +3 -3
- package/build/runtime/cache/lists.d.ts +1 -0
- package/build/runtime/client/documentStore.d.ts +1 -1
- package/build/runtime/client/plugins/fetchParams.d.ts +1 -1
- 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/lib/types.d.ts +2 -3
- 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/cache.d.ts +3 -3
- package/build/runtime-cjs/cache/cache.js +30 -15
- package/build/runtime-cjs/cache/lists.d.ts +1 -0
- package/build/runtime-cjs/cache/lists.js +6 -3
- package/build/runtime-cjs/client/documentStore.d.ts +1 -1
- package/build/runtime-cjs/client/plugins/fetchParams.d.ts +1 -1
- package/build/runtime-cjs/client/plugins/fetchParams.js +6 -1
- package/build/runtime-cjs/client/plugins/query.js +0 -1
- 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/lib/types.d.ts +2 -3
- 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/cache.d.ts +3 -3
- package/build/runtime-esm/cache/cache.js +30 -15
- package/build/runtime-esm/cache/lists.d.ts +1 -0
- package/build/runtime-esm/cache/lists.js +6 -3
- package/build/runtime-esm/client/documentStore.d.ts +1 -1
- package/build/runtime-esm/client/plugins/fetchParams.d.ts +1 -1
- package/build/runtime-esm/client/plugins/fetchParams.js +6 -1
- package/build/runtime-esm/client/plugins/query.js +0 -1
- 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/lib/types.d.ts +2 -3
- 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 +1270 -1087
- package/build/test-esm/index.js +1270 -1087
- package/build/vite-cjs/index.js +1271 -1087
- package/build/vite-esm/index.js +1271 -1087
- package/package.json +1 -1
package/build/test-esm/index.js
CHANGED
|
@@ -54344,8 +54344,7 @@ var Config = class {
|
|
|
54344
54344
|
types: types14 = {},
|
|
54345
54345
|
logLevel,
|
|
54346
54346
|
defaultFragmentMasking = "enable",
|
|
54347
|
-
|
|
54348
|
-
schemaPollHeaders = {},
|
|
54347
|
+
watchSchema,
|
|
54349
54348
|
projectDir
|
|
54350
54349
|
} = this.configFile;
|
|
54351
54350
|
if (typeof schema === "string") {
|
|
@@ -54378,8 +54377,8 @@ var Config = class {
|
|
|
54378
54377
|
this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
|
|
54379
54378
|
this.defaultFragmentMasking = defaultFragmentMasking;
|
|
54380
54379
|
this.routesDir = join(this.projectRoot, "src", "routes");
|
|
54381
|
-
this.schemaPollInterval =
|
|
54382
|
-
this.schemaPollHeaders =
|
|
54380
|
+
this.schemaPollInterval = watchSchema?.interval ?? 2e3;
|
|
54381
|
+
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
54383
54382
|
this.rootDir = join(this.projectRoot, "$houdini");
|
|
54384
54383
|
if (defaultKeys) {
|
|
54385
54384
|
this.defaultKeys = defaultKeys;
|
|
@@ -54392,11 +54391,12 @@ var Config = class {
|
|
|
54392
54391
|
}
|
|
54393
54392
|
}
|
|
54394
54393
|
async apiURL() {
|
|
54395
|
-
|
|
54394
|
+
const apiURL = this.configFile.watchSchema?.url;
|
|
54395
|
+
if (!apiURL) {
|
|
54396
54396
|
return "";
|
|
54397
54397
|
}
|
|
54398
54398
|
const env = await this.getEnv();
|
|
54399
|
-
return this.processEnvValues(env,
|
|
54399
|
+
return this.processEnvValues(env, apiURL);
|
|
54400
54400
|
}
|
|
54401
54401
|
get include() {
|
|
54402
54402
|
if (this.configFile.include) {
|
|
@@ -54600,8 +54600,8 @@ var Config = class {
|
|
|
54600
54600
|
pluginDirectory(name2) {
|
|
54601
54601
|
return join(this.pluginRootDirectory, name2);
|
|
54602
54602
|
}
|
|
54603
|
-
get
|
|
54604
|
-
return "
|
|
54603
|
+
get loadDirective() {
|
|
54604
|
+
return "load";
|
|
54605
54605
|
}
|
|
54606
54606
|
get maskEnableDirective() {
|
|
54607
54607
|
return "mask_enable";
|
|
@@ -54718,7 +54718,7 @@ var Config = class {
|
|
|
54718
54718
|
this.withDirective,
|
|
54719
54719
|
this.paginateDirective,
|
|
54720
54720
|
this.cacheDirective,
|
|
54721
|
-
this.
|
|
54721
|
+
this.loadDirective,
|
|
54722
54722
|
this.maskEnableDirective,
|
|
54723
54723
|
this.maskDisableDirective
|
|
54724
54724
|
].includes(name2.value) || this.isDeleteDirective(name2.value);
|
|
@@ -54989,7 +54989,7 @@ async function cleanupFiles(pathFolder, listOfObj) {
|
|
|
54989
54989
|
}
|
|
54990
54990
|
|
|
54991
54991
|
// src/codegen/generators/artifacts/index.ts
|
|
54992
|
-
var
|
|
54992
|
+
var graphql12 = __toESM(require_graphql2(), 1);
|
|
54993
54993
|
var recast5 = __toESM(require_main2(), 1);
|
|
54994
54994
|
|
|
54995
54995
|
// src/codegen/utils/commonjs.ts
|
|
@@ -55247,159 +55247,534 @@ function murmurHash(str) {
|
|
|
55247
55247
|
return s;
|
|
55248
55248
|
}
|
|
55249
55249
|
|
|
55250
|
-
// src/codegen/
|
|
55251
|
-
async function writeIndexFile(config2, docs) {
|
|
55252
|
-
const docsToGenerate = docs.filter((doc) => doc.generateArtifact).sort((a, b) => a.name.localeCompare(b.name));
|
|
55253
|
-
let body = config2.module === "esm" ? docsToGenerate.reduce(
|
|
55254
|
-
(content, doc) => content + `
|
|
55255
|
-
export { default as ${doc.name}} from './${doc.name}'`,
|
|
55256
|
-
""
|
|
55257
|
-
) : docsToGenerate.reduce(
|
|
55258
|
-
(content, doc) => content + `
|
|
55259
|
-
${exportDefaultFrom(`./${doc.name}`, doc.name)}`,
|
|
55260
|
-
cjsIndexFilePreamble
|
|
55261
|
-
);
|
|
55262
|
-
await fs_exports.writeFile(path_exports.join(config2.artifactDirectory, "index.js"), body);
|
|
55263
|
-
}
|
|
55264
|
-
|
|
55265
|
-
// src/codegen/generators/artifacts/inputs.ts
|
|
55250
|
+
// src/codegen/transforms/fragmentVariables.ts
|
|
55266
55251
|
var graphql3 = __toESM(require_graphql2(), 1);
|
|
55267
|
-
var recast3 = __toESM(require_main2(), 1);
|
|
55268
|
-
var AST3 = recast3.types.builders;
|
|
55269
|
-
function inputObject(config2, inputs) {
|
|
55270
|
-
const visitedTypes = /* @__PURE__ */ new Set();
|
|
55271
|
-
const inputObj = {
|
|
55272
|
-
fields: inputs.reduce((fields, input) => {
|
|
55273
|
-
const { type } = unwrapType(config2, input.type);
|
|
55274
|
-
return {
|
|
55275
|
-
...fields,
|
|
55276
|
-
[input.variable.name.value]: type.name
|
|
55277
|
-
};
|
|
55278
|
-
}, {}),
|
|
55279
|
-
types: {}
|
|
55280
|
-
};
|
|
55281
|
-
for (const input of inputs) {
|
|
55282
|
-
walkInputs(config2, visitedTypes, inputObj, input.type);
|
|
55283
|
-
}
|
|
55284
|
-
return inputObj;
|
|
55285
|
-
}
|
|
55286
|
-
function walkInputs(config2, visitedTypes, inputObj, rootType) {
|
|
55287
|
-
const { type } = unwrapType(config2, rootType);
|
|
55288
|
-
if (visitedTypes.has(type.name)) {
|
|
55289
|
-
return;
|
|
55290
|
-
}
|
|
55291
|
-
if (graphql3.isEnumType(type) || graphql3.isScalarType(type)) {
|
|
55292
|
-
return;
|
|
55293
|
-
}
|
|
55294
|
-
if (graphql3.isUnionType(type)) {
|
|
55295
|
-
return;
|
|
55296
|
-
}
|
|
55297
|
-
visitedTypes.add(type.name);
|
|
55298
|
-
inputObj.types[type.name] = Object.values(type.getFields()).reduce(
|
|
55299
|
-
(typeFields, field) => {
|
|
55300
|
-
const { type: fieldType } = unwrapType(config2, field.type);
|
|
55301
|
-
walkInputs(config2, visitedTypes, inputObj, fieldType);
|
|
55302
|
-
return {
|
|
55303
|
-
...typeFields,
|
|
55304
|
-
[field.name]: fieldType.toString()
|
|
55305
|
-
};
|
|
55306
|
-
},
|
|
55307
|
-
{}
|
|
55308
|
-
);
|
|
55309
|
-
}
|
|
55310
55252
|
|
|
55311
|
-
// src/codegen/
|
|
55312
|
-
var
|
|
55313
|
-
|
|
55314
|
-
|
|
55315
|
-
|
|
55316
|
-
|
|
55317
|
-
|
|
55318
|
-
|
|
55319
|
-
|
|
55320
|
-
|
|
55253
|
+
// src/codegen/transforms/composeQueries.ts
|
|
55254
|
+
var import_graphql = __toESM(require_graphql2(), 1);
|
|
55255
|
+
async function includeFragmentDefinitions(config2, documents) {
|
|
55256
|
+
const fragments = collectFragments(config2, documents);
|
|
55257
|
+
for (const [index, { name: name2, document, filename }] of documents.entries()) {
|
|
55258
|
+
const operation = document.definitions.find(
|
|
55259
|
+
({ kind }) => kind === import_graphql.Kind.OPERATION_DEFINITION
|
|
55260
|
+
);
|
|
55261
|
+
if (!operation) {
|
|
55262
|
+
continue;
|
|
55263
|
+
}
|
|
55264
|
+
const allFragments = flattenFragments(
|
|
55265
|
+
filename,
|
|
55266
|
+
{ requiredFragments: findRequiredFragments(operation.selectionSet) },
|
|
55267
|
+
fragments
|
|
55268
|
+
);
|
|
55269
|
+
documents[index].document = {
|
|
55270
|
+
...document,
|
|
55271
|
+
definitions: [
|
|
55272
|
+
operation,
|
|
55273
|
+
...allFragments.map((fragmentName) => fragments[fragmentName].definition)
|
|
55274
|
+
]
|
|
55275
|
+
};
|
|
55321
55276
|
}
|
|
55322
|
-
|
|
55323
|
-
|
|
55324
|
-
|
|
55325
|
-
|
|
55326
|
-
)
|
|
55277
|
+
}
|
|
55278
|
+
function collectFragments(config2, docs) {
|
|
55279
|
+
return docs.reduce((acc, doc) => {
|
|
55280
|
+
const definitions = doc.document.definitions.reduce(
|
|
55281
|
+
(prev, definition) => definition.kind !== "FragmentDefinition" ? prev : {
|
|
55282
|
+
...prev,
|
|
55283
|
+
[definition.name.value]: {
|
|
55284
|
+
definition,
|
|
55285
|
+
requiredFragments: findRequiredFragments(definition.selectionSet),
|
|
55286
|
+
document: doc
|
|
55287
|
+
}
|
|
55288
|
+
},
|
|
55289
|
+
{}
|
|
55327
55290
|
);
|
|
55291
|
+
return {
|
|
55292
|
+
...acc,
|
|
55293
|
+
...definitions
|
|
55294
|
+
};
|
|
55295
|
+
}, {});
|
|
55296
|
+
}
|
|
55297
|
+
function findRequiredFragments(selectionSet) {
|
|
55298
|
+
if (selectionSet.selections.length === 0) {
|
|
55299
|
+
return [];
|
|
55328
55300
|
}
|
|
55329
|
-
|
|
55330
|
-
|
|
55331
|
-
|
|
55332
|
-
|
|
55333
|
-
|
|
55334
|
-
);
|
|
55301
|
+
const referencedFragments = [];
|
|
55302
|
+
for (const selection2 of selectionSet.selections) {
|
|
55303
|
+
if (selection2.kind === import_graphql.Kind.FRAGMENT_SPREAD) {
|
|
55304
|
+
referencedFragments.push(selection2.name.value);
|
|
55305
|
+
} else if (selection2.selectionSet) {
|
|
55306
|
+
referencedFragments.push(...findRequiredFragments(selection2.selectionSet));
|
|
55335
55307
|
}
|
|
55336
|
-
return AST4.stringLiteral(value);
|
|
55337
55308
|
}
|
|
55338
|
-
return
|
|
55309
|
+
return referencedFragments;
|
|
55339
55310
|
}
|
|
55340
|
-
function
|
|
55341
|
-
|
|
55342
|
-
|
|
55343
|
-
|
|
55344
|
-
|
|
55311
|
+
function flattenFragments(filepath, operation, fragments) {
|
|
55312
|
+
const frags = /* @__PURE__ */ new Set();
|
|
55313
|
+
const remaining = [...operation.requiredFragments];
|
|
55314
|
+
while (remaining.length > 0) {
|
|
55315
|
+
const nextFragment = remaining.shift();
|
|
55316
|
+
if (!nextFragment) {
|
|
55317
|
+
continue;
|
|
55345
55318
|
}
|
|
55346
|
-
|
|
55347
|
-
|
|
55348
|
-
|
|
55349
|
-
|
|
55350
|
-
|
|
55351
|
-
|
|
55352
|
-
|
|
55353
|
-
|
|
55354
|
-
|
|
55355
|
-
|
|
55356
|
-
}
|
|
55357
|
-
fields[key].push(value);
|
|
55319
|
+
if (!frags.has(nextFragment)) {
|
|
55320
|
+
frags.add(nextFragment);
|
|
55321
|
+
} else {
|
|
55322
|
+
continue;
|
|
55323
|
+
}
|
|
55324
|
+
const targetFragment = fragments[nextFragment];
|
|
55325
|
+
if (!targetFragment) {
|
|
55326
|
+
throw new HoudiniError({
|
|
55327
|
+
filepath,
|
|
55328
|
+
message: "compose: could not find definition for fragment " + nextFragment
|
|
55329
|
+
});
|
|
55358
55330
|
}
|
|
55331
|
+
remaining.push(...targetFragment.requiredFragments);
|
|
55359
55332
|
}
|
|
55360
|
-
return
|
|
55361
|
-
Object.entries(fields).map(([key, value]) => [key, deepMerge(filepath, ...value)])
|
|
55362
|
-
);
|
|
55333
|
+
return [...frags];
|
|
55363
55334
|
}
|
|
55364
|
-
|
|
55365
|
-
|
|
55366
|
-
|
|
55367
|
-
|
|
55368
|
-
|
|
55369
|
-
|
|
55370
|
-
|
|
55371
|
-
|
|
55372
|
-
|
|
55373
|
-
|
|
55374
|
-
|
|
55375
|
-
|
|
55376
|
-
|
|
55377
|
-
|
|
55378
|
-
|
|
55379
|
-
|
|
55380
|
-
|
|
55381
|
-
|
|
55335
|
+
|
|
55336
|
+
// src/codegen/transforms/fragmentVariables.ts
|
|
55337
|
+
var GraphqlKinds2 = graphql3.Kind;
|
|
55338
|
+
async function fragmentVariables(config2, documents) {
|
|
55339
|
+
const fragments = collectFragments(config2, documents);
|
|
55340
|
+
const generatedFragments = {};
|
|
55341
|
+
const visitedFragments = /* @__PURE__ */ new Set();
|
|
55342
|
+
for (const doc2 of documents) {
|
|
55343
|
+
const operation = doc2.document.definitions.find(
|
|
55344
|
+
({ kind }) => kind === GraphqlKinds2.OPERATION_DEFINITION
|
|
55345
|
+
);
|
|
55346
|
+
if (!operation) {
|
|
55347
|
+
continue;
|
|
55348
|
+
}
|
|
55349
|
+
doc2.document = inlineFragmentArgs({
|
|
55350
|
+
config: config2,
|
|
55351
|
+
filepath: doc2.filename,
|
|
55352
|
+
fragmentDefinitions: fragments,
|
|
55353
|
+
document: doc2.document,
|
|
55354
|
+
generatedFragments,
|
|
55355
|
+
visitedFragments,
|
|
55356
|
+
scope: null
|
|
55357
|
+
});
|
|
55382
55358
|
}
|
|
55383
|
-
|
|
55359
|
+
const doc = {
|
|
55360
|
+
kind: graphql3.Kind.DOCUMENT,
|
|
55361
|
+
definitions: Object.values(generatedFragments)
|
|
55362
|
+
};
|
|
55363
|
+
documents.push({
|
|
55364
|
+
name: "generated::fragmentVariables",
|
|
55365
|
+
kind: "HoudiniFragment" /* Fragment */,
|
|
55366
|
+
document: doc,
|
|
55367
|
+
originalDocument: doc,
|
|
55368
|
+
generateStore: false,
|
|
55369
|
+
generateArtifact: false,
|
|
55370
|
+
filename: "generated::fragmentVariables",
|
|
55371
|
+
originalString: ""
|
|
55372
|
+
});
|
|
55384
55373
|
}
|
|
55385
|
-
|
|
55386
|
-
|
|
55387
|
-
|
|
55388
|
-
|
|
55389
|
-
|
|
55374
|
+
function inlineFragmentArgs({
|
|
55375
|
+
config: config2,
|
|
55376
|
+
filepath,
|
|
55377
|
+
fragmentDefinitions,
|
|
55378
|
+
document,
|
|
55379
|
+
generatedFragments,
|
|
55380
|
+
visitedFragments,
|
|
55381
|
+
scope,
|
|
55382
|
+
newName
|
|
55383
|
+
}) {
|
|
55384
|
+
if (!scope) {
|
|
55385
|
+
scope = operationScope(
|
|
55386
|
+
document.definitions.find(
|
|
55387
|
+
({ kind }) => kind === GraphqlKinds2.OPERATION_DEFINITION
|
|
55388
|
+
)
|
|
55389
|
+
);
|
|
55390
55390
|
}
|
|
55391
|
-
const
|
|
55392
|
-
|
|
55393
|
-
|
|
55394
|
-
|
|
55395
|
-
|
|
55396
|
-
|
|
55397
|
-
|
|
55398
|
-
|
|
55399
|
-
|
|
55400
|
-
}
|
|
55401
|
-
|
|
55402
|
-
|
|
55391
|
+
const definitionArgs = fragmentArguments(
|
|
55392
|
+
config2,
|
|
55393
|
+
filepath,
|
|
55394
|
+
document
|
|
55395
|
+
).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
|
|
55396
|
+
const result = graphql3.visit(document, {
|
|
55397
|
+
FragmentSpread(node) {
|
|
55398
|
+
const { definition } = fragmentDefinitions[node.name.value];
|
|
55399
|
+
let { args, hash } = collectWithArguments(config2, filepath, node, scope);
|
|
55400
|
+
const newFragmentName = `${node.name.value}${hash}`;
|
|
55401
|
+
if (!visitedFragments.has(newFragmentName)) {
|
|
55402
|
+
visitedFragments.add(newFragmentName);
|
|
55403
|
+
const defaultArguments = collectDefaultArgumentValues(config2, filepath, definition);
|
|
55404
|
+
if (args) {
|
|
55405
|
+
for (const [field, value] of Object.entries(defaultArguments || {})) {
|
|
55406
|
+
if (!args[field]) {
|
|
55407
|
+
args[field] = value;
|
|
55408
|
+
}
|
|
55409
|
+
}
|
|
55410
|
+
generatedFragments[newFragmentName] = inlineFragmentArgs({
|
|
55411
|
+
config: config2,
|
|
55412
|
+
filepath,
|
|
55413
|
+
fragmentDefinitions,
|
|
55414
|
+
document: fragmentDefinitions[node.name.value].definition,
|
|
55415
|
+
generatedFragments,
|
|
55416
|
+
visitedFragments,
|
|
55417
|
+
scope: args,
|
|
55418
|
+
newName: newFragmentName
|
|
55419
|
+
});
|
|
55420
|
+
} else {
|
|
55421
|
+
const doc = fragmentDefinitions[node.name.value].document;
|
|
55422
|
+
const definitionIndex = doc.document.definitions.findIndex(
|
|
55423
|
+
(definition2) => definition2.kind === "FragmentDefinition" && definition2.name.value === node.name.value
|
|
55424
|
+
);
|
|
55425
|
+
const localDefinitions = [...doc.document.definitions];
|
|
55426
|
+
localDefinitions.splice(definitionIndex, 1);
|
|
55427
|
+
localDefinitions.push(
|
|
55428
|
+
inlineFragmentArgs({
|
|
55429
|
+
config: config2,
|
|
55430
|
+
filepath,
|
|
55431
|
+
fragmentDefinitions,
|
|
55432
|
+
document: fragmentDefinitions[node.name.value].definition,
|
|
55433
|
+
generatedFragments,
|
|
55434
|
+
visitedFragments,
|
|
55435
|
+
scope: defaultArguments,
|
|
55436
|
+
newName: ""
|
|
55437
|
+
})
|
|
55438
|
+
);
|
|
55439
|
+
doc.document = {
|
|
55440
|
+
...doc.document,
|
|
55441
|
+
definitions: localDefinitions
|
|
55442
|
+
};
|
|
55443
|
+
}
|
|
55444
|
+
if (node.name.value !== newFragmentName) {
|
|
55445
|
+
return {
|
|
55446
|
+
...node,
|
|
55447
|
+
name: {
|
|
55448
|
+
kind: "Name",
|
|
55449
|
+
value: newFragmentName
|
|
55450
|
+
}
|
|
55451
|
+
};
|
|
55452
|
+
}
|
|
55453
|
+
}
|
|
55454
|
+
},
|
|
55455
|
+
Argument(node) {
|
|
55456
|
+
const value = node.value;
|
|
55457
|
+
if (value.kind !== "Variable") {
|
|
55458
|
+
return;
|
|
55459
|
+
}
|
|
55460
|
+
if (!scope) {
|
|
55461
|
+
throw new HoudiniError({
|
|
55462
|
+
filepath,
|
|
55463
|
+
message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
|
|
55464
|
+
});
|
|
55465
|
+
}
|
|
55466
|
+
const newValue = scope[value.name.value];
|
|
55467
|
+
if (newValue) {
|
|
55468
|
+
return {
|
|
55469
|
+
...node,
|
|
55470
|
+
value: newValue
|
|
55471
|
+
};
|
|
55472
|
+
}
|
|
55473
|
+
if (definitionArgs[value.name.value] && definitionArgs[value.name.value].required) {
|
|
55474
|
+
throw new HoudiniError({
|
|
55475
|
+
filepath,
|
|
55476
|
+
message: "Missing value for required arg: " + value.name.value
|
|
55477
|
+
});
|
|
55478
|
+
}
|
|
55479
|
+
return null;
|
|
55480
|
+
}
|
|
55481
|
+
});
|
|
55482
|
+
if (newName) {
|
|
55483
|
+
result.name = {
|
|
55484
|
+
kind: graphql3.Kind.NAME,
|
|
55485
|
+
value: newName
|
|
55486
|
+
};
|
|
55487
|
+
}
|
|
55488
|
+
return result;
|
|
55489
|
+
}
|
|
55490
|
+
function withArguments(config2, node) {
|
|
55491
|
+
const withDirectives = node.directives?.filter(
|
|
55492
|
+
(directive) => directive.name.value === config2.withDirective
|
|
55493
|
+
);
|
|
55494
|
+
if (!withDirectives || withDirectives.length === 0) {
|
|
55495
|
+
return [];
|
|
55496
|
+
}
|
|
55497
|
+
return withDirectives.flatMap((directive) => directive.arguments || []);
|
|
55498
|
+
}
|
|
55499
|
+
function fragmentArguments(config2, filepath, definition) {
|
|
55500
|
+
const directives = definition.directives?.filter(
|
|
55501
|
+
(directive) => directive.name.value === config2.argumentsDirective
|
|
55502
|
+
);
|
|
55503
|
+
if (!directives || directives.length === 0) {
|
|
55504
|
+
return [];
|
|
55505
|
+
}
|
|
55506
|
+
return directives.flatMap(
|
|
55507
|
+
(directive) => directive.arguments?.flatMap((arg) => {
|
|
55508
|
+
if (arg.value.kind !== "ObjectValue") {
|
|
55509
|
+
throw new HoudiniError({
|
|
55510
|
+
filepath,
|
|
55511
|
+
message: "values of @argument must be objects"
|
|
55512
|
+
});
|
|
55513
|
+
}
|
|
55514
|
+
const typeArg = arg.value.fields?.find((arg2) => arg2.name.value === "type")?.value;
|
|
55515
|
+
if (!typeArg || typeArg.kind !== "StringValue") {
|
|
55516
|
+
return [];
|
|
55517
|
+
}
|
|
55518
|
+
let type = typeArg.value;
|
|
55519
|
+
let name2 = arg.name.value;
|
|
55520
|
+
let required = false;
|
|
55521
|
+
let defaultValue = arg.value.fields?.find((arg2) => arg2.name.value === "default")?.value || null;
|
|
55522
|
+
if (type[type.length - 1] === "!") {
|
|
55523
|
+
type = type.slice(0, -1);
|
|
55524
|
+
required = true;
|
|
55525
|
+
defaultValue = null;
|
|
55526
|
+
}
|
|
55527
|
+
return [
|
|
55528
|
+
{
|
|
55529
|
+
name: name2,
|
|
55530
|
+
type,
|
|
55531
|
+
required,
|
|
55532
|
+
defaultValue
|
|
55533
|
+
}
|
|
55534
|
+
];
|
|
55535
|
+
}) || []
|
|
55536
|
+
);
|
|
55537
|
+
}
|
|
55538
|
+
function collectDefaultArgumentValues(config2, filepath, definition) {
|
|
55539
|
+
let result = {};
|
|
55540
|
+
for (const { name: name2, required, defaultValue } of fragmentArguments(
|
|
55541
|
+
config2,
|
|
55542
|
+
filepath,
|
|
55543
|
+
definition
|
|
55544
|
+
)) {
|
|
55545
|
+
if (required || !defaultValue) {
|
|
55546
|
+
continue;
|
|
55547
|
+
}
|
|
55548
|
+
result[name2] = defaultValue;
|
|
55549
|
+
}
|
|
55550
|
+
return result;
|
|
55551
|
+
}
|
|
55552
|
+
function collectWithArguments(config2, filepath, node, scope = {}) {
|
|
55553
|
+
const withArgs = withArguments(config2, node);
|
|
55554
|
+
if (withArgs.length === 0) {
|
|
55555
|
+
return { args: null, hash: "" };
|
|
55556
|
+
}
|
|
55557
|
+
let args = {};
|
|
55558
|
+
for (const arg of withArgs) {
|
|
55559
|
+
let value = arg.value;
|
|
55560
|
+
if (value.kind === GraphqlKinds2.VARIABLE) {
|
|
55561
|
+
if (!scope || !scope[value.name.value]) {
|
|
55562
|
+
throw new HoudiniError({
|
|
55563
|
+
filepath,
|
|
55564
|
+
message: "Encountered undefined variable: " + value.name.value
|
|
55565
|
+
});
|
|
55566
|
+
}
|
|
55567
|
+
value = scope[value.name.value];
|
|
55568
|
+
}
|
|
55569
|
+
args[arg.name.value] = {
|
|
55570
|
+
...value,
|
|
55571
|
+
loc: void 0
|
|
55572
|
+
};
|
|
55573
|
+
}
|
|
55574
|
+
return {
|
|
55575
|
+
args,
|
|
55576
|
+
hash: "_" + murmurHash(JSON.stringify(args))
|
|
55577
|
+
};
|
|
55578
|
+
}
|
|
55579
|
+
function operationScope(operation) {
|
|
55580
|
+
return operation.variableDefinitions?.reduce(
|
|
55581
|
+
(scope, definition) => ({
|
|
55582
|
+
...scope,
|
|
55583
|
+
[definition.variable.name.value]: {
|
|
55584
|
+
kind: "Variable",
|
|
55585
|
+
name: {
|
|
55586
|
+
kind: "Name",
|
|
55587
|
+
value: definition.variable.name.value
|
|
55588
|
+
}
|
|
55589
|
+
}
|
|
55590
|
+
}),
|
|
55591
|
+
{}
|
|
55592
|
+
) || {};
|
|
55593
|
+
}
|
|
55594
|
+
function fragmentArgumentsDefinitions(config2, filepath, definition) {
|
|
55595
|
+
const args = fragmentArguments(config2, filepath, definition);
|
|
55596
|
+
if (args.length === 0) {
|
|
55597
|
+
return [];
|
|
55598
|
+
}
|
|
55599
|
+
return args.map((arg) => {
|
|
55600
|
+
const innerType = {
|
|
55601
|
+
kind: "NamedType",
|
|
55602
|
+
name: {
|
|
55603
|
+
kind: "Name",
|
|
55604
|
+
value: arg.type
|
|
55605
|
+
}
|
|
55606
|
+
};
|
|
55607
|
+
return {
|
|
55608
|
+
kind: "VariableDefinition",
|
|
55609
|
+
type: arg.required ? innerType : {
|
|
55610
|
+
kind: "NonNullType",
|
|
55611
|
+
type: innerType
|
|
55612
|
+
},
|
|
55613
|
+
variable: {
|
|
55614
|
+
kind: "Variable",
|
|
55615
|
+
name: {
|
|
55616
|
+
kind: "Name",
|
|
55617
|
+
value: arg.name
|
|
55618
|
+
}
|
|
55619
|
+
},
|
|
55620
|
+
defaultValue: arg.defaultValue ?? void 0
|
|
55621
|
+
};
|
|
55622
|
+
});
|
|
55623
|
+
}
|
|
55624
|
+
|
|
55625
|
+
// src/codegen/generators/artifacts/indexFile.ts
|
|
55626
|
+
async function writeIndexFile(config2, docs) {
|
|
55627
|
+
const docsToGenerate = docs.filter((doc) => doc.generateArtifact).sort((a, b) => a.name.localeCompare(b.name));
|
|
55628
|
+
let body = config2.module === "esm" ? docsToGenerate.reduce(
|
|
55629
|
+
(content, doc) => content + `
|
|
55630
|
+
export { default as ${doc.name}} from './${doc.name}'`,
|
|
55631
|
+
""
|
|
55632
|
+
) : docsToGenerate.reduce(
|
|
55633
|
+
(content, doc) => content + `
|
|
55634
|
+
${exportDefaultFrom(`./${doc.name}`, doc.name)}`,
|
|
55635
|
+
cjsIndexFilePreamble
|
|
55636
|
+
);
|
|
55637
|
+
await fs_exports.writeFile(path_exports.join(config2.artifactDirectory, "index.js"), body);
|
|
55638
|
+
}
|
|
55639
|
+
|
|
55640
|
+
// src/codegen/generators/artifacts/inputs.ts
|
|
55641
|
+
var graphql4 = __toESM(require_graphql2(), 1);
|
|
55642
|
+
var recast3 = __toESM(require_main2(), 1);
|
|
55643
|
+
var AST3 = recast3.types.builders;
|
|
55644
|
+
function inputObject(config2, inputs) {
|
|
55645
|
+
const visitedTypes = /* @__PURE__ */ new Set();
|
|
55646
|
+
const inputObj = {
|
|
55647
|
+
fields: inputs.reduce((fields, input) => {
|
|
55648
|
+
const { type } = unwrapType(config2, input.type);
|
|
55649
|
+
return {
|
|
55650
|
+
...fields,
|
|
55651
|
+
[input.variable.name.value]: type.name
|
|
55652
|
+
};
|
|
55653
|
+
}, {}),
|
|
55654
|
+
types: {}
|
|
55655
|
+
};
|
|
55656
|
+
for (const input of inputs) {
|
|
55657
|
+
walkInputs(config2, visitedTypes, inputObj, input.type);
|
|
55658
|
+
}
|
|
55659
|
+
return inputObj;
|
|
55660
|
+
}
|
|
55661
|
+
function walkInputs(config2, visitedTypes, inputObj, rootType) {
|
|
55662
|
+
const { type } = unwrapType(config2, rootType);
|
|
55663
|
+
if (visitedTypes.has(type.name)) {
|
|
55664
|
+
return;
|
|
55665
|
+
}
|
|
55666
|
+
if (graphql4.isEnumType(type) || graphql4.isScalarType(type)) {
|
|
55667
|
+
return;
|
|
55668
|
+
}
|
|
55669
|
+
if (graphql4.isUnionType(type)) {
|
|
55670
|
+
return;
|
|
55671
|
+
}
|
|
55672
|
+
visitedTypes.add(type.name);
|
|
55673
|
+
inputObj.types[type.name] = Object.values(type.getFields()).reduce(
|
|
55674
|
+
(typeFields, field) => {
|
|
55675
|
+
const { type: fieldType } = unwrapType(config2, field.type);
|
|
55676
|
+
walkInputs(config2, visitedTypes, inputObj, fieldType);
|
|
55677
|
+
return {
|
|
55678
|
+
...typeFields,
|
|
55679
|
+
[field.name]: fieldType.toString()
|
|
55680
|
+
};
|
|
55681
|
+
},
|
|
55682
|
+
{}
|
|
55683
|
+
);
|
|
55684
|
+
}
|
|
55685
|
+
|
|
55686
|
+
// src/codegen/generators/artifacts/operations.ts
|
|
55687
|
+
var graphql6 = __toESM(require_graphql2(), 1);
|
|
55688
|
+
|
|
55689
|
+
// src/codegen/generators/artifacts/utils.ts
|
|
55690
|
+
var graphql5 = __toESM(require_graphql2(), 1);
|
|
55691
|
+
var recast4 = __toESM(require_main2(), 1);
|
|
55692
|
+
var AST4 = recast4.types.builders;
|
|
55693
|
+
function serializeValue(value) {
|
|
55694
|
+
if (Array.isArray(value)) {
|
|
55695
|
+
return AST4.arrayExpression(value.map(serializeValue));
|
|
55696
|
+
}
|
|
55697
|
+
if (typeof value === "object" && value !== null) {
|
|
55698
|
+
return AST4.objectExpression(
|
|
55699
|
+
Object.entries(value).filter(([, value2]) => typeof value2 !== "undefined").map(
|
|
55700
|
+
([key, value2]) => AST4.objectProperty(AST4.stringLiteral(key), serializeValue(value2))
|
|
55701
|
+
)
|
|
55702
|
+
);
|
|
55703
|
+
}
|
|
55704
|
+
if (typeof value === "string") {
|
|
55705
|
+
if (value.indexOf("\n") !== -1) {
|
|
55706
|
+
return AST4.templateLiteral(
|
|
55707
|
+
[AST4.templateElement({ raw: value, cooked: value }, true)],
|
|
55708
|
+
[]
|
|
55709
|
+
);
|
|
55710
|
+
}
|
|
55711
|
+
return AST4.stringLiteral(value);
|
|
55712
|
+
}
|
|
55713
|
+
return AST4.literal(value);
|
|
55714
|
+
}
|
|
55715
|
+
function deepMerge(filepath, ...targets) {
|
|
55716
|
+
if (typeof targets[0] !== "object") {
|
|
55717
|
+
const matches = targets.filter((val) => val !== targets[0]).length === 0;
|
|
55718
|
+
if (!matches) {
|
|
55719
|
+
throw new HoudiniError({ filepath, message: "could not merge: " + targets });
|
|
55720
|
+
}
|
|
55721
|
+
return targets[0];
|
|
55722
|
+
}
|
|
55723
|
+
if (Array.isArray(targets[0])) {
|
|
55724
|
+
return targets[0].concat(...targets.slice(1));
|
|
55725
|
+
}
|
|
55726
|
+
const fields = {};
|
|
55727
|
+
for (const target of targets) {
|
|
55728
|
+
for (const [key, value] of Object.entries(target)) {
|
|
55729
|
+
if (!fields[key]) {
|
|
55730
|
+
fields[key] = [];
|
|
55731
|
+
}
|
|
55732
|
+
fields[key].push(value);
|
|
55733
|
+
}
|
|
55734
|
+
}
|
|
55735
|
+
return Object.fromEntries(
|
|
55736
|
+
Object.entries(fields).map(([key, value]) => [key, deepMerge(filepath, ...value)])
|
|
55737
|
+
);
|
|
55738
|
+
}
|
|
55739
|
+
function convertValue(config2, val) {
|
|
55740
|
+
let value;
|
|
55741
|
+
let kind;
|
|
55742
|
+
if (val.kind === graphql5.Kind.INT) {
|
|
55743
|
+
value = parseInt(val.value, 10);
|
|
55744
|
+
kind = "Int";
|
|
55745
|
+
} else if (val.kind === graphql5.Kind.FLOAT) {
|
|
55746
|
+
value = parseFloat(val.value);
|
|
55747
|
+
kind = "Float";
|
|
55748
|
+
} else if (val.kind === graphql5.Kind.BOOLEAN) {
|
|
55749
|
+
value = val.value;
|
|
55750
|
+
kind = "Boolean";
|
|
55751
|
+
} else if (val.kind === graphql5.Kind.VARIABLE) {
|
|
55752
|
+
value = val.name.value;
|
|
55753
|
+
kind = "Variable";
|
|
55754
|
+
} else if (val.kind === graphql5.Kind.STRING) {
|
|
55755
|
+
value = val.value;
|
|
55756
|
+
kind = "String";
|
|
55757
|
+
}
|
|
55758
|
+
return { kind, value };
|
|
55759
|
+
}
|
|
55760
|
+
|
|
55761
|
+
// src/codegen/generators/artifacts/operations.ts
|
|
55762
|
+
function operationsByPath(config2, filepath, definition, filterTypes) {
|
|
55763
|
+
if (!definition) {
|
|
55764
|
+
return {};
|
|
55765
|
+
}
|
|
55766
|
+
const pathOperations = {};
|
|
55767
|
+
graphql6.visit(definition, {
|
|
55768
|
+
FragmentSpread(node, _, __, ___, ancestors) {
|
|
55769
|
+
if (!config2.isListFragment(node.name.value)) {
|
|
55770
|
+
return;
|
|
55771
|
+
}
|
|
55772
|
+
const path2 = ancestorKey(ancestors);
|
|
55773
|
+
if (!pathOperations[path2]) {
|
|
55774
|
+
pathOperations[path2] = [];
|
|
55775
|
+
}
|
|
55776
|
+
pathOperations[path2].push(
|
|
55777
|
+
operationObject({
|
|
55403
55778
|
config: config2,
|
|
55404
55779
|
filepath,
|
|
55405
55780
|
listName: config2.listNameFromFragment(node.name.value),
|
|
@@ -55548,7 +55923,7 @@ function ancestorKey(ancestors) {
|
|
|
55548
55923
|
}
|
|
55549
55924
|
|
|
55550
55925
|
// src/codegen/generators/artifacts/selection.ts
|
|
55551
|
-
var
|
|
55926
|
+
var graphql11 = __toESM(require_graphql2(), 1);
|
|
55552
55927
|
|
|
55553
55928
|
// ../../node_modules/.pnpm/@kitql+helper@0.5.0/node_modules/@kitql/helper/index.mjs
|
|
55554
55929
|
var config = {
|
|
@@ -55588,16 +55963,16 @@ function logYellow(str) {
|
|
|
55588
55963
|
}
|
|
55589
55964
|
|
|
55590
55965
|
// src/codegen/transforms/list.ts
|
|
55591
|
-
var
|
|
55966
|
+
var graphql9 = __toESM(require_graphql2(), 1);
|
|
55592
55967
|
|
|
55593
55968
|
// src/codegen/utils/objectIdentificationSelection.ts
|
|
55594
|
-
var
|
|
55969
|
+
var graphql7 = __toESM(require_graphql2(), 1);
|
|
55595
55970
|
var objectIdentificationSelection = (config2, type) => {
|
|
55596
55971
|
return config2.keyFieldsForType(type.name).map((key) => {
|
|
55597
55972
|
return {
|
|
55598
|
-
kind:
|
|
55973
|
+
kind: graphql7.Kind.FIELD,
|
|
55599
55974
|
name: {
|
|
55600
|
-
kind:
|
|
55975
|
+
kind: graphql7.Kind.NAME,
|
|
55601
55976
|
value: key
|
|
55602
55977
|
}
|
|
55603
55978
|
};
|
|
@@ -55605,7 +55980,7 @@ var objectIdentificationSelection = (config2, type) => {
|
|
|
55605
55980
|
};
|
|
55606
55981
|
|
|
55607
55982
|
// src/codegen/transforms/paginate.ts
|
|
55608
|
-
var
|
|
55983
|
+
var graphql8 = __toESM(require_graphql2(), 1);
|
|
55609
55984
|
async function paginate(config2, documents) {
|
|
55610
55985
|
const newDocs = [];
|
|
55611
55986
|
for (const doc of documents) {
|
|
@@ -55638,7 +56013,7 @@ async function paginate(config2, documents) {
|
|
|
55638
56013
|
};
|
|
55639
56014
|
let cursorType = "String";
|
|
55640
56015
|
let paginationPath = [];
|
|
55641
|
-
doc.document =
|
|
56016
|
+
doc.document = graphql8.visit(doc.document, {
|
|
55642
56017
|
Field(node, _, __, ___, ancestors) {
|
|
55643
56018
|
const paginateDirective = node.directives?.find(
|
|
55644
56019
|
(directive) => directive.name.value === config2.paginateDirective
|
|
@@ -55649,23 +56024,22 @@ async function paginate(config2, documents) {
|
|
|
55649
56024
|
paginated = true;
|
|
55650
56025
|
const fieldTypeFields = parentTypeFromAncestors(config2.schema, doc.filename, ancestors).getFields()[node.name.value];
|
|
55651
56026
|
const args = new Set(fieldTypeFields.args.map((arg) => arg.name));
|
|
55652
|
-
const passedArgs = new Set(node.arguments?.map((arg) => arg.name.value));
|
|
55653
|
-
const specifiedForwards = passedArgs.has("first");
|
|
55654
|
-
const specifiedBackwards = passedArgs.has("last");
|
|
55655
56027
|
cursorType = fieldTypeFields.args?.find((arg) => ["before", "after"].includes(arg.name))?.type?.name || "String";
|
|
55656
56028
|
flags.after.type = cursorType;
|
|
55657
56029
|
flags.before.type = cursorType;
|
|
55658
|
-
const
|
|
55659
|
-
const
|
|
55660
|
-
const
|
|
55661
|
-
|
|
55662
|
-
|
|
55663
|
-
flags.
|
|
55664
|
-
flags.
|
|
56030
|
+
const passedArgs = new Set(node.arguments?.map((arg) => arg.name.value));
|
|
56031
|
+
const forwards = args.has("first") && args.has("after");
|
|
56032
|
+
const backwards = args.has("last") && args.has("after");
|
|
56033
|
+
const cursorPagination = passedArgs.has("last") || passedArgs.has("first");
|
|
56034
|
+
const offsetPagination = !cursorPagination && args.has("offset") && args.has("limit");
|
|
56035
|
+
flags.first.enabled = forwards;
|
|
56036
|
+
flags.after.enabled = forwards;
|
|
56037
|
+
flags.last.enabled = backwards;
|
|
56038
|
+
flags.before.enabled = backwards;
|
|
55665
56039
|
flags.offset.enabled = offsetPagination;
|
|
55666
56040
|
flags.limit.enabled = offsetPagination;
|
|
55667
56041
|
paginationPath = ancestors.filter(
|
|
55668
|
-
(ancestor) => !Array.isArray(ancestor) && ancestor.kind ===
|
|
56042
|
+
(ancestor) => !Array.isArray(ancestor) && ancestor.kind === graphql8.Kind.FIELD
|
|
55669
56043
|
).concat(node).map((field) => field.alias?.value || field.name.value);
|
|
55670
56044
|
return {
|
|
55671
56045
|
...node,
|
|
@@ -55681,12 +56055,8 @@ async function paginate(config2, documents) {
|
|
|
55681
56055
|
let fragmentName = "";
|
|
55682
56056
|
let refetchQueryName = "";
|
|
55683
56057
|
let nodeQuery = false;
|
|
55684
|
-
let refetchUpdate = "append" /* append */;
|
|
55685
|
-
if (flags.last.enabled) {
|
|
55686
|
-
refetchUpdate = "prepend" /* prepend */;
|
|
55687
|
-
}
|
|
55688
56058
|
let fragment = "";
|
|
55689
|
-
doc.document =
|
|
56059
|
+
doc.document = graphql8.visit(doc.document, {
|
|
55690
56060
|
OperationDefinition(node) {
|
|
55691
56061
|
if (node.operation !== "query") {
|
|
55692
56062
|
throw new HoudiniError({
|
|
@@ -55740,9 +56110,9 @@ async function paginate(config2, documents) {
|
|
|
55740
56110
|
directives: [
|
|
55741
56111
|
...node.directives || [],
|
|
55742
56112
|
{
|
|
55743
|
-
kind:
|
|
56113
|
+
kind: graphql8.Kind.DIRECTIVE,
|
|
55744
56114
|
name: {
|
|
55745
|
-
kind:
|
|
56115
|
+
kind: graphql8.Kind.NAME,
|
|
55746
56116
|
value: config2.argumentsDirective
|
|
55747
56117
|
}
|
|
55748
56118
|
}
|
|
@@ -55779,42 +56149,40 @@ async function paginate(config2, documents) {
|
|
|
55779
56149
|
targetType = fragment;
|
|
55780
56150
|
}
|
|
55781
56151
|
}
|
|
56152
|
+
const pageSize = flags.first.defaultValue ?? flags.last.defaultValue ?? flags.limit.defaultValue;
|
|
56153
|
+
const start = flags.after.defaultValue ?? flags.before.defaultValue ?? flags.offset.defaultValue;
|
|
56154
|
+
let direction = "forward";
|
|
56155
|
+
if (flags.before.enabled && flags.after.enabled) {
|
|
56156
|
+
direction = "both";
|
|
56157
|
+
} else if (flags.before.enabled) {
|
|
56158
|
+
direction = "backward";
|
|
56159
|
+
}
|
|
55782
56160
|
doc.refetch = {
|
|
55783
|
-
update: refetchUpdate,
|
|
55784
56161
|
path: paginationPath,
|
|
55785
56162
|
method: flags.first.enabled || flags.last.enabled ? "cursor" : "offset",
|
|
55786
|
-
pageSize
|
|
56163
|
+
pageSize,
|
|
55787
56164
|
embedded: nodeQuery,
|
|
55788
56165
|
targetType,
|
|
55789
56166
|
paginated: true,
|
|
55790
|
-
direction
|
|
55791
|
-
|
|
55792
|
-
|
|
55793
|
-
doc.refetch.pageSize = flags.first.defaultValue;
|
|
55794
|
-
doc.refetch.start = flags.after.defaultValue;
|
|
55795
|
-
} else if (flags.last.enabled) {
|
|
55796
|
-
doc.refetch.pageSize = flags.last.defaultValue;
|
|
55797
|
-
doc.refetch.start = flags.before.defaultValue;
|
|
55798
|
-
} else if (flags.limit.enabled) {
|
|
55799
|
-
doc.refetch.pageSize = flags.limit.defaultValue;
|
|
55800
|
-
doc.refetch.start = flags.offset.defaultValue;
|
|
55801
|
-
}
|
|
56167
|
+
direction,
|
|
56168
|
+
start
|
|
56169
|
+
};
|
|
55802
56170
|
if (!fragment) {
|
|
55803
56171
|
continue;
|
|
55804
56172
|
}
|
|
55805
56173
|
const paginationArgs = Object.entries(flags).filter(([_, { enabled }]) => enabled).map(([key, value]) => ({ name: key, ...value }));
|
|
55806
56174
|
const fragmentSpreadSelection = [
|
|
55807
56175
|
{
|
|
55808
|
-
kind:
|
|
56176
|
+
kind: graphql8.Kind.FRAGMENT_SPREAD,
|
|
55809
56177
|
name: {
|
|
55810
|
-
kind:
|
|
56178
|
+
kind: graphql8.Kind.NAME,
|
|
55811
56179
|
value: fragmentName
|
|
55812
56180
|
},
|
|
55813
56181
|
directives: [
|
|
55814
56182
|
{
|
|
55815
|
-
kind:
|
|
56183
|
+
kind: graphql8.Kind.DIRECTIVE,
|
|
55816
56184
|
name: {
|
|
55817
|
-
kind:
|
|
56185
|
+
kind: graphql8.Kind.NAME,
|
|
55818
56186
|
value: config2.withDirective
|
|
55819
56187
|
},
|
|
55820
56188
|
["arguments"]: paginationArgs.map(
|
|
@@ -55842,29 +56210,29 @@ async function paginate(config2, documents) {
|
|
|
55842
56210
|
});
|
|
55843
56211
|
const typeConfig = config2.typeConfig?.[fragment];
|
|
55844
56212
|
const queryDoc = {
|
|
55845
|
-
kind:
|
|
56213
|
+
kind: graphql8.Kind.DOCUMENT,
|
|
55846
56214
|
definitions: [
|
|
55847
56215
|
{
|
|
55848
|
-
kind:
|
|
56216
|
+
kind: graphql8.Kind.OPERATION_DEFINITION,
|
|
55849
56217
|
name: {
|
|
55850
|
-
kind:
|
|
56218
|
+
kind: graphql8.Kind.NAME,
|
|
55851
56219
|
value: refetchQueryName
|
|
55852
56220
|
},
|
|
55853
56221
|
operation: "query",
|
|
55854
56222
|
variableDefinitions: paginationArgs.map(
|
|
55855
56223
|
(arg) => ({
|
|
55856
|
-
kind:
|
|
56224
|
+
kind: graphql8.Kind.VARIABLE_DEFINITION,
|
|
55857
56225
|
type: {
|
|
55858
|
-
kind:
|
|
56226
|
+
kind: graphql8.Kind.NAMED_TYPE,
|
|
55859
56227
|
name: {
|
|
55860
|
-
kind:
|
|
56228
|
+
kind: graphql8.Kind.NAME,
|
|
55861
56229
|
value: arg.type
|
|
55862
56230
|
}
|
|
55863
56231
|
},
|
|
55864
56232
|
variable: {
|
|
55865
|
-
kind:
|
|
56233
|
+
kind: graphql8.Kind.VARIABLE,
|
|
55866
56234
|
name: {
|
|
55867
|
-
kind:
|
|
56235
|
+
kind: graphql8.Kind.NAME,
|
|
55868
56236
|
value: arg.name
|
|
55869
56237
|
}
|
|
55870
56238
|
},
|
|
@@ -55876,12 +56244,12 @@ async function paginate(config2, documents) {
|
|
|
55876
56244
|
).concat(
|
|
55877
56245
|
!nodeQuery ? [] : keys.map(
|
|
55878
56246
|
(key) => ({
|
|
55879
|
-
kind:
|
|
56247
|
+
kind: graphql8.Kind.VARIABLE_DEFINITION,
|
|
55880
56248
|
type: key.type,
|
|
55881
56249
|
variable: {
|
|
55882
|
-
kind:
|
|
56250
|
+
kind: graphql8.Kind.VARIABLE,
|
|
55883
56251
|
name: {
|
|
55884
|
-
kind:
|
|
56252
|
+
kind: graphql8.Kind.NAME,
|
|
55885
56253
|
value: key.name
|
|
55886
56254
|
}
|
|
55887
56255
|
}
|
|
@@ -55889,42 +56257,42 @@ async function paginate(config2, documents) {
|
|
|
55889
56257
|
)
|
|
55890
56258
|
),
|
|
55891
56259
|
selectionSet: {
|
|
55892
|
-
kind:
|
|
56260
|
+
kind: graphql8.Kind.SELECTION_SET,
|
|
55893
56261
|
selections: !nodeQuery ? fragmentSpreadSelection : [
|
|
55894
56262
|
{
|
|
55895
|
-
kind:
|
|
56263
|
+
kind: graphql8.Kind.FIELD,
|
|
55896
56264
|
name: {
|
|
55897
|
-
kind:
|
|
56265
|
+
kind: graphql8.Kind.NAME,
|
|
55898
56266
|
value: typeConfig?.resolve?.queryField || "node"
|
|
55899
56267
|
},
|
|
55900
56268
|
["arguments"]: keys.map((key) => ({
|
|
55901
|
-
kind:
|
|
56269
|
+
kind: graphql8.Kind.ARGUMENT,
|
|
55902
56270
|
name: {
|
|
55903
|
-
kind:
|
|
56271
|
+
kind: graphql8.Kind.NAME,
|
|
55904
56272
|
value: key.name
|
|
55905
56273
|
},
|
|
55906
56274
|
value: {
|
|
55907
|
-
kind:
|
|
56275
|
+
kind: graphql8.Kind.VARIABLE,
|
|
55908
56276
|
name: {
|
|
55909
|
-
kind:
|
|
56277
|
+
kind: graphql8.Kind.NAME,
|
|
55910
56278
|
value: key.name
|
|
55911
56279
|
}
|
|
55912
56280
|
}
|
|
55913
56281
|
})),
|
|
55914
56282
|
selectionSet: {
|
|
55915
|
-
kind:
|
|
56283
|
+
kind: graphql8.Kind.SELECTION_SET,
|
|
55916
56284
|
selections: [
|
|
55917
56285
|
{
|
|
55918
|
-
kind:
|
|
56286
|
+
kind: graphql8.Kind.FIELD,
|
|
55919
56287
|
name: {
|
|
55920
|
-
kind:
|
|
56288
|
+
kind: graphql8.Kind.NAME,
|
|
55921
56289
|
value: "__typename"
|
|
55922
56290
|
}
|
|
55923
56291
|
},
|
|
55924
56292
|
...(typeConfig?.keys || ["id"]).map((key) => ({
|
|
55925
|
-
kind:
|
|
56293
|
+
kind: graphql8.Kind.FIELD,
|
|
55926
56294
|
name: {
|
|
55927
|
-
kind:
|
|
56295
|
+
kind: graphql8.Kind.NAME,
|
|
55928
56296
|
value: key
|
|
55929
56297
|
}
|
|
55930
56298
|
})),
|
|
@@ -55974,27 +56342,21 @@ function replaceArgumentsWithVariables(args, flags) {
|
|
|
55974
56342
|
if (flags[name2].defaultValue || !spec.enabled || seenArgs[name2]) {
|
|
55975
56343
|
continue;
|
|
55976
56344
|
}
|
|
55977
|
-
if (["first", "after"].includes(name2) && flags["before"].enabled) {
|
|
55978
|
-
continue;
|
|
55979
|
-
}
|
|
55980
|
-
if (["last", "before"].includes(name2) && flags["first"].enabled) {
|
|
55981
|
-
continue;
|
|
55982
|
-
}
|
|
55983
56345
|
newArgs.push(variableAsArgument(name2));
|
|
55984
56346
|
}
|
|
55985
56347
|
return newArgs;
|
|
55986
56348
|
}
|
|
55987
56349
|
function variableAsArgument(name2, variable) {
|
|
55988
56350
|
return {
|
|
55989
|
-
kind:
|
|
56351
|
+
kind: graphql8.Kind.ARGUMENT,
|
|
55990
56352
|
name: {
|
|
55991
|
-
kind:
|
|
56353
|
+
kind: graphql8.Kind.NAME,
|
|
55992
56354
|
value: name2
|
|
55993
56355
|
},
|
|
55994
56356
|
value: {
|
|
55995
|
-
kind:
|
|
56357
|
+
kind: graphql8.Kind.VARIABLE,
|
|
55996
56358
|
name: {
|
|
55997
|
-
kind:
|
|
56359
|
+
kind: graphql8.Kind.NAME,
|
|
55998
56360
|
value: variable ?? name2
|
|
55999
56361
|
}
|
|
56000
56362
|
}
|
|
@@ -56002,18 +56364,18 @@ function variableAsArgument(name2, variable) {
|
|
|
56002
56364
|
}
|
|
56003
56365
|
function staticVariableDefinition(name2, type, defaultValue, variableName) {
|
|
56004
56366
|
return {
|
|
56005
|
-
kind:
|
|
56367
|
+
kind: graphql8.Kind.VARIABLE_DEFINITION,
|
|
56006
56368
|
type: {
|
|
56007
|
-
kind:
|
|
56369
|
+
kind: graphql8.Kind.NAMED_TYPE,
|
|
56008
56370
|
name: {
|
|
56009
|
-
kind:
|
|
56371
|
+
kind: graphql8.Kind.NAME,
|
|
56010
56372
|
value: type
|
|
56011
56373
|
}
|
|
56012
56374
|
},
|
|
56013
56375
|
variable: {
|
|
56014
|
-
kind:
|
|
56376
|
+
kind: graphql8.Kind.VARIABLE,
|
|
56015
56377
|
name: {
|
|
56016
|
-
kind:
|
|
56378
|
+
kind: graphql8.Kind.NAME,
|
|
56017
56379
|
value: variableName ?? name2
|
|
56018
56380
|
}
|
|
56019
56381
|
},
|
|
@@ -56025,9 +56387,9 @@ function staticVariableDefinition(name2, type, defaultValue, variableName) {
|
|
|
56025
56387
|
}
|
|
56026
56388
|
function argumentNode(name2, value) {
|
|
56027
56389
|
return {
|
|
56028
|
-
kind:
|
|
56390
|
+
kind: graphql8.Kind.ARGUMENT,
|
|
56029
56391
|
name: {
|
|
56030
|
-
kind:
|
|
56392
|
+
kind: graphql8.Kind.NAME,
|
|
56031
56393
|
value: name2
|
|
56032
56394
|
},
|
|
56033
56395
|
value: objectNode(value)
|
|
@@ -56035,16 +56397,16 @@ function argumentNode(name2, value) {
|
|
|
56035
56397
|
}
|
|
56036
56398
|
function objectNode([type, defaultValue]) {
|
|
56037
56399
|
const node = {
|
|
56038
|
-
kind:
|
|
56400
|
+
kind: graphql8.Kind.OBJECT,
|
|
56039
56401
|
fields: [
|
|
56040
56402
|
{
|
|
56041
|
-
kind:
|
|
56403
|
+
kind: graphql8.Kind.OBJECT_FIELD,
|
|
56042
56404
|
name: {
|
|
56043
|
-
kind:
|
|
56405
|
+
kind: graphql8.Kind.NAME,
|
|
56044
56406
|
value: "type"
|
|
56045
56407
|
},
|
|
56046
56408
|
value: {
|
|
56047
|
-
kind:
|
|
56409
|
+
kind: graphql8.Kind.STRING,
|
|
56048
56410
|
value: type
|
|
56049
56411
|
}
|
|
56050
56412
|
}
|
|
@@ -56052,8 +56414,8 @@ function objectNode([type, defaultValue]) {
|
|
|
56052
56414
|
};
|
|
56053
56415
|
if (defaultValue) {
|
|
56054
56416
|
node.fields.push({
|
|
56055
|
-
kind:
|
|
56056
|
-
name: { kind:
|
|
56417
|
+
kind: graphql8.Kind.OBJECT_FIELD,
|
|
56418
|
+
name: { kind: graphql8.Kind.NAME, value: "default" },
|
|
56057
56419
|
value: {
|
|
56058
56420
|
kind: typeof defaultValue === "number" ? "IntValue" : "StringValue",
|
|
56059
56421
|
value: defaultValue.toString()
|
|
@@ -56064,34 +56426,34 @@ function objectNode([type, defaultValue]) {
|
|
|
56064
56426
|
}
|
|
56065
56427
|
var pageInfoSelection = [
|
|
56066
56428
|
{
|
|
56067
|
-
kind:
|
|
56429
|
+
kind: graphql8.Kind.FIELD,
|
|
56068
56430
|
name: {
|
|
56069
|
-
kind:
|
|
56431
|
+
kind: graphql8.Kind.NAME,
|
|
56070
56432
|
value: "edges"
|
|
56071
56433
|
},
|
|
56072
56434
|
selectionSet: {
|
|
56073
|
-
kind:
|
|
56435
|
+
kind: graphql8.Kind.SELECTION_SET,
|
|
56074
56436
|
selections: [
|
|
56075
56437
|
{
|
|
56076
|
-
kind:
|
|
56438
|
+
kind: graphql8.Kind.FIELD,
|
|
56077
56439
|
name: {
|
|
56078
|
-
kind:
|
|
56440
|
+
kind: graphql8.Kind.NAME,
|
|
56079
56441
|
value: "cursor"
|
|
56080
56442
|
}
|
|
56081
56443
|
},
|
|
56082
56444
|
{
|
|
56083
|
-
kind:
|
|
56445
|
+
kind: graphql8.Kind.FIELD,
|
|
56084
56446
|
name: {
|
|
56085
|
-
kind:
|
|
56447
|
+
kind: graphql8.Kind.NAME,
|
|
56086
56448
|
value: "node"
|
|
56087
56449
|
},
|
|
56088
56450
|
selectionSet: {
|
|
56089
|
-
kind:
|
|
56451
|
+
kind: graphql8.Kind.SELECTION_SET,
|
|
56090
56452
|
selections: [
|
|
56091
56453
|
{
|
|
56092
|
-
kind:
|
|
56454
|
+
kind: graphql8.Kind.FIELD,
|
|
56093
56455
|
name: {
|
|
56094
|
-
kind:
|
|
56456
|
+
kind: graphql8.Kind.NAME,
|
|
56095
56457
|
value: "__typename"
|
|
56096
56458
|
}
|
|
56097
56459
|
}
|
|
@@ -56102,39 +56464,39 @@ var pageInfoSelection = [
|
|
|
56102
56464
|
}
|
|
56103
56465
|
},
|
|
56104
56466
|
{
|
|
56105
|
-
kind:
|
|
56467
|
+
kind: graphql8.Kind.FIELD,
|
|
56106
56468
|
name: {
|
|
56107
|
-
kind:
|
|
56469
|
+
kind: graphql8.Kind.NAME,
|
|
56108
56470
|
value: "pageInfo"
|
|
56109
56471
|
},
|
|
56110
56472
|
selectionSet: {
|
|
56111
|
-
kind:
|
|
56473
|
+
kind: graphql8.Kind.SELECTION_SET,
|
|
56112
56474
|
selections: [
|
|
56113
56475
|
{
|
|
56114
|
-
kind:
|
|
56476
|
+
kind: graphql8.Kind.FIELD,
|
|
56115
56477
|
name: {
|
|
56116
|
-
kind:
|
|
56478
|
+
kind: graphql8.Kind.NAME,
|
|
56117
56479
|
value: "hasPreviousPage"
|
|
56118
56480
|
}
|
|
56119
56481
|
},
|
|
56120
56482
|
{
|
|
56121
|
-
kind:
|
|
56483
|
+
kind: graphql8.Kind.FIELD,
|
|
56122
56484
|
name: {
|
|
56123
|
-
kind:
|
|
56485
|
+
kind: graphql8.Kind.NAME,
|
|
56124
56486
|
value: "hasNextPage"
|
|
56125
56487
|
}
|
|
56126
56488
|
},
|
|
56127
56489
|
{
|
|
56128
|
-
kind:
|
|
56490
|
+
kind: graphql8.Kind.FIELD,
|
|
56129
56491
|
name: {
|
|
56130
|
-
kind:
|
|
56492
|
+
kind: graphql8.Kind.NAME,
|
|
56131
56493
|
value: "startCursor"
|
|
56132
56494
|
}
|
|
56133
56495
|
},
|
|
56134
56496
|
{
|
|
56135
|
-
kind:
|
|
56497
|
+
kind: graphql8.Kind.FIELD,
|
|
56136
56498
|
name: {
|
|
56137
|
-
kind:
|
|
56499
|
+
kind: graphql8.Kind.NAME,
|
|
56138
56500
|
value: "endCursor"
|
|
56139
56501
|
}
|
|
56140
56502
|
}
|
|
@@ -56148,15 +56510,15 @@ async function addListFragments(config2, documents) {
|
|
|
56148
56510
|
const lists = {};
|
|
56149
56511
|
const errors = [];
|
|
56150
56512
|
for (const doc of documents) {
|
|
56151
|
-
doc.document =
|
|
56513
|
+
doc.document = graphql9.visit(doc.document, {
|
|
56152
56514
|
Directive(node, key, parent, path2, ancestors) {
|
|
56153
56515
|
if ([config2.listDirective, config2.paginateDirective].includes(node.name.value)) {
|
|
56154
56516
|
const nameArg = node.arguments?.find((arg) => arg.name.value === "name");
|
|
56155
56517
|
let error = {
|
|
56156
|
-
...new
|
|
56518
|
+
...new graphql9.GraphQLError(
|
|
56157
56519
|
"",
|
|
56158
56520
|
node,
|
|
56159
|
-
new
|
|
56521
|
+
new graphql9.Source(""),
|
|
56160
56522
|
node.loc ? [node.loc.start, node.loc.end] : null,
|
|
56161
56523
|
path2
|
|
56162
56524
|
),
|
|
@@ -56208,7 +56570,7 @@ async function addListFragments(config2, documents) {
|
|
|
56208
56570
|
{
|
|
56209
56571
|
kind: "Argument",
|
|
56210
56572
|
name: {
|
|
56211
|
-
kind:
|
|
56573
|
+
kind: graphql9.Kind.NAME,
|
|
56212
56574
|
value: "connection"
|
|
56213
56575
|
},
|
|
56214
56576
|
value: {
|
|
@@ -56258,7 +56620,7 @@ async function addListFragments(config2, documents) {
|
|
|
56258
56620
|
const validDeletes = [
|
|
56259
56621
|
...new Set(
|
|
56260
56622
|
Object.values(lists).map(({ type }) => {
|
|
56261
|
-
if (!(type instanceof
|
|
56623
|
+
if (!(type instanceof graphql9.GraphQLObjectType)) {
|
|
56262
56624
|
return "";
|
|
56263
56625
|
}
|
|
56264
56626
|
if (config2.keyFieldsForType(type.name).length !== 1) {
|
|
@@ -56272,7 +56634,7 @@ async function addListFragments(config2, documents) {
|
|
|
56272
56634
|
return;
|
|
56273
56635
|
}
|
|
56274
56636
|
const generatedDoc = {
|
|
56275
|
-
kind:
|
|
56637
|
+
kind: graphql9.Kind.DOCUMENT,
|
|
56276
56638
|
definitions: Object.entries(lists).flatMap(
|
|
56277
56639
|
([name2, { selection: selection2, type }]) => {
|
|
56278
56640
|
const schemaType = config2.schema.getType(type.name);
|
|
@@ -56280,7 +56642,7 @@ async function addListFragments(config2, documents) {
|
|
|
56280
56642
|
throw new HoudiniError({ message: "Lists must have a selection" });
|
|
56281
56643
|
}
|
|
56282
56644
|
const fragmentSelection = {
|
|
56283
|
-
kind:
|
|
56645
|
+
kind: graphql9.Kind.SELECTION_SET,
|
|
56284
56646
|
selections: [...selection2.selections]
|
|
56285
56647
|
};
|
|
56286
56648
|
if (schemaType && fragmentSelection && !fragmentSelection?.selections.find(
|
|
@@ -56295,14 +56657,14 @@ async function addListFragments(config2, documents) {
|
|
|
56295
56657
|
{
|
|
56296
56658
|
name: {
|
|
56297
56659
|
value: config2.listInsertFragment(name2),
|
|
56298
|
-
kind:
|
|
56660
|
+
kind: graphql9.Kind.NAME
|
|
56299
56661
|
},
|
|
56300
|
-
kind:
|
|
56662
|
+
kind: graphql9.Kind.FRAGMENT_DEFINITION,
|
|
56301
56663
|
selectionSet: fragmentSelection,
|
|
56302
56664
|
typeCondition: {
|
|
56303
|
-
kind:
|
|
56665
|
+
kind: graphql9.Kind.NAMED_TYPE,
|
|
56304
56666
|
name: {
|
|
56305
|
-
kind:
|
|
56667
|
+
kind: graphql9.Kind.NAME,
|
|
56306
56668
|
value: type.name
|
|
56307
56669
|
}
|
|
56308
56670
|
}
|
|
@@ -56310,32 +56672,32 @@ async function addListFragments(config2, documents) {
|
|
|
56310
56672
|
{
|
|
56311
56673
|
name: {
|
|
56312
56674
|
value: config2.listToggleFragment(name2),
|
|
56313
|
-
kind:
|
|
56675
|
+
kind: graphql9.Kind.NAME
|
|
56314
56676
|
},
|
|
56315
|
-
kind:
|
|
56677
|
+
kind: graphql9.Kind.FRAGMENT_DEFINITION,
|
|
56316
56678
|
selectionSet: fragmentSelection,
|
|
56317
56679
|
typeCondition: {
|
|
56318
|
-
kind:
|
|
56680
|
+
kind: graphql9.Kind.NAMED_TYPE,
|
|
56319
56681
|
name: {
|
|
56320
|
-
kind:
|
|
56682
|
+
kind: graphql9.Kind.NAME,
|
|
56321
56683
|
value: type.name
|
|
56322
56684
|
}
|
|
56323
56685
|
}
|
|
56324
56686
|
},
|
|
56325
56687
|
{
|
|
56326
|
-
kind:
|
|
56688
|
+
kind: graphql9.Kind.FRAGMENT_DEFINITION,
|
|
56327
56689
|
name: {
|
|
56328
56690
|
value: config2.listRemoveFragment(name2),
|
|
56329
|
-
kind:
|
|
56691
|
+
kind: graphql9.Kind.NAME
|
|
56330
56692
|
},
|
|
56331
56693
|
selectionSet: {
|
|
56332
|
-
kind:
|
|
56694
|
+
kind: graphql9.Kind.SELECTION_SET,
|
|
56333
56695
|
selections: [...objectIdentificationSelection(config2, type)]
|
|
56334
56696
|
},
|
|
56335
56697
|
typeCondition: {
|
|
56336
|
-
kind:
|
|
56698
|
+
kind: graphql9.Kind.NAMED_TYPE,
|
|
56337
56699
|
name: {
|
|
56338
|
-
kind:
|
|
56700
|
+
kind: graphql9.Kind.NAME,
|
|
56339
56701
|
value: type.name
|
|
56340
56702
|
}
|
|
56341
56703
|
}
|
|
@@ -56344,14 +56706,14 @@ async function addListFragments(config2, documents) {
|
|
|
56344
56706
|
}
|
|
56345
56707
|
).concat(
|
|
56346
56708
|
...validDeletes.map((typeName) => ({
|
|
56347
|
-
kind:
|
|
56709
|
+
kind: graphql9.Kind.DIRECTIVE_DEFINITION,
|
|
56348
56710
|
name: {
|
|
56349
|
-
kind:
|
|
56711
|
+
kind: graphql9.Kind.NAME,
|
|
56350
56712
|
value: config2.listDeleteDirective(typeName)
|
|
56351
56713
|
},
|
|
56352
56714
|
locations: [
|
|
56353
56715
|
{
|
|
56354
|
-
kind:
|
|
56716
|
+
kind: graphql9.Kind.NAME,
|
|
56355
56717
|
value: "FIELD"
|
|
56356
56718
|
}
|
|
56357
56719
|
],
|
|
@@ -56359,8 +56721,8 @@ async function addListFragments(config2, documents) {
|
|
|
56359
56721
|
}))
|
|
56360
56722
|
)
|
|
56361
56723
|
};
|
|
56362
|
-
config2.newSchema += "\n" + generatedDoc.definitions.filter((c) => c.kind !== "FragmentDefinition").map(
|
|
56363
|
-
config2.newDocuments += "\n" + generatedDoc.definitions.filter((c) => c.kind === "FragmentDefinition").map(
|
|
56724
|
+
config2.newSchema += "\n" + generatedDoc.definitions.filter((c) => c.kind !== "FragmentDefinition").map(graphql9.print).join("\n\n");
|
|
56725
|
+
config2.newDocuments += "\n" + generatedDoc.definitions.filter((c) => c.kind === "FragmentDefinition").map(graphql9.print).join("\n\n");
|
|
56364
56726
|
documents.push({
|
|
56365
56727
|
name: "generated::lists",
|
|
56366
56728
|
kind: "HoudiniFragment" /* Fragment */,
|
|
@@ -56445,11 +56807,11 @@ var nodeNotDefinedMessage = (config2) => `Looks like you are trying to use the $
|
|
|
56445
56807
|
For more information, visit this link: ${siteURL}/guides/pagination`;
|
|
56446
56808
|
|
|
56447
56809
|
// src/codegen/generators/artifacts/fieldKey.ts
|
|
56448
|
-
var
|
|
56810
|
+
var graphql10 = __toESM(require_graphql2(), 1);
|
|
56449
56811
|
function fieldKey(config2, field) {
|
|
56450
56812
|
const attributeName = field.alias?.value || field.name.value;
|
|
56451
|
-
const printed =
|
|
56452
|
-
const secondParse =
|
|
56813
|
+
const printed = graphql10.print(field);
|
|
56814
|
+
const secondParse = graphql10.parse(`{${printed}}`).definitions[0].selectionSet.selections[0];
|
|
56453
56815
|
const paginated = !!field.directives?.find(
|
|
56454
56816
|
(directive) => directive.name.value === config2.paginateDirective
|
|
56455
56817
|
);
|
|
@@ -56487,7 +56849,7 @@ function selection({
|
|
|
56487
56849
|
path: path2 = [],
|
|
56488
56850
|
includeFragments,
|
|
56489
56851
|
document,
|
|
56490
|
-
|
|
56852
|
+
inConnection
|
|
56491
56853
|
}) {
|
|
56492
56854
|
let object = {};
|
|
56493
56855
|
const typeMap = {};
|
|
@@ -56544,8 +56906,8 @@ function selection({
|
|
|
56544
56906
|
const typeConditionName = field.typeCondition.name.value;
|
|
56545
56907
|
const typeCondition = config2.schema.getType(typeConditionName);
|
|
56546
56908
|
const possibleTypes = [];
|
|
56547
|
-
if (!
|
|
56548
|
-
} else if (
|
|
56909
|
+
if (!graphql11.isAbstractType(typeCondition)) {
|
|
56910
|
+
} else if (graphql11.isAbstractType(parentType)) {
|
|
56549
56911
|
const possibleParentTypes = config2.schema.getPossibleTypes(parentType).map((type) => type.name);
|
|
56550
56912
|
for (const possible of config2.schema.getPossibleTypes(typeCondition)) {
|
|
56551
56913
|
if (possibleParentTypes.includes(possible.name)) {
|
|
@@ -56593,7 +56955,7 @@ function selection({
|
|
|
56593
56955
|
} else {
|
|
56594
56956
|
let typeRef = type.getFields()[field.name.value].type;
|
|
56595
56957
|
fieldType = getRootType(typeRef);
|
|
56596
|
-
nullable = !
|
|
56958
|
+
nullable = !graphql11.isNonNullType(typeRef);
|
|
56597
56959
|
}
|
|
56598
56960
|
const typeName = fieldType.toString();
|
|
56599
56961
|
const pathSoFar = path2.concat(attributeName);
|
|
@@ -56629,14 +56991,23 @@ function selection({
|
|
|
56629
56991
|
(directive) => directive.name.value === config2.paginateDirective
|
|
56630
56992
|
);
|
|
56631
56993
|
if (paginated && document.refetch && document.refetch.method === "offset") {
|
|
56632
|
-
fieldObj.
|
|
56994
|
+
fieldObj.updates = ["append" /* append */];
|
|
56633
56995
|
}
|
|
56634
|
-
|
|
56635
|
-
|
|
56636
|
-
|
|
56996
|
+
let continueConnection = inConnection;
|
|
56997
|
+
if ([
|
|
56998
|
+
"edges",
|
|
56999
|
+
"endCursor",
|
|
57000
|
+
"startCursor",
|
|
57001
|
+
"hasNextPage",
|
|
57002
|
+
"hasPreviousPage"
|
|
57003
|
+
].includes(attributeName) && inConnection && document.refetch) {
|
|
57004
|
+
fieldObj.updates = ["append" /* append */, "prepend" /* prepend */];
|
|
57005
|
+
}
|
|
57006
|
+
if (attributeName === "node" && inConnection) {
|
|
57007
|
+
continueConnection = false;
|
|
56637
57008
|
}
|
|
56638
57009
|
if (field.selectionSet) {
|
|
56639
|
-
const
|
|
57010
|
+
const connectionState = paginated && document.refetch?.method === "cursor" || continueConnection;
|
|
56640
57011
|
fieldObj.selection = selection({
|
|
56641
57012
|
config: config2,
|
|
56642
57013
|
filepath,
|
|
@@ -56646,7 +57017,7 @@ function selection({
|
|
|
56646
57017
|
path: pathSoFar,
|
|
56647
57018
|
includeFragments,
|
|
56648
57019
|
document,
|
|
56649
|
-
|
|
57020
|
+
inConnection: connectionState
|
|
56650
57021
|
});
|
|
56651
57022
|
}
|
|
56652
57023
|
if (field.arguments?.length && fieldObj.list) {
|
|
@@ -56658,7 +57029,7 @@ function selection({
|
|
|
56658
57029
|
{}
|
|
56659
57030
|
);
|
|
56660
57031
|
}
|
|
56661
|
-
if (
|
|
57032
|
+
if (graphql11.isInterfaceType(fieldType) || graphql11.isUnionType(fieldType)) {
|
|
56662
57033
|
fieldObj.abstract = true;
|
|
56663
57034
|
}
|
|
56664
57035
|
object.fields = {
|
|
@@ -56715,7 +57086,7 @@ function artifactGenerator(stats) {
|
|
|
56715
57086
|
return async function(config2, docs) {
|
|
56716
57087
|
const filterTypes = {};
|
|
56717
57088
|
for (const doc of docs) {
|
|
56718
|
-
|
|
57089
|
+
graphql12.visit(doc.document, {
|
|
56719
57090
|
Directive(node, _, __, ___, ancestors) {
|
|
56720
57091
|
if (node.name.value !== config2.listDirective) {
|
|
56721
57092
|
return;
|
|
@@ -56774,7 +57145,7 @@ function artifactGenerator(stats) {
|
|
|
56774
57145
|
return;
|
|
56775
57146
|
}
|
|
56776
57147
|
const usedVariableNames = /* @__PURE__ */ new Set();
|
|
56777
|
-
let documentWithoutInternalDirectives =
|
|
57148
|
+
let documentWithoutInternalDirectives = graphql12.visit(document, {
|
|
56778
57149
|
Directive(node) {
|
|
56779
57150
|
if (config2.isInternalDirective(node)) {
|
|
56780
57151
|
return null;
|
|
@@ -56787,7 +57158,7 @@ function artifactGenerator(stats) {
|
|
|
56787
57158
|
}
|
|
56788
57159
|
}
|
|
56789
57160
|
});
|
|
56790
|
-
let documentWithoutExtraVariables =
|
|
57161
|
+
let documentWithoutExtraVariables = graphql12.visit(
|
|
56791
57162
|
documentWithoutInternalDirectives,
|
|
56792
57163
|
{
|
|
56793
57164
|
VariableDefinition(variableDefinitionNode) {
|
|
@@ -56798,13 +57169,13 @@ function artifactGenerator(stats) {
|
|
|
56798
57169
|
}
|
|
56799
57170
|
}
|
|
56800
57171
|
);
|
|
56801
|
-
let rawString =
|
|
57172
|
+
let rawString = graphql12.print(documentWithoutExtraVariables);
|
|
56802
57173
|
let docKind = doc.kind;
|
|
56803
57174
|
const operations = document.definitions.filter(
|
|
56804
|
-
({ kind }) => kind ===
|
|
57175
|
+
({ kind }) => kind === graphql12.Kind.OPERATION_DEFINITION
|
|
56805
57176
|
);
|
|
56806
57177
|
const fragments = document.definitions.filter(
|
|
56807
|
-
({ kind }) => kind ===
|
|
57178
|
+
({ kind }) => kind === graphql12.Kind.FRAGMENT_DEFINITION
|
|
56808
57179
|
);
|
|
56809
57180
|
let rootType = "";
|
|
56810
57181
|
let selectionSet;
|
|
@@ -56837,7 +57208,13 @@ function artifactGenerator(stats) {
|
|
|
56837
57208
|
rootType = matchingFragment.typeCondition.name.value;
|
|
56838
57209
|
selectionSet = matchingFragment.selectionSet;
|
|
56839
57210
|
}
|
|
56840
|
-
|
|
57211
|
+
let inputs = operations[0]?.variableDefinitions;
|
|
57212
|
+
let directive = fragments[0]?.directives?.find(
|
|
57213
|
+
(directive2) => directive2.name.value === config2.argumentsDirective
|
|
57214
|
+
);
|
|
57215
|
+
if (docKind === "HoudiniFragment" /* Fragment */ && directive) {
|
|
57216
|
+
inputs = fragmentArgumentsDefinitions(config2, doc.filename, fragments[0]);
|
|
57217
|
+
}
|
|
56841
57218
|
const mergedSelection = flattenSelections({
|
|
56842
57219
|
config: config2,
|
|
56843
57220
|
filepath: doc.filename,
|
|
@@ -56898,7 +57275,7 @@ function artifactGenerator(stats) {
|
|
|
56898
57275
|
}
|
|
56899
57276
|
if (docKind === "HoudiniQuery") {
|
|
56900
57277
|
const cacheDirective = operations[0].directives?.find(
|
|
56901
|
-
(
|
|
57278
|
+
(directive2) => directive2.name.value === config2.cacheDirective
|
|
56902
57279
|
);
|
|
56903
57280
|
if (cacheDirective) {
|
|
56904
57281
|
const args = cacheDirective.arguments?.reduce(
|
|
@@ -57114,19 +57491,19 @@ async function generatePluginRuntime(config2, plugin) {
|
|
|
57114
57491
|
);
|
|
57115
57492
|
}
|
|
57116
57493
|
|
|
57117
|
-
// src/codegen/generators/typescript/
|
|
57118
|
-
var
|
|
57494
|
+
// src/codegen/generators/typescript/documentTypes.ts
|
|
57495
|
+
var recast11 = __toESM(require_main2(), 1);
|
|
57119
57496
|
|
|
57120
57497
|
// src/codegen/generators/typescript/addReferencedInputTypes.ts
|
|
57121
|
-
var
|
|
57498
|
+
var graphql15 = __toESM(require_graphql2(), 1);
|
|
57122
57499
|
var recast9 = __toESM(require_main2(), 1);
|
|
57123
57500
|
|
|
57124
57501
|
// src/codegen/generators/typescript/typeReference.ts
|
|
57125
|
-
var
|
|
57502
|
+
var graphql14 = __toESM(require_graphql2(), 1);
|
|
57126
57503
|
var recast8 = __toESM(require_main2(), 1);
|
|
57127
57504
|
|
|
57128
57505
|
// src/codegen/generators/typescript/types.ts
|
|
57129
|
-
var
|
|
57506
|
+
var graphql13 = __toESM(require_graphql2(), 1);
|
|
57130
57507
|
var recast7 = __toESM(require_main2(), 1);
|
|
57131
57508
|
var AST7 = recast7.types.builders;
|
|
57132
57509
|
function readonlyProperty(prop, enable = true) {
|
|
@@ -57157,336 +57534,89 @@ function scalarPropertyValue(config2, missingScalars, target) {
|
|
|
57157
57534
|
return AST7.tsBooleanKeyword();
|
|
57158
57535
|
}
|
|
57159
57536
|
case "ID": {
|
|
57160
|
-
return AST7.tsStringKeyword();
|
|
57161
|
-
}
|
|
57162
|
-
default: {
|
|
57163
|
-
if (
|
|
57164
|
-
return scalarPropertyValue(
|
|
57165
|
-
config2,
|
|
57166
|
-
missingScalars,
|
|
57167
|
-
target.ofType
|
|
57168
|
-
);
|
|
57169
|
-
}
|
|
57170
|
-
if (config2.scalars?.[target.name]) {
|
|
57171
|
-
return AST7.tsTypeReference(AST7.identifier(config2.scalars?.[target.name].type));
|
|
57172
|
-
}
|
|
57173
|
-
missingScalars.add(target.name);
|
|
57174
|
-
return AST7.tsAnyKeyword();
|
|
57175
|
-
}
|
|
57176
|
-
}
|
|
57177
|
-
}
|
|
57178
|
-
|
|
57179
|
-
// src/codegen/generators/typescript/typeReference.ts
|
|
57180
|
-
var AST8 = recast8.types.builders;
|
|
57181
|
-
function tsTypeReference(config2, missingScalars, definition) {
|
|
57182
|
-
const { type, wrappers } = unwrapType(config2, definition.type);
|
|
57183
|
-
let result;
|
|
57184
|
-
if (graphql13.isScalarType(type)) {
|
|
57185
|
-
result = scalarPropertyValue(config2, missingScalars, type);
|
|
57186
|
-
} else {
|
|
57187
|
-
result = AST8.tsTypeReference(AST8.identifier(type.name));
|
|
57188
|
-
}
|
|
57189
|
-
for (const toWrap of wrappers) {
|
|
57190
|
-
if (toWrap === "NonNull" /* NonNull */) {
|
|
57191
|
-
continue;
|
|
57192
|
-
} else if (toWrap === "Nullable" /* Nullable */) {
|
|
57193
|
-
result = nullableField(result, true);
|
|
57194
|
-
} else if (toWrap === "List" /* List */) {
|
|
57195
|
-
result = AST8.tsArrayType(AST8.tsParenthesizedType(result));
|
|
57196
|
-
}
|
|
57197
|
-
}
|
|
57198
|
-
return result;
|
|
57199
|
-
}
|
|
57200
|
-
|
|
57201
|
-
// src/codegen/generators/typescript/addReferencedInputTypes.ts
|
|
57202
|
-
var AST9 = recast9.types.builders;
|
|
57203
|
-
function addReferencedInputTypes(config2, filepath, body, visitedTypes, missingScalars, rootType) {
|
|
57204
|
-
const { type } = unwrapType(config2, rootType);
|
|
57205
|
-
if (graphql14.isScalarType(type)) {
|
|
57206
|
-
return;
|
|
57207
|
-
}
|
|
57208
|
-
if (visitedTypes.has(type.name)) {
|
|
57209
|
-
return;
|
|
57210
|
-
}
|
|
57211
|
-
if (graphql14.isUnionType(type)) {
|
|
57212
|
-
throw new HoudiniError({ filepath, message: "Input Unions are not supported yet. Sorry!" });
|
|
57213
|
-
}
|
|
57214
|
-
visitedTypes.add(type.name);
|
|
57215
|
-
if (graphql14.isEnumType(type)) {
|
|
57216
|
-
ensureImports({
|
|
57217
|
-
config: config2,
|
|
57218
|
-
body,
|
|
57219
|
-
import: [type.name],
|
|
57220
|
-
sourceModule: "$houdini/graphql/enums",
|
|
57221
|
-
importKind: "type"
|
|
57222
|
-
});
|
|
57223
|
-
return;
|
|
57224
|
-
}
|
|
57225
|
-
const members = [];
|
|
57226
|
-
for (const field of Object.values(type.getFields())) {
|
|
57227
|
-
addReferencedInputTypes(config2, filepath, body, visitedTypes, missingScalars, field.type);
|
|
57228
|
-
members.push(
|
|
57229
|
-
AST9.tsPropertySignature(
|
|
57230
|
-
AST9.identifier(field.name),
|
|
57231
|
-
AST9.tsTypeAnnotation(tsTypeReference(config2, missingScalars, field)),
|
|
57232
|
-
graphql14.isNullableType(field.type)
|
|
57233
|
-
)
|
|
57234
|
-
);
|
|
57235
|
-
}
|
|
57236
|
-
body.push(AST9.tsTypeAliasDeclaration(AST9.identifier(type.name), AST9.tsTypeLiteral(members)));
|
|
57237
|
-
}
|
|
57238
|
-
|
|
57239
|
-
// src/codegen/generators/typescript/imperativeCache.ts
|
|
57240
|
-
var graphql15 = __toESM(require_graphql2(), 1);
|
|
57241
|
-
var recast10 = __toESM(require_main2(), 1);
|
|
57242
|
-
var AST10 = recast10.types.builders;
|
|
57243
|
-
async function imperativeCacheTypef(config2, docs) {
|
|
57244
|
-
const target = path_exports.join(config2.runtimeDirectory, "generated.d.ts");
|
|
57245
|
-
const body = [];
|
|
57246
|
-
const declaration = AST10.tsTypeAliasDeclaration(
|
|
57247
|
-
AST10.identifier(CacheTypeDefName),
|
|
57248
|
-
AST10.tsTypeLiteral([
|
|
57249
|
-
AST10.tsPropertySignature(
|
|
57250
|
-
AST10.identifier("types"),
|
|
57251
|
-
AST10.tsTypeAnnotation(typeDefinitions(config2, body))
|
|
57252
|
-
),
|
|
57253
|
-
AST10.tsPropertySignature(
|
|
57254
|
-
AST10.identifier("lists"),
|
|
57255
|
-
AST10.tsTypeAnnotation(listDefinitions(config2, docs))
|
|
57256
|
-
)
|
|
57257
|
-
])
|
|
57258
|
-
);
|
|
57259
|
-
declaration.declare = true;
|
|
57260
|
-
const importRecord = AST10.importDeclaration(
|
|
57261
|
-
[AST10.importSpecifier(AST10.identifier("Record"))],
|
|
57262
|
-
AST10.stringLiteral("./public/record")
|
|
57263
|
-
);
|
|
57264
|
-
importRecord.importKind = "type";
|
|
57265
|
-
await fs_exports.writeFile(
|
|
57266
|
-
target,
|
|
57267
|
-
recast10.prettyPrint(
|
|
57268
|
-
AST10.program([importRecord, ...body, AST10.exportNamedDeclaration(declaration)])
|
|
57269
|
-
).code
|
|
57270
|
-
);
|
|
57271
|
-
}
|
|
57272
|
-
function typeDefinitions(config2, body) {
|
|
57273
|
-
const operationTypes = [config2.schema.getMutationType(), config2.schema.getSubscriptionType()].filter(Boolean).map((type) => type?.name);
|
|
57274
|
-
const visitedTypes = /* @__PURE__ */ new Set();
|
|
57275
|
-
const types14 = Object.values(config2.schema.getTypeMap()).filter(
|
|
57276
|
-
(type) => !graphql15.isAbstractType(type) && !graphql15.isScalarType(type) && !graphql15.isEnumType(type) && !graphql15.isInputObjectType(type) && !type.name.startsWith("__") && !operationTypes.includes(type.name)
|
|
57277
|
-
);
|
|
57278
|
-
return AST10.tsTypeLiteral(
|
|
57279
|
-
types14.map((type) => {
|
|
57280
|
-
let typeName = type.name;
|
|
57281
|
-
if (config2.schema.getQueryType() && config2.schema.getQueryType()?.name === type.name) {
|
|
57282
|
-
typeName = "__ROOT__";
|
|
57283
|
-
}
|
|
57284
|
-
let idFields = AST10.tsNeverKeyword();
|
|
57285
|
-
const keys = keyFieldsForType(config2.configFile, type.name);
|
|
57286
|
-
if (graphql15.isObjectType(type) && keys.length > 0 && keys.every((key) => type.getFields()[key])) {
|
|
57287
|
-
idFields = AST10.tsTypeLiteral(
|
|
57288
|
-
keys.map((key) => {
|
|
57289
|
-
const fieldType = type.getFields()[key];
|
|
57290
|
-
const unwrapped = unwrapType(config2, fieldType.type);
|
|
57291
|
-
return AST10.tsPropertySignature(
|
|
57292
|
-
AST10.identifier(key),
|
|
57293
|
-
AST10.tsTypeAnnotation(
|
|
57294
|
-
scalarPropertyValue(config2, /* @__PURE__ */ new Set(), unwrapped.type)
|
|
57295
|
-
)
|
|
57296
|
-
);
|
|
57297
|
-
})
|
|
57298
|
-
);
|
|
57299
|
-
} else if (typeName === "__ROOT__") {
|
|
57300
|
-
idFields = AST10.tsTypeLiteral([]);
|
|
57301
|
-
}
|
|
57302
|
-
let fields = AST10.tsTypeLiteral([]);
|
|
57303
|
-
if (graphql15.isObjectType(type)) {
|
|
57304
|
-
fields = AST10.tsTypeLiteral(
|
|
57305
|
-
Object.entries(type.getFields()).map(
|
|
57306
|
-
([key, fieldType]) => {
|
|
57307
|
-
const unwrapped = unwrapType(config2, fieldType.type);
|
|
57308
|
-
let typeOptions = AST10.tsUnionType([]);
|
|
57309
|
-
if (graphql15.isScalarType(unwrapped.type)) {
|
|
57310
|
-
typeOptions.types.push(
|
|
57311
|
-
scalarPropertyValue(config2, /* @__PURE__ */ new Set(), unwrapped.type)
|
|
57312
|
-
);
|
|
57313
|
-
} else if (graphql15.isEnumType(unwrapped.type)) {
|
|
57314
|
-
typeOptions.types.push(
|
|
57315
|
-
AST10.tsTypeReference(AST10.identifier(unwrapped.type.name))
|
|
57316
|
-
);
|
|
57317
|
-
} else if (!graphql15.isAbstractType(unwrapped.type)) {
|
|
57318
|
-
typeOptions.types.push(record(unwrapped.type.name));
|
|
57319
|
-
} else {
|
|
57320
|
-
typeOptions.types.push(
|
|
57321
|
-
...config2.schema.getPossibleTypes(unwrapped.type).map((type2) => record(type2.name))
|
|
57322
|
-
);
|
|
57323
|
-
}
|
|
57324
|
-
for (const wrapper of unwrapped.wrappers) {
|
|
57325
|
-
if (wrapper === "Nullable" /* Nullable */) {
|
|
57326
|
-
typeOptions = AST10.tsParenthesizedType(
|
|
57327
|
-
AST10.tsUnionType([typeOptions, AST10.tsNullKeyword()])
|
|
57328
|
-
);
|
|
57329
|
-
} else if (wrapper === "List" /* List */) {
|
|
57330
|
-
typeOptions = AST10.tsArrayType(
|
|
57331
|
-
AST10.tsParenthesizedType(typeOptions)
|
|
57332
|
-
);
|
|
57333
|
-
}
|
|
57334
|
-
}
|
|
57335
|
-
if (typeOptions.type === "TSParenthesizedType") {
|
|
57336
|
-
typeOptions = typeOptions.typeAnnotation;
|
|
57337
|
-
}
|
|
57338
|
-
let args = AST10.tsNeverKeyword();
|
|
57339
|
-
if (fieldType.args?.length > 0) {
|
|
57340
|
-
args = AST10.tsTypeLiteral(
|
|
57341
|
-
fieldType.args.map((arg) => {
|
|
57342
|
-
addReferencedInputTypes(
|
|
57343
|
-
config2,
|
|
57344
|
-
"",
|
|
57345
|
-
body,
|
|
57346
|
-
visitedTypes,
|
|
57347
|
-
/* @__PURE__ */ new Set(),
|
|
57348
|
-
arg.type
|
|
57349
|
-
);
|
|
57350
|
-
const prop = AST10.tsPropertySignature(
|
|
57351
|
-
AST10.identifier(arg.name),
|
|
57352
|
-
AST10.tsTypeAnnotation(
|
|
57353
|
-
tsTypeReference(config2, /* @__PURE__ */ new Set(), arg)
|
|
57354
|
-
)
|
|
57355
|
-
);
|
|
57356
|
-
const unwrapped2 = unwrapType(config2, arg.type);
|
|
57357
|
-
prop.optional = unwrapped2.wrappers[unwrapped2.wrappers.length - 1] === "Nullable" /* Nullable */;
|
|
57358
|
-
return prop;
|
|
57359
|
-
})
|
|
57360
|
-
);
|
|
57361
|
-
}
|
|
57362
|
-
return AST10.tsPropertySignature(
|
|
57363
|
-
AST10.identifier(key),
|
|
57364
|
-
AST10.tsTypeAnnotation(
|
|
57365
|
-
AST10.tsTypeLiteral([
|
|
57366
|
-
AST10.tsPropertySignature(
|
|
57367
|
-
AST10.identifier("type"),
|
|
57368
|
-
AST10.tsTypeAnnotation(typeOptions)
|
|
57369
|
-
),
|
|
57370
|
-
AST10.tsPropertySignature(
|
|
57371
|
-
AST10.identifier("args"),
|
|
57372
|
-
AST10.tsTypeAnnotation(args)
|
|
57373
|
-
)
|
|
57374
|
-
])
|
|
57375
|
-
)
|
|
57376
|
-
);
|
|
57377
|
-
}
|
|
57378
|
-
)
|
|
57537
|
+
return AST7.tsStringKeyword();
|
|
57538
|
+
}
|
|
57539
|
+
default: {
|
|
57540
|
+
if (graphql13.isNonNullType(target) && "ofType" in target) {
|
|
57541
|
+
return scalarPropertyValue(
|
|
57542
|
+
config2,
|
|
57543
|
+
missingScalars,
|
|
57544
|
+
target.ofType
|
|
57379
57545
|
);
|
|
57380
57546
|
}
|
|
57381
|
-
|
|
57382
|
-
|
|
57383
|
-
AST10.tsTypeAnnotation(
|
|
57384
|
-
AST10.tsTypeLiteral([
|
|
57385
|
-
AST10.tsPropertySignature(
|
|
57386
|
-
AST10.identifier("idFields"),
|
|
57387
|
-
AST10.tsTypeAnnotation(idFields)
|
|
57388
|
-
),
|
|
57389
|
-
AST10.tsPropertySignature(
|
|
57390
|
-
AST10.identifier("fields"),
|
|
57391
|
-
AST10.tsTypeAnnotation(fields)
|
|
57392
|
-
)
|
|
57393
|
-
])
|
|
57394
|
-
)
|
|
57395
|
-
);
|
|
57396
|
-
})
|
|
57397
|
-
);
|
|
57398
|
-
}
|
|
57399
|
-
function listDefinitions(config2, docs) {
|
|
57400
|
-
const lists = [];
|
|
57401
|
-
const visitedLists = /* @__PURE__ */ new Set();
|
|
57402
|
-
for (const doc of docs) {
|
|
57403
|
-
graphql15.visit(doc.document, {
|
|
57404
|
-
Directive(node, key, parent, path2, ancestors) {
|
|
57405
|
-
if (![config2.listDirective, config2.paginateDirective].includes(node.name.value)) {
|
|
57406
|
-
return;
|
|
57407
|
-
}
|
|
57408
|
-
const nameArg = node.arguments?.find((arg) => arg.name.value === "name");
|
|
57409
|
-
const nameValue = nameArg?.value?.value || "";
|
|
57410
|
-
if (!nameValue || visitedLists.has(nameValue)) {
|
|
57411
|
-
return;
|
|
57412
|
-
}
|
|
57413
|
-
visitedLists.add(nameValue);
|
|
57414
|
-
const parentType = parentTypeFromAncestors(
|
|
57415
|
-
config2.schema,
|
|
57416
|
-
doc.filename,
|
|
57417
|
-
ancestors.slice(0, -1)
|
|
57418
|
-
);
|
|
57419
|
-
const targetField = ancestors[ancestors.length - 1];
|
|
57420
|
-
const targetFieldDefinition = parentType.getFields()[targetField.name.value];
|
|
57421
|
-
const { type: listType } = unwrapType(config2, targetFieldDefinition.type);
|
|
57422
|
-
const possibleTypes = [];
|
|
57423
|
-
if (graphql15.isAbstractType(listType)) {
|
|
57424
|
-
possibleTypes.push(
|
|
57425
|
-
...config2.schema.getPossibleTypes(listType).map((possible) => possible.name)
|
|
57426
|
-
);
|
|
57427
|
-
} else {
|
|
57428
|
-
possibleTypes.push(listType.name);
|
|
57429
|
-
}
|
|
57430
|
-
lists.push(
|
|
57431
|
-
AST10.tsPropertySignature(
|
|
57432
|
-
AST10.identifier(nameValue),
|
|
57433
|
-
AST10.tsTypeAnnotation(
|
|
57434
|
-
AST10.tsTypeLiteral([
|
|
57435
|
-
AST10.tsPropertySignature(
|
|
57436
|
-
AST10.identifier("types"),
|
|
57437
|
-
AST10.tsTypeAnnotation(
|
|
57438
|
-
AST10.tsUnionType(
|
|
57439
|
-
possibleTypes.map(
|
|
57440
|
-
(possible) => AST10.tsLiteralType(AST10.stringLiteral(possible))
|
|
57441
|
-
)
|
|
57442
|
-
)
|
|
57443
|
-
)
|
|
57444
|
-
),
|
|
57445
|
-
AST10.tsPropertySignature(
|
|
57446
|
-
AST10.identifier("filters"),
|
|
57447
|
-
AST10.tsTypeAnnotation(
|
|
57448
|
-
targetFieldDefinition.args.length === 0 ? AST10.tsNeverKeyword() : AST10.tsTypeLiteral(
|
|
57449
|
-
targetFieldDefinition.args.map((arg) => {
|
|
57450
|
-
const argDef = AST10.tsPropertySignature(
|
|
57451
|
-
AST10.identifier(arg.name),
|
|
57452
|
-
AST10.tsTypeAnnotation(
|
|
57453
|
-
tsTypeReference(
|
|
57454
|
-
config2,
|
|
57455
|
-
/* @__PURE__ */ new Set(),
|
|
57456
|
-
arg
|
|
57457
|
-
)
|
|
57458
|
-
)
|
|
57459
|
-
);
|
|
57460
|
-
argDef.optional = true;
|
|
57461
|
-
return argDef;
|
|
57462
|
-
})
|
|
57463
|
-
)
|
|
57464
|
-
)
|
|
57465
|
-
)
|
|
57466
|
-
])
|
|
57467
|
-
)
|
|
57468
|
-
)
|
|
57469
|
-
);
|
|
57547
|
+
if (config2.scalars?.[target.name]) {
|
|
57548
|
+
return AST7.tsTypeReference(AST7.identifier(config2.scalars?.[target.name].type));
|
|
57470
57549
|
}
|
|
57471
|
-
|
|
57550
|
+
missingScalars.add(target.name);
|
|
57551
|
+
return AST7.tsAnyKeyword();
|
|
57552
|
+
}
|
|
57472
57553
|
}
|
|
57473
|
-
return AST10.tsTypeLiteral(lists);
|
|
57474
57554
|
}
|
|
57475
|
-
|
|
57476
|
-
|
|
57477
|
-
|
|
57478
|
-
|
|
57479
|
-
|
|
57480
|
-
|
|
57481
|
-
|
|
57482
|
-
|
|
57483
|
-
|
|
57555
|
+
|
|
57556
|
+
// src/codegen/generators/typescript/typeReference.ts
|
|
57557
|
+
var AST8 = recast8.types.builders;
|
|
57558
|
+
function tsTypeReference(config2, missingScalars, definition) {
|
|
57559
|
+
const { type, wrappers } = unwrapType(config2, definition.type);
|
|
57560
|
+
let result;
|
|
57561
|
+
if (graphql14.isScalarType(type)) {
|
|
57562
|
+
result = scalarPropertyValue(config2, missingScalars, type);
|
|
57563
|
+
} else {
|
|
57564
|
+
result = AST8.tsTypeReference(AST8.identifier(type.name));
|
|
57565
|
+
}
|
|
57566
|
+
for (const toWrap of wrappers) {
|
|
57567
|
+
if (toWrap === "NonNull" /* NonNull */) {
|
|
57568
|
+
continue;
|
|
57569
|
+
} else if (toWrap === "Nullable" /* Nullable */) {
|
|
57570
|
+
result = nullableField(result, true);
|
|
57571
|
+
} else if (toWrap === "List" /* List */) {
|
|
57572
|
+
result = AST8.tsArrayType(AST8.tsParenthesizedType(result));
|
|
57573
|
+
}
|
|
57574
|
+
}
|
|
57575
|
+
return result;
|
|
57576
|
+
}
|
|
57577
|
+
|
|
57578
|
+
// src/codegen/generators/typescript/addReferencedInputTypes.ts
|
|
57579
|
+
var AST9 = recast9.types.builders;
|
|
57580
|
+
function addReferencedInputTypes(config2, filepath, body, visitedTypes, missingScalars, rootType) {
|
|
57581
|
+
const { type } = unwrapType(config2, rootType);
|
|
57582
|
+
if (graphql15.isScalarType(type)) {
|
|
57583
|
+
return;
|
|
57584
|
+
}
|
|
57585
|
+
if (visitedTypes.has(type.name)) {
|
|
57586
|
+
return;
|
|
57587
|
+
}
|
|
57588
|
+
if (graphql15.isUnionType(type)) {
|
|
57589
|
+
throw new HoudiniError({ filepath, message: "Input Unions are not supported yet. Sorry!" });
|
|
57590
|
+
}
|
|
57591
|
+
visitedTypes.add(type.name);
|
|
57592
|
+
if (graphql15.isEnumType(type)) {
|
|
57593
|
+
ensureImports({
|
|
57594
|
+
config: config2,
|
|
57595
|
+
body,
|
|
57596
|
+
import: [type.name],
|
|
57597
|
+
sourceModule: "$houdini/graphql/enums",
|
|
57598
|
+
importKind: "type"
|
|
57599
|
+
});
|
|
57600
|
+
return;
|
|
57601
|
+
}
|
|
57602
|
+
const members = [];
|
|
57603
|
+
for (const field of Object.values(type.getFields())) {
|
|
57604
|
+
addReferencedInputTypes(config2, filepath, body, visitedTypes, missingScalars, field.type);
|
|
57605
|
+
members.push(
|
|
57606
|
+
AST9.tsPropertySignature(
|
|
57607
|
+
AST9.identifier(field.name),
|
|
57608
|
+
AST9.tsTypeAnnotation(tsTypeReference(config2, missingScalars, field)),
|
|
57609
|
+
graphql15.isNullableType(field.type)
|
|
57610
|
+
)
|
|
57611
|
+
);
|
|
57612
|
+
}
|
|
57613
|
+
body.push(AST9.tsTypeAliasDeclaration(AST9.identifier(type.name), AST9.tsTypeLiteral(members)));
|
|
57484
57614
|
}
|
|
57485
57615
|
|
|
57486
57616
|
// src/codegen/generators/typescript/inlineType.ts
|
|
57487
57617
|
var graphql16 = __toESM(require_graphql2(), 1);
|
|
57488
|
-
var
|
|
57489
|
-
var
|
|
57618
|
+
var recast10 = __toESM(require_main2(), 1);
|
|
57619
|
+
var AST10 = recast10.types.builders;
|
|
57490
57620
|
var fragmentKey = "$fragments";
|
|
57491
57621
|
function inlineType({
|
|
57492
57622
|
config: config2,
|
|
@@ -57515,7 +57645,7 @@ function inlineType({
|
|
|
57515
57645
|
});
|
|
57516
57646
|
visitedTypes.add(type.name);
|
|
57517
57647
|
}
|
|
57518
|
-
result =
|
|
57648
|
+
result = AST10.tsTypeReference(AST10.identifier(type.name));
|
|
57519
57649
|
} else if (selections) {
|
|
57520
57650
|
const rootObj = type;
|
|
57521
57651
|
const inlineFragments = {};
|
|
@@ -57566,7 +57696,7 @@ function inlineType({
|
|
|
57566
57696
|
selectedFields.push(selection2);
|
|
57567
57697
|
}
|
|
57568
57698
|
}
|
|
57569
|
-
result =
|
|
57699
|
+
result = AST10.tsTypeLiteral([
|
|
57570
57700
|
...(selectedFields || []).filter(
|
|
57571
57701
|
(field) => field.kind === "Field"
|
|
57572
57702
|
).map((selection2) => {
|
|
@@ -57586,9 +57716,9 @@ function inlineType({
|
|
|
57586
57716
|
allOptional
|
|
57587
57717
|
});
|
|
57588
57718
|
const prop = readonlyProperty(
|
|
57589
|
-
|
|
57590
|
-
|
|
57591
|
-
|
|
57719
|
+
AST10.tsPropertySignature(
|
|
57720
|
+
AST10.identifier(attributeName),
|
|
57721
|
+
AST10.tsTypeAnnotation(attributeType)
|
|
57592
57722
|
),
|
|
57593
57723
|
allowReadonly
|
|
57594
57724
|
);
|
|
@@ -57602,15 +57732,15 @@ function inlineType({
|
|
|
57602
57732
|
if (includeFragments && fragmentSpreads && fragmentSpreads.length) {
|
|
57603
57733
|
result.members.push(
|
|
57604
57734
|
readonlyProperty(
|
|
57605
|
-
|
|
57606
|
-
|
|
57607
|
-
|
|
57608
|
-
|
|
57735
|
+
AST10.tsPropertySignature(
|
|
57736
|
+
AST10.identifier(fragmentKey),
|
|
57737
|
+
AST10.tsTypeAnnotation(
|
|
57738
|
+
AST10.tsTypeLiteral(
|
|
57609
57739
|
(fragmentSpreads || []).map(
|
|
57610
|
-
(fragmentSpread) =>
|
|
57611
|
-
|
|
57612
|
-
|
|
57613
|
-
|
|
57740
|
+
(fragmentSpread) => AST10.tsPropertySignature(
|
|
57741
|
+
AST10.identifier(fragmentSpread.name.value),
|
|
57742
|
+
AST10.tsTypeAnnotation(
|
|
57743
|
+
AST10.tsLiteralType(AST10.booleanLiteral(true))
|
|
57614
57744
|
)
|
|
57615
57745
|
)
|
|
57616
57746
|
)
|
|
@@ -57656,9 +57786,9 @@ function inlineType({
|
|
|
57656
57786
|
}
|
|
57657
57787
|
objectType.members.push(
|
|
57658
57788
|
readonlyProperty(
|
|
57659
|
-
|
|
57660
|
-
|
|
57661
|
-
|
|
57789
|
+
AST10.tsPropertySignature(
|
|
57790
|
+
AST10.identifier("__typename"),
|
|
57791
|
+
AST10.tsTypeAnnotation(AST10.tsLiteralType(AST10.stringLiteral(typeName)))
|
|
57662
57792
|
),
|
|
57663
57793
|
allowReadonly
|
|
57664
57794
|
)
|
|
@@ -57669,8 +57799,8 @@ function inlineType({
|
|
|
57669
57799
|
if (Object.keys(inlineFragmentSelections).length > 0) {
|
|
57670
57800
|
let selectionTypes = Object.entries(inlineFragmentSelections).map(
|
|
57671
57801
|
([typeName, { type: type2, tsType }]) => {
|
|
57672
|
-
return
|
|
57673
|
-
|
|
57802
|
+
return AST10.tsParenthesizedType(
|
|
57803
|
+
AST10.tsIntersectionType(
|
|
57674
57804
|
[tsType].flatMap((type3) => {
|
|
57675
57805
|
if (type3.type === "TSUnionType") {
|
|
57676
57806
|
return type3.types.filter(
|
|
@@ -57683,9 +57813,9 @@ function inlineType({
|
|
|
57683
57813
|
);
|
|
57684
57814
|
}
|
|
57685
57815
|
);
|
|
57686
|
-
result =
|
|
57816
|
+
result = AST10.tsIntersectionType([
|
|
57687
57817
|
result,
|
|
57688
|
-
|
|
57818
|
+
AST10.tsParenthesizedType(AST10.tsUnionType(selectionTypes))
|
|
57689
57819
|
]);
|
|
57690
57820
|
}
|
|
57691
57821
|
} else {
|
|
@@ -57697,7 +57827,7 @@ function inlineType({
|
|
|
57697
57827
|
} else if (toWrap === "NonNull" /* NonNull */) {
|
|
57698
57828
|
continue;
|
|
57699
57829
|
} else if (toWrap === "List" /* List */) {
|
|
57700
|
-
result =
|
|
57830
|
+
result = AST10.tsArrayType(AST10.tsParenthesizedType(result));
|
|
57701
57831
|
}
|
|
57702
57832
|
}
|
|
57703
57833
|
return result;
|
|
@@ -57741,9 +57871,9 @@ function selectionTypeInfo(schema, filepath, rootType, selection2) {
|
|
|
57741
57871
|
return { field, type: selectionType };
|
|
57742
57872
|
}
|
|
57743
57873
|
|
|
57744
|
-
// src/codegen/generators/typescript/
|
|
57745
|
-
var
|
|
57746
|
-
async function
|
|
57874
|
+
// src/codegen/generators/typescript/documentTypes.ts
|
|
57875
|
+
var AST11 = recast11.types.builders;
|
|
57876
|
+
async function generateDocumentTypes(config2, docs) {
|
|
57747
57877
|
const typePaths = [];
|
|
57748
57878
|
const fragmentDefinitions = {};
|
|
57749
57879
|
for (const document of docs) {
|
|
@@ -57760,7 +57890,7 @@ async function typescriptGenerator(config2, docs) {
|
|
|
57760
57890
|
return;
|
|
57761
57891
|
}
|
|
57762
57892
|
const typeDefPath = config2.artifactTypePath(originalDocument);
|
|
57763
|
-
const program =
|
|
57893
|
+
const program = AST11.program([]);
|
|
57764
57894
|
const visitedTypes = /* @__PURE__ */ new Set();
|
|
57765
57895
|
let definition = originalDocument.definitions.find(
|
|
57766
57896
|
(def) => (def.kind === "OperationDefinition" || def.kind === "FragmentDefinition") && def.name?.value === name2
|
|
@@ -57793,21 +57923,21 @@ async function typescriptGenerator(config2, docs) {
|
|
|
57793
57923
|
missingScalars
|
|
57794
57924
|
);
|
|
57795
57925
|
}
|
|
57796
|
-
await fs_exports.writeFile(typeDefPath,
|
|
57926
|
+
await fs_exports.writeFile(typeDefPath, recast11.print(program).code);
|
|
57797
57927
|
typePaths.push(typeDefPath);
|
|
57798
57928
|
})
|
|
57799
57929
|
);
|
|
57800
|
-
const typeIndex =
|
|
57930
|
+
const typeIndex = AST11.program(
|
|
57801
57931
|
typePaths.sort((a, b) => a.localeCompare(b)).map((typePath) => {
|
|
57802
|
-
return
|
|
57803
|
-
|
|
57932
|
+
return AST11.exportAllDeclaration(
|
|
57933
|
+
AST11.literal(
|
|
57804
57934
|
"./" + path_exports.relative(path_exports.resolve(config2.typeIndexPath, ".."), typePath).replace(/\.[^/.]+\.[^/.]+$/, "")
|
|
57805
57935
|
),
|
|
57806
57936
|
null
|
|
57807
57937
|
);
|
|
57808
57938
|
}).concat([
|
|
57809
|
-
|
|
57810
|
-
|
|
57939
|
+
AST11.exportAllDeclaration(AST11.literal("./runtime"), null),
|
|
57940
|
+
AST11.exportAllDeclaration(AST11.literal("./graphql"), null)
|
|
57811
57941
|
])
|
|
57812
57942
|
);
|
|
57813
57943
|
const export_default_as = ({ module, as }) => `
|
|
@@ -57816,7 +57946,7 @@ export { default as ${as} } from "${module}"
|
|
|
57816
57946
|
const export_star_from = ({ module }) => `
|
|
57817
57947
|
export * from "${module}"
|
|
57818
57948
|
`;
|
|
57819
|
-
let indexContent =
|
|
57949
|
+
let indexContent = recast11.print(typeIndex).code;
|
|
57820
57950
|
for (const plugin of config2.plugins) {
|
|
57821
57951
|
if (!plugin.index_file) {
|
|
57822
57952
|
continue;
|
|
@@ -57837,7 +57967,6 @@ export * from "${module}"
|
|
|
57837
57967
|
}
|
|
57838
57968
|
}
|
|
57839
57969
|
await fs_exports.writeFile(config2.typeIndexPath, indexContent);
|
|
57840
|
-
await imperativeCacheTypef(config2, docs);
|
|
57841
57970
|
if (missingScalars.size > 0) {
|
|
57842
57971
|
console.warn(`\u26A0\uFE0F Missing definitions for the following scalars: ${[...missingScalars].join(
|
|
57843
57972
|
", "
|
|
@@ -57879,23 +58008,23 @@ async function generateOperationTypeDefs(config2, filepath, body, definition, se
|
|
|
57879
58008
|
const optimisticTypeName = `${definition.name.value}$optimistic`;
|
|
57880
58009
|
const hasInputs = definition.variableDefinitions && definition.variableDefinitions.length > 0;
|
|
57881
58010
|
body.push(
|
|
57882
|
-
|
|
57883
|
-
|
|
57884
|
-
|
|
57885
|
-
|
|
58011
|
+
AST11.exportNamedDeclaration(
|
|
58012
|
+
AST11.tsTypeAliasDeclaration(
|
|
58013
|
+
AST11.identifier(definition.name.value),
|
|
58014
|
+
AST11.tsTypeLiteral([
|
|
57886
58015
|
readonlyProperty(
|
|
57887
|
-
|
|
57888
|
-
|
|
57889
|
-
|
|
58016
|
+
AST11.tsPropertySignature(
|
|
58017
|
+
AST11.stringLiteral("input"),
|
|
58018
|
+
AST11.tsTypeAnnotation(AST11.tsTypeReference(AST11.identifier(inputTypeName)))
|
|
57890
58019
|
)
|
|
57891
58020
|
),
|
|
57892
58021
|
readonlyProperty(
|
|
57893
|
-
|
|
57894
|
-
|
|
57895
|
-
|
|
57896
|
-
definition.operation === "mutation" ?
|
|
57897
|
-
|
|
57898
|
-
|
|
58022
|
+
AST11.tsPropertySignature(
|
|
58023
|
+
AST11.stringLiteral("result"),
|
|
58024
|
+
AST11.tsTypeAnnotation(
|
|
58025
|
+
definition.operation === "mutation" ? AST11.tsTypeReference(AST11.identifier(shapeTypeName)) : AST11.tsUnionType([
|
|
58026
|
+
AST11.tsTypeReference(AST11.identifier(shapeTypeName)),
|
|
58027
|
+
AST11.tsUndefinedKeyword()
|
|
57899
58028
|
])
|
|
57900
58029
|
)
|
|
57901
58030
|
)
|
|
@@ -57903,9 +58032,9 @@ async function generateOperationTypeDefs(config2, filepath, body, definition, se
|
|
|
57903
58032
|
])
|
|
57904
58033
|
)
|
|
57905
58034
|
),
|
|
57906
|
-
|
|
57907
|
-
|
|
57908
|
-
|
|
58035
|
+
AST11.exportNamedDeclaration(
|
|
58036
|
+
AST11.tsTypeAliasDeclaration(
|
|
58037
|
+
AST11.identifier(shapeTypeName),
|
|
57909
58038
|
inlineType({
|
|
57910
58039
|
config: config2,
|
|
57911
58040
|
filepath,
|
|
@@ -57933,15 +58062,15 @@ async function generateOperationTypeDefs(config2, filepath, body, definition, se
|
|
|
57933
58062
|
);
|
|
57934
58063
|
}
|
|
57935
58064
|
body.push(
|
|
57936
|
-
|
|
57937
|
-
|
|
57938
|
-
|
|
57939
|
-
|
|
58065
|
+
AST11.exportNamedDeclaration(
|
|
58066
|
+
AST11.tsTypeAliasDeclaration(
|
|
58067
|
+
AST11.identifier(inputTypeName),
|
|
58068
|
+
AST11.tsTypeLiteral(
|
|
57940
58069
|
(definition.variableDefinitions || []).map(
|
|
57941
58070
|
(definition2) => {
|
|
57942
|
-
return
|
|
57943
|
-
|
|
57944
|
-
|
|
58071
|
+
return AST11.tsPropertySignature(
|
|
58072
|
+
AST11.identifier(definition2.variable.name.value),
|
|
58073
|
+
AST11.tsTypeAnnotation(
|
|
57945
58074
|
tsTypeReference(config2, missingScalars, definition2)
|
|
57946
58075
|
),
|
|
57947
58076
|
definition2.type.kind !== "NonNullType"
|
|
@@ -57954,16 +58083,16 @@ async function generateOperationTypeDefs(config2, filepath, body, definition, se
|
|
|
57954
58083
|
);
|
|
57955
58084
|
} else {
|
|
57956
58085
|
body.push(
|
|
57957
|
-
|
|
57958
|
-
|
|
58086
|
+
AST11.exportNamedDeclaration(
|
|
58087
|
+
AST11.tsTypeAliasDeclaration(AST11.identifier(inputTypeName), AST11.tsNullKeyword())
|
|
57959
58088
|
)
|
|
57960
58089
|
);
|
|
57961
58090
|
}
|
|
57962
58091
|
if (definition.operation === "mutation") {
|
|
57963
58092
|
body.push(
|
|
57964
|
-
|
|
57965
|
-
|
|
57966
|
-
|
|
58093
|
+
AST11.exportNamedDeclaration(
|
|
58094
|
+
AST11.tsTypeAliasDeclaration(
|
|
58095
|
+
AST11.identifier(optimisticTypeName),
|
|
57967
58096
|
inlineType({
|
|
57968
58097
|
config: config2,
|
|
57969
58098
|
filepath,
|
|
@@ -57989,65 +58118,463 @@ async function generateFragmentTypeDefs(config2, filepath, body, selections, def
|
|
|
57989
58118
|
}
|
|
57990
58119
|
const propTypeName = definition.name.value;
|
|
57991
58120
|
const shapeTypeName = `${definition.name.value}$data`;
|
|
58121
|
+
const inputTypeName = `${definition.name.value}$input`;
|
|
57992
58122
|
const type = config2.schema.getType(definition.typeCondition.name.value);
|
|
57993
58123
|
if (!type) {
|
|
57994
58124
|
throw new Error("Should not get here");
|
|
57995
58125
|
}
|
|
58126
|
+
let extraExports = [];
|
|
58127
|
+
let directive = definition.directives?.find(
|
|
58128
|
+
(directive2) => directive2.name.value === config2.argumentsDirective
|
|
58129
|
+
);
|
|
58130
|
+
if (directive) {
|
|
58131
|
+
extraExports.push(
|
|
58132
|
+
AST11.exportNamedDeclaration(
|
|
58133
|
+
AST11.tsTypeAliasDeclaration(
|
|
58134
|
+
AST11.identifier(inputTypeName),
|
|
58135
|
+
AST11.tsTypeLiteral(
|
|
58136
|
+
(fragmentArgumentsDefinitions(config2, filepath, definition) || []).map(
|
|
58137
|
+
(definition2) => {
|
|
58138
|
+
return AST11.tsPropertySignature(
|
|
58139
|
+
AST11.identifier(definition2.variable.name.value),
|
|
58140
|
+
AST11.tsTypeAnnotation(
|
|
58141
|
+
tsTypeReference(config2, missingScalars, definition2)
|
|
58142
|
+
),
|
|
58143
|
+
definition2.type.kind !== "NonNullType"
|
|
58144
|
+
);
|
|
58145
|
+
}
|
|
58146
|
+
)
|
|
58147
|
+
)
|
|
58148
|
+
)
|
|
58149
|
+
)
|
|
58150
|
+
);
|
|
58151
|
+
}
|
|
57996
58152
|
body.push(
|
|
57997
|
-
|
|
57998
|
-
|
|
57999
|
-
|
|
58000
|
-
|
|
58153
|
+
...extraExports,
|
|
58154
|
+
AST11.exportNamedDeclaration(
|
|
58155
|
+
AST11.tsTypeAliasDeclaration(
|
|
58156
|
+
AST11.identifier(propTypeName),
|
|
58157
|
+
AST11.tsTypeLiteral([
|
|
58001
58158
|
readonlyProperty(
|
|
58002
|
-
|
|
58003
|
-
|
|
58004
|
-
|
|
58005
|
-
|
|
58159
|
+
AST11.tsPropertySignature(
|
|
58160
|
+
AST11.stringLiteral("shape"),
|
|
58161
|
+
AST11.tsTypeAnnotation(
|
|
58162
|
+
AST11.tsTypeReference(AST11.identifier(shapeTypeName))
|
|
58006
58163
|
),
|
|
58007
58164
|
true
|
|
58008
58165
|
)
|
|
58009
58166
|
),
|
|
58010
58167
|
readonlyProperty(
|
|
58011
|
-
|
|
58012
|
-
|
|
58168
|
+
AST11.tsPropertySignature(
|
|
58169
|
+
AST11.stringLiteral(fragmentKey),
|
|
58170
|
+
AST11.tsTypeAnnotation(
|
|
58171
|
+
AST11.tsTypeLiteral([
|
|
58172
|
+
AST11.tsPropertySignature(
|
|
58173
|
+
AST11.stringLiteral(propTypeName),
|
|
58174
|
+
AST11.tsTypeAnnotation(
|
|
58175
|
+
AST11.tsLiteralType(AST11.booleanLiteral(true))
|
|
58176
|
+
)
|
|
58177
|
+
)
|
|
58178
|
+
])
|
|
58179
|
+
)
|
|
58180
|
+
)
|
|
58181
|
+
)
|
|
58182
|
+
])
|
|
58183
|
+
)
|
|
58184
|
+
),
|
|
58185
|
+
AST11.exportNamedDeclaration(
|
|
58186
|
+
AST11.tsTypeAliasDeclaration(
|
|
58187
|
+
AST11.identifier(shapeTypeName),
|
|
58188
|
+
inlineType({
|
|
58189
|
+
config: config2,
|
|
58190
|
+
filepath,
|
|
58191
|
+
rootType: type,
|
|
58192
|
+
selections,
|
|
58193
|
+
root: true,
|
|
58194
|
+
allowReadonly: true,
|
|
58195
|
+
body,
|
|
58196
|
+
visitedTypes,
|
|
58197
|
+
missingScalars,
|
|
58198
|
+
includeFragments: true
|
|
58199
|
+
})
|
|
58200
|
+
)
|
|
58201
|
+
)
|
|
58202
|
+
);
|
|
58203
|
+
}
|
|
58204
|
+
}
|
|
58205
|
+
|
|
58206
|
+
// src/codegen/generators/typescript/imperativeTypeDef.ts
|
|
58207
|
+
var graphql17 = __toESM(require_graphql2(), 1);
|
|
58208
|
+
var recast12 = __toESM(require_main2(), 1);
|
|
58209
|
+
var AST12 = recast12.types.builders;
|
|
58210
|
+
async function imperativeCacheTypef(config2, docs) {
|
|
58211
|
+
const returnType = (doc) => config2.plugins.find((plugin) => plugin.graphql_tag_return)?.graphql_tag_return?.({
|
|
58212
|
+
config: config2,
|
|
58213
|
+
doc,
|
|
58214
|
+
ensure_import({ identifier, module }) {
|
|
58215
|
+
ensureImports({
|
|
58216
|
+
config: config2,
|
|
58217
|
+
body,
|
|
58218
|
+
sourceModule: module,
|
|
58219
|
+
import: [identifier]
|
|
58220
|
+
});
|
|
58221
|
+
}
|
|
58222
|
+
}) ?? "any";
|
|
58223
|
+
const target = path_exports.join(config2.runtimeDirectory, "generated.d.ts");
|
|
58224
|
+
const body = [];
|
|
58225
|
+
const declaration = AST12.tsTypeAliasDeclaration(
|
|
58226
|
+
AST12.identifier(CacheTypeDefName),
|
|
58227
|
+
AST12.tsTypeLiteral([
|
|
58228
|
+
AST12.tsPropertySignature(
|
|
58229
|
+
AST12.identifier("types"),
|
|
58230
|
+
AST12.tsTypeAnnotation(typeDefinitions(config2, body, docs, returnType))
|
|
58231
|
+
),
|
|
58232
|
+
AST12.tsPropertySignature(
|
|
58233
|
+
AST12.identifier("lists"),
|
|
58234
|
+
AST12.tsTypeAnnotation(listDefinitions(config2, docs))
|
|
58235
|
+
),
|
|
58236
|
+
AST12.tsPropertySignature(
|
|
58237
|
+
AST12.identifier("queries"),
|
|
58238
|
+
AST12.tsTypeAnnotation(queryDefinitions(config2, body, docs, returnType))
|
|
58239
|
+
)
|
|
58240
|
+
])
|
|
58241
|
+
);
|
|
58242
|
+
declaration.declare = true;
|
|
58243
|
+
const importRecord = AST12.importDeclaration(
|
|
58244
|
+
[AST12.importSpecifier(AST12.identifier("Record"))],
|
|
58245
|
+
AST12.stringLiteral("./public/record")
|
|
58246
|
+
);
|
|
58247
|
+
importRecord.importKind = "type";
|
|
58248
|
+
await fs_exports.writeFile(
|
|
58249
|
+
target,
|
|
58250
|
+
recast12.prettyPrint(
|
|
58251
|
+
AST12.program([importRecord, ...body, AST12.exportNamedDeclaration(declaration)])
|
|
58252
|
+
).code
|
|
58253
|
+
);
|
|
58254
|
+
}
|
|
58255
|
+
function typeDefinitions(config2, body, docs, returnType) {
|
|
58256
|
+
const operationTypes = [config2.schema.getMutationType(), config2.schema.getSubscriptionType()].filter(Boolean).map((type) => type?.name);
|
|
58257
|
+
const visitedTypes = /* @__PURE__ */ new Set();
|
|
58258
|
+
const types14 = Object.values(config2.schema.getTypeMap()).filter(
|
|
58259
|
+
(type) => !graphql17.isAbstractType(type) && !graphql17.isScalarType(type) && !graphql17.isEnumType(type) && !graphql17.isInputObjectType(type) && !type.name.startsWith("__") && !operationTypes.includes(type.name)
|
|
58260
|
+
);
|
|
58261
|
+
const fragmentMap = fragmentListMap(
|
|
58262
|
+
config2,
|
|
58263
|
+
types14.map((type) => type.name),
|
|
58264
|
+
body,
|
|
58265
|
+
docs,
|
|
58266
|
+
returnType
|
|
58267
|
+
);
|
|
58268
|
+
return AST12.tsTypeLiteral(
|
|
58269
|
+
types14.map((type) => {
|
|
58270
|
+
let typeName = type.name;
|
|
58271
|
+
if (config2.schema.getQueryType() && config2.schema.getQueryType()?.name === type.name) {
|
|
58272
|
+
typeName = "__ROOT__";
|
|
58273
|
+
}
|
|
58274
|
+
let idFields = AST12.tsNeverKeyword();
|
|
58275
|
+
const keys = keyFieldsForType(config2.configFile, type.name);
|
|
58276
|
+
if (graphql17.isObjectType(type) && keys.length > 0 && keys.every((key) => type.getFields()[key])) {
|
|
58277
|
+
idFields = AST12.tsTypeLiteral(
|
|
58278
|
+
keys.map((key) => {
|
|
58279
|
+
const fieldType = type.getFields()[key];
|
|
58280
|
+
const unwrapped = unwrapType(config2, fieldType.type);
|
|
58281
|
+
return AST12.tsPropertySignature(
|
|
58282
|
+
AST12.identifier(key),
|
|
58283
|
+
AST12.tsTypeAnnotation(
|
|
58284
|
+
scalarPropertyValue(config2, /* @__PURE__ */ new Set(), unwrapped.type)
|
|
58285
|
+
)
|
|
58286
|
+
);
|
|
58287
|
+
})
|
|
58288
|
+
);
|
|
58289
|
+
} else if (typeName === "__ROOT__") {
|
|
58290
|
+
idFields = AST12.tsTypeLiteral([]);
|
|
58291
|
+
}
|
|
58292
|
+
let fields = AST12.tsTypeLiteral([]);
|
|
58293
|
+
if (graphql17.isObjectType(type)) {
|
|
58294
|
+
fields = AST12.tsTypeLiteral(
|
|
58295
|
+
Object.entries(type.getFields()).map(
|
|
58296
|
+
([key, fieldType]) => {
|
|
58297
|
+
const unwrapped = unwrapType(config2, fieldType.type);
|
|
58298
|
+
let typeOptions = AST12.tsUnionType([]);
|
|
58299
|
+
if (graphql17.isScalarType(unwrapped.type)) {
|
|
58300
|
+
typeOptions.types.push(
|
|
58301
|
+
scalarPropertyValue(config2, /* @__PURE__ */ new Set(), unwrapped.type)
|
|
58302
|
+
);
|
|
58303
|
+
} else if (graphql17.isEnumType(unwrapped.type)) {
|
|
58304
|
+
typeOptions.types.push(
|
|
58305
|
+
AST12.tsTypeReference(AST12.identifier(unwrapped.type.name))
|
|
58306
|
+
);
|
|
58307
|
+
} else if (!graphql17.isAbstractType(unwrapped.type)) {
|
|
58308
|
+
typeOptions.types.push(record(unwrapped.type.name));
|
|
58309
|
+
} else {
|
|
58310
|
+
typeOptions.types.push(
|
|
58311
|
+
...config2.schema.getPossibleTypes(unwrapped.type).map((type2) => record(type2.name))
|
|
58312
|
+
);
|
|
58313
|
+
}
|
|
58314
|
+
for (const wrapper of unwrapped.wrappers) {
|
|
58315
|
+
if (wrapper === "Nullable" /* Nullable */) {
|
|
58316
|
+
typeOptions = AST12.tsParenthesizedType(
|
|
58317
|
+
AST12.tsUnionType([typeOptions, AST12.tsNullKeyword()])
|
|
58318
|
+
);
|
|
58319
|
+
} else if (wrapper === "List" /* List */) {
|
|
58320
|
+
typeOptions = AST12.tsArrayType(
|
|
58321
|
+
AST12.tsParenthesizedType(typeOptions)
|
|
58322
|
+
);
|
|
58323
|
+
}
|
|
58324
|
+
}
|
|
58325
|
+
if (typeOptions.type === "TSParenthesizedType") {
|
|
58326
|
+
typeOptions = typeOptions.typeAnnotation;
|
|
58327
|
+
}
|
|
58328
|
+
let args = AST12.tsNeverKeyword();
|
|
58329
|
+
if (fieldType.args?.length > 0) {
|
|
58330
|
+
args = AST12.tsTypeLiteral(
|
|
58331
|
+
fieldType.args.map((arg) => {
|
|
58332
|
+
addReferencedInputTypes(
|
|
58333
|
+
config2,
|
|
58334
|
+
"",
|
|
58335
|
+
body,
|
|
58336
|
+
visitedTypes,
|
|
58337
|
+
/* @__PURE__ */ new Set(),
|
|
58338
|
+
arg.type
|
|
58339
|
+
);
|
|
58340
|
+
const prop = AST12.tsPropertySignature(
|
|
58341
|
+
AST12.identifier(arg.name),
|
|
58342
|
+
AST12.tsTypeAnnotation(
|
|
58343
|
+
tsTypeReference(config2, /* @__PURE__ */ new Set(), arg)
|
|
58344
|
+
)
|
|
58345
|
+
);
|
|
58346
|
+
const unwrapped2 = unwrapType(config2, arg.type);
|
|
58347
|
+
prop.optional = unwrapped2.wrappers[unwrapped2.wrappers.length - 1] === "Nullable" /* Nullable */;
|
|
58348
|
+
return prop;
|
|
58349
|
+
})
|
|
58350
|
+
);
|
|
58351
|
+
}
|
|
58352
|
+
return AST12.tsPropertySignature(
|
|
58353
|
+
AST12.identifier(key),
|
|
58013
58354
|
AST12.tsTypeAnnotation(
|
|
58014
58355
|
AST12.tsTypeLiteral([
|
|
58015
58356
|
AST12.tsPropertySignature(
|
|
58016
|
-
AST12.
|
|
58017
|
-
AST12.tsTypeAnnotation(
|
|
58018
|
-
|
|
58019
|
-
|
|
58357
|
+
AST12.identifier("type"),
|
|
58358
|
+
AST12.tsTypeAnnotation(typeOptions)
|
|
58359
|
+
),
|
|
58360
|
+
AST12.tsPropertySignature(
|
|
58361
|
+
AST12.identifier("args"),
|
|
58362
|
+
AST12.tsTypeAnnotation(args)
|
|
58020
58363
|
)
|
|
58021
58364
|
])
|
|
58022
58365
|
)
|
|
58023
|
-
)
|
|
58366
|
+
);
|
|
58367
|
+
}
|
|
58368
|
+
)
|
|
58369
|
+
);
|
|
58370
|
+
}
|
|
58371
|
+
return AST12.tsPropertySignature(
|
|
58372
|
+
AST12.identifier(typeName),
|
|
58373
|
+
AST12.tsTypeAnnotation(
|
|
58374
|
+
AST12.tsTypeLiteral([
|
|
58375
|
+
AST12.tsPropertySignature(
|
|
58376
|
+
AST12.identifier("idFields"),
|
|
58377
|
+
AST12.tsTypeAnnotation(idFields)
|
|
58378
|
+
),
|
|
58379
|
+
AST12.tsPropertySignature(
|
|
58380
|
+
AST12.identifier("fields"),
|
|
58381
|
+
AST12.tsTypeAnnotation(fields)
|
|
58382
|
+
),
|
|
58383
|
+
AST12.tsPropertySignature(
|
|
58384
|
+
AST12.identifier("fragments"),
|
|
58385
|
+
AST12.tsTypeAnnotation(fragmentMap[typeName] ?? AST12.tsTupleType([]))
|
|
58024
58386
|
)
|
|
58025
58387
|
])
|
|
58026
58388
|
)
|
|
58389
|
+
);
|
|
58390
|
+
})
|
|
58391
|
+
);
|
|
58392
|
+
}
|
|
58393
|
+
function listDefinitions(config2, docs) {
|
|
58394
|
+
const lists = [];
|
|
58395
|
+
const visitedLists = /* @__PURE__ */ new Set();
|
|
58396
|
+
for (const doc of docs) {
|
|
58397
|
+
graphql17.visit(doc.document, {
|
|
58398
|
+
Directive(node, key, parent, path2, ancestors) {
|
|
58399
|
+
if (![config2.listDirective, config2.paginateDirective].includes(node.name.value)) {
|
|
58400
|
+
return;
|
|
58401
|
+
}
|
|
58402
|
+
const nameArg = node.arguments?.find((arg) => arg.name.value === "name");
|
|
58403
|
+
const nameValue = nameArg?.value?.value || "";
|
|
58404
|
+
if (!nameValue || visitedLists.has(nameValue)) {
|
|
58405
|
+
return;
|
|
58406
|
+
}
|
|
58407
|
+
visitedLists.add(nameValue);
|
|
58408
|
+
const parentType = parentTypeFromAncestors(
|
|
58409
|
+
config2.schema,
|
|
58410
|
+
doc.filename,
|
|
58411
|
+
ancestors.slice(0, -1)
|
|
58412
|
+
);
|
|
58413
|
+
const targetField = ancestors[ancestors.length - 1];
|
|
58414
|
+
const targetFieldDefinition = parentType.getFields()[targetField.name.value];
|
|
58415
|
+
const { type: listType } = unwrapType(config2, targetFieldDefinition.type);
|
|
58416
|
+
const possibleTypes = [];
|
|
58417
|
+
if (graphql17.isAbstractType(listType)) {
|
|
58418
|
+
possibleTypes.push(
|
|
58419
|
+
...config2.schema.getPossibleTypes(listType).map((possible) => possible.name)
|
|
58420
|
+
);
|
|
58421
|
+
} else {
|
|
58422
|
+
possibleTypes.push(listType.name);
|
|
58423
|
+
}
|
|
58424
|
+
lists.push(
|
|
58425
|
+
AST12.tsPropertySignature(
|
|
58426
|
+
AST12.identifier(nameValue),
|
|
58427
|
+
AST12.tsTypeAnnotation(
|
|
58428
|
+
AST12.tsTypeLiteral([
|
|
58429
|
+
AST12.tsPropertySignature(
|
|
58430
|
+
AST12.identifier("types"),
|
|
58431
|
+
AST12.tsTypeAnnotation(
|
|
58432
|
+
AST12.tsUnionType(
|
|
58433
|
+
possibleTypes.map(
|
|
58434
|
+
(possible) => AST12.tsLiteralType(AST12.stringLiteral(possible))
|
|
58435
|
+
)
|
|
58436
|
+
)
|
|
58437
|
+
)
|
|
58438
|
+
),
|
|
58439
|
+
AST12.tsPropertySignature(
|
|
58440
|
+
AST12.identifier("filters"),
|
|
58441
|
+
AST12.tsTypeAnnotation(
|
|
58442
|
+
targetFieldDefinition.args.length === 0 ? AST12.tsNeverKeyword() : AST12.tsTypeLiteral(
|
|
58443
|
+
targetFieldDefinition.args.map((arg) => {
|
|
58444
|
+
const argDef = AST12.tsPropertySignature(
|
|
58445
|
+
AST12.identifier(arg.name),
|
|
58446
|
+
AST12.tsTypeAnnotation(
|
|
58447
|
+
tsTypeReference(
|
|
58448
|
+
config2,
|
|
58449
|
+
/* @__PURE__ */ new Set(),
|
|
58450
|
+
arg
|
|
58451
|
+
)
|
|
58452
|
+
)
|
|
58453
|
+
);
|
|
58454
|
+
argDef.optional = true;
|
|
58455
|
+
return argDef;
|
|
58456
|
+
})
|
|
58457
|
+
)
|
|
58458
|
+
)
|
|
58459
|
+
)
|
|
58460
|
+
])
|
|
58461
|
+
)
|
|
58462
|
+
)
|
|
58463
|
+
);
|
|
58464
|
+
}
|
|
58465
|
+
});
|
|
58466
|
+
}
|
|
58467
|
+
return AST12.tsTypeLiteral(lists);
|
|
58468
|
+
}
|
|
58469
|
+
function queryDefinitions(config2, body, docs, returnType) {
|
|
58470
|
+
return AST12.tsTupleType(
|
|
58471
|
+
docs.reduce((prev, doc) => {
|
|
58472
|
+
if (doc.kind !== "HoudiniQuery" /* Query */ || !doc.generateStore) {
|
|
58473
|
+
return prev;
|
|
58474
|
+
}
|
|
58475
|
+
const definition = doc.document.definitions.find(
|
|
58476
|
+
(def) => def.kind === "OperationDefinition" && def.operation === "query"
|
|
58477
|
+
);
|
|
58478
|
+
if (!definition) {
|
|
58479
|
+
return prev;
|
|
58480
|
+
}
|
|
58481
|
+
const runtimeType = returnType(doc);
|
|
58482
|
+
const [shapeType, inputType] = ensureImports({
|
|
58483
|
+
config: config2,
|
|
58484
|
+
body,
|
|
58485
|
+
sourceModule: path_exports.relative(
|
|
58486
|
+
config2.runtimeDirectory,
|
|
58487
|
+
config2.artifactImportPath(doc.name)
|
|
58488
|
+
),
|
|
58489
|
+
import: [`${doc.name}$result`, `${doc.name}$input`]
|
|
58490
|
+
});
|
|
58491
|
+
return prev.concat(
|
|
58492
|
+
AST12.tsTupleType([
|
|
58493
|
+
AST12.tsTypeReference(AST12.identifier(runtimeType)),
|
|
58494
|
+
AST12.tsTypeReference(AST12.identifier(shapeType)),
|
|
58495
|
+
AST12.tsTypeReference(AST12.identifier(inputType))
|
|
58496
|
+
])
|
|
58497
|
+
);
|
|
58498
|
+
}, [])
|
|
58499
|
+
);
|
|
58500
|
+
}
|
|
58501
|
+
function fragmentListMap(config2, concreteTypes, body, docs, return_type) {
|
|
58502
|
+
return docs.reduce((prev, doc) => {
|
|
58503
|
+
if (doc.kind !== "HoudiniFragment" /* Fragment */) {
|
|
58504
|
+
return prev;
|
|
58505
|
+
}
|
|
58506
|
+
const definition = doc.document.definitions.find(
|
|
58507
|
+
(def) => def.kind === "FragmentDefinition" && def.name.value === doc.name
|
|
58508
|
+
);
|
|
58509
|
+
if (!definition || !concreteTypes.includes(definition.typeCondition.name.value)) {
|
|
58510
|
+
return prev;
|
|
58511
|
+
}
|
|
58512
|
+
const typeName = definition.typeCondition.name.value;
|
|
58513
|
+
const previousValue = prev[typeName]?.elementTypes ?? [];
|
|
58514
|
+
const tagResult = return_type(doc);
|
|
58515
|
+
const [shapeType] = ensureImports({
|
|
58516
|
+
config: config2,
|
|
58517
|
+
body,
|
|
58518
|
+
sourceModule: path_exports.relative(
|
|
58519
|
+
config2.runtimeDirectory,
|
|
58520
|
+
config2.artifactImportPath(doc.name)
|
|
58027
58521
|
),
|
|
58028
|
-
|
|
58029
|
-
|
|
58030
|
-
|
|
58031
|
-
|
|
58522
|
+
import: [`${definition.name.value}$data`]
|
|
58523
|
+
});
|
|
58524
|
+
let inputType = AST12.tsNeverKeyword();
|
|
58525
|
+
let directive = definition.directives?.find(
|
|
58526
|
+
(directive2) => directive2.name.value === config2.argumentsDirective
|
|
58527
|
+
);
|
|
58528
|
+
if (directive) {
|
|
58529
|
+
inputType = AST12.tsTypeReference(
|
|
58530
|
+
AST12.identifier(
|
|
58531
|
+
ensureImports({
|
|
58032
58532
|
config: config2,
|
|
58033
|
-
filepath,
|
|
58034
|
-
rootType: type,
|
|
58035
|
-
selections,
|
|
58036
|
-
root: true,
|
|
58037
|
-
allowReadonly: true,
|
|
58038
58533
|
body,
|
|
58039
|
-
|
|
58040
|
-
|
|
58041
|
-
|
|
58042
|
-
|
|
58534
|
+
sourceModule: path_exports.relative(
|
|
58535
|
+
config2.runtimeDirectory,
|
|
58536
|
+
config2.artifactImportPath(doc.name)
|
|
58537
|
+
),
|
|
58538
|
+
import: [`${definition.name.value}$input`]
|
|
58539
|
+
})[0]
|
|
58540
|
+
)
|
|
58541
|
+
);
|
|
58542
|
+
}
|
|
58543
|
+
return {
|
|
58544
|
+
...prev,
|
|
58545
|
+
[typeName]: AST12.tsTupleType(
|
|
58546
|
+
previousValue.concat(
|
|
58547
|
+
AST12.tsTupleType([
|
|
58548
|
+
AST12.tsTypeReference(AST12.identifier(tagResult)),
|
|
58549
|
+
AST12.tsTypeReference(AST12.identifier(shapeType)),
|
|
58550
|
+
inputType
|
|
58551
|
+
])
|
|
58043
58552
|
)
|
|
58044
58553
|
)
|
|
58045
|
-
|
|
58046
|
-
}
|
|
58554
|
+
};
|
|
58555
|
+
}, {});
|
|
58556
|
+
}
|
|
58557
|
+
var CacheTypeDefName = "CacheTypeDef";
|
|
58558
|
+
function record(name2) {
|
|
58559
|
+
return AST12.tsTypeReference(
|
|
58560
|
+
AST12.identifier("Record"),
|
|
58561
|
+
AST12.tsTypeParameterInstantiation([
|
|
58562
|
+
AST12.tsTypeReference(AST12.identifier(CacheTypeDefName)),
|
|
58563
|
+
AST12.tsLiteralType(AST12.stringLiteral(name2))
|
|
58564
|
+
])
|
|
58565
|
+
);
|
|
58566
|
+
}
|
|
58567
|
+
|
|
58568
|
+
// src/codegen/generators/typescript/index.ts
|
|
58569
|
+
async function typescriptGenerator(config2, docs) {
|
|
58570
|
+
await Promise.all([
|
|
58571
|
+
generateDocumentTypes(config2, docs),
|
|
58572
|
+
imperativeCacheTypef(config2, docs)
|
|
58573
|
+
]);
|
|
58047
58574
|
}
|
|
58048
58575
|
|
|
58049
58576
|
// src/codegen/generators/persistedQueries/index.ts
|
|
58050
|
-
var
|
|
58577
|
+
var graphql18 = __toESM(require_graphql2(), 1);
|
|
58051
58578
|
async function persistOutputGenerator(config2, docs) {
|
|
58052
58579
|
if (typeof config2.persistedQueryPath !== "string" || config2.persistedQueryPath.length === 0)
|
|
58053
58580
|
return;
|
|
@@ -58059,8 +58586,8 @@ async function persistOutputGenerator(config2, docs) {
|
|
|
58059
58586
|
if (!generateArtifact) {
|
|
58060
58587
|
return acc;
|
|
58061
58588
|
}
|
|
58062
|
-
let rawString =
|
|
58063
|
-
|
|
58589
|
+
let rawString = graphql18.print(
|
|
58590
|
+
graphql18.visit(document, {
|
|
58064
58591
|
Directive(node) {
|
|
58065
58592
|
if (config2.isInternalDirective(node)) {
|
|
58066
58593
|
return null;
|
|
@@ -58069,7 +58596,7 @@ async function persistOutputGenerator(config2, docs) {
|
|
|
58069
58596
|
})
|
|
58070
58597
|
);
|
|
58071
58598
|
const operations = document.definitions.filter(
|
|
58072
|
-
({ kind }) => kind ===
|
|
58599
|
+
({ kind }) => kind === graphql18.Kind.OPERATION_DEFINITION
|
|
58073
58600
|
);
|
|
58074
58601
|
if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
|
|
58075
58602
|
acc[hashDocument(rawString)] = rawString;
|
|
@@ -58082,11 +58609,11 @@ async function persistOutputGenerator(config2, docs) {
|
|
|
58082
58609
|
}
|
|
58083
58610
|
|
|
58084
58611
|
// src/codegen/generators/definitions/enums.ts
|
|
58085
|
-
var
|
|
58612
|
+
var graphql19 = __toESM(require_graphql2(), 1);
|
|
58086
58613
|
var recast13 = __toESM(require_main2(), 1);
|
|
58087
58614
|
var AST13 = recast13.types.builders;
|
|
58088
58615
|
async function definitionsGenerator(config2) {
|
|
58089
|
-
const enums =
|
|
58616
|
+
const enums = graphql19.parse(graphql19.printSchema(config2.schema)).definitions.filter(
|
|
58090
58617
|
(definition) => definition.kind === "EnumTypeDefinition"
|
|
58091
58618
|
).filter((def) => !config2.isInternalEnum(def));
|
|
58092
58619
|
const runtimeDefinitions = recast13.print(
|
|
@@ -58176,91 +58703,8 @@ async function writeIndexFile2(config2, docs) {
|
|
|
58176
58703
|
await fs_exports.writeFile(path_exports.join(config2.rootDir, "index.js"), body);
|
|
58177
58704
|
}
|
|
58178
58705
|
|
|
58179
|
-
// src/codegen/transforms/composeQueries.ts
|
|
58180
|
-
var import_graphql = __toESM(require_graphql2(), 1);
|
|
58181
|
-
async function includeFragmentDefinitions(config2, documents) {
|
|
58182
|
-
const fragments = collectFragments(config2, documents);
|
|
58183
|
-
for (const [index, { name: name2, document, filename }] of documents.entries()) {
|
|
58184
|
-
const operation = document.definitions.find(
|
|
58185
|
-
({ kind }) => kind === import_graphql.Kind.OPERATION_DEFINITION
|
|
58186
|
-
);
|
|
58187
|
-
if (!operation) {
|
|
58188
|
-
continue;
|
|
58189
|
-
}
|
|
58190
|
-
const allFragments = flattenFragments(
|
|
58191
|
-
filename,
|
|
58192
|
-
{ requiredFragments: findRequiredFragments(operation.selectionSet) },
|
|
58193
|
-
fragments
|
|
58194
|
-
);
|
|
58195
|
-
documents[index].document = {
|
|
58196
|
-
...document,
|
|
58197
|
-
definitions: [
|
|
58198
|
-
operation,
|
|
58199
|
-
...allFragments.map((fragmentName) => fragments[fragmentName].definition)
|
|
58200
|
-
]
|
|
58201
|
-
};
|
|
58202
|
-
}
|
|
58203
|
-
}
|
|
58204
|
-
function collectFragments(config2, docs) {
|
|
58205
|
-
return docs.reduce((acc, doc) => {
|
|
58206
|
-
const definitions = doc.document.definitions.reduce(
|
|
58207
|
-
(prev, definition) => definition.kind !== "FragmentDefinition" ? prev : {
|
|
58208
|
-
...prev,
|
|
58209
|
-
[definition.name.value]: {
|
|
58210
|
-
definition,
|
|
58211
|
-
requiredFragments: findRequiredFragments(definition.selectionSet),
|
|
58212
|
-
document: doc
|
|
58213
|
-
}
|
|
58214
|
-
},
|
|
58215
|
-
{}
|
|
58216
|
-
);
|
|
58217
|
-
return {
|
|
58218
|
-
...acc,
|
|
58219
|
-
...definitions
|
|
58220
|
-
};
|
|
58221
|
-
}, {});
|
|
58222
|
-
}
|
|
58223
|
-
function findRequiredFragments(selectionSet) {
|
|
58224
|
-
if (selectionSet.selections.length === 0) {
|
|
58225
|
-
return [];
|
|
58226
|
-
}
|
|
58227
|
-
const referencedFragments = [];
|
|
58228
|
-
for (const selection2 of selectionSet.selections) {
|
|
58229
|
-
if (selection2.kind === import_graphql.Kind.FRAGMENT_SPREAD) {
|
|
58230
|
-
referencedFragments.push(selection2.name.value);
|
|
58231
|
-
} else if (selection2.selectionSet) {
|
|
58232
|
-
referencedFragments.push(...findRequiredFragments(selection2.selectionSet));
|
|
58233
|
-
}
|
|
58234
|
-
}
|
|
58235
|
-
return referencedFragments;
|
|
58236
|
-
}
|
|
58237
|
-
function flattenFragments(filepath, operation, fragments) {
|
|
58238
|
-
const frags = /* @__PURE__ */ new Set();
|
|
58239
|
-
const remaining = [...operation.requiredFragments];
|
|
58240
|
-
while (remaining.length > 0) {
|
|
58241
|
-
const nextFragment = remaining.shift();
|
|
58242
|
-
if (!nextFragment) {
|
|
58243
|
-
continue;
|
|
58244
|
-
}
|
|
58245
|
-
if (!frags.has(nextFragment)) {
|
|
58246
|
-
frags.add(nextFragment);
|
|
58247
|
-
} else {
|
|
58248
|
-
continue;
|
|
58249
|
-
}
|
|
58250
|
-
const targetFragment = fragments[nextFragment];
|
|
58251
|
-
if (!targetFragment) {
|
|
58252
|
-
throw new HoudiniError({
|
|
58253
|
-
filepath,
|
|
58254
|
-
message: "compose: could not find definition for fragment " + nextFragment
|
|
58255
|
-
});
|
|
58256
|
-
}
|
|
58257
|
-
remaining.push(...targetFragment.requiredFragments);
|
|
58258
|
-
}
|
|
58259
|
-
return [...frags];
|
|
58260
|
-
}
|
|
58261
|
-
|
|
58262
58706
|
// src/codegen/transforms/schema.ts
|
|
58263
|
-
var
|
|
58707
|
+
var graphql20 = __toESM(require_graphql2(), 1);
|
|
58264
58708
|
async function graphqlExtensions(config2, documents) {
|
|
58265
58709
|
const internalSchema = `
|
|
58266
58710
|
enum CachePolicy {
|
|
@@ -58324,9 +58768,9 @@ directive @${config2.argumentsDirective} on FRAGMENT_DEFINITION
|
|
|
58324
58768
|
directive @${config2.cacheDirective}(${config2.cachePolicyArg}: CachePolicy, ${config2.cachePartialArg}: Boolean) on QUERY
|
|
58325
58769
|
|
|
58326
58770
|
"""
|
|
58327
|
-
@${config2.
|
|
58771
|
+
@${config2.loadDirective} is used to disable automatic fetch (no load, no auto fetch in component), you will have to do it manually.
|
|
58328
58772
|
"""
|
|
58329
|
-
directive @${config2.
|
|
58773
|
+
directive @${config2.loadDirective} on QUERY
|
|
58330
58774
|
|
|
58331
58775
|
"""
|
|
58332
58776
|
@${config2.maskEnableDirective} to enable masking on fragment (overwriting the global conf)
|
|
@@ -58338,19 +58782,19 @@ directive @${config2.maskEnableDirective} on FRAGMENT_SPREAD
|
|
|
58338
58782
|
"""
|
|
58339
58783
|
directive @${config2.maskDisableDirective} on FRAGMENT_SPREAD
|
|
58340
58784
|
`;
|
|
58341
|
-
let currentSchema =
|
|
58785
|
+
let currentSchema = graphql20.printSchema(config2.schema);
|
|
58342
58786
|
if (!currentSchema.includes(`directive @${config2.listDirective}`)) {
|
|
58343
58787
|
currentSchema += internalSchema;
|
|
58344
58788
|
}
|
|
58345
58789
|
config2.newSchema += internalSchema;
|
|
58346
|
-
config2.schema =
|
|
58790
|
+
config2.schema = graphql20.buildSchema(currentSchema);
|
|
58347
58791
|
}
|
|
58348
58792
|
|
|
58349
58793
|
// src/codegen/transforms/typename.ts
|
|
58350
|
-
var
|
|
58794
|
+
var graphql21 = __toESM(require_graphql2(), 1);
|
|
58351
58795
|
async function addTypename(config2, documents) {
|
|
58352
58796
|
for (const doc of documents) {
|
|
58353
|
-
doc.document =
|
|
58797
|
+
doc.document = graphql21.visit(doc.document, {
|
|
58354
58798
|
Field(node, key, parent, path2, ancestors) {
|
|
58355
58799
|
if (!node.selectionSet) {
|
|
58356
58800
|
return;
|
|
@@ -58362,7 +58806,7 @@ async function addTypename(config2, documents) {
|
|
|
58362
58806
|
);
|
|
58363
58807
|
const field = type.getFields()[node.name.value];
|
|
58364
58808
|
const fieldType = unwrapType(config2, field.type).type;
|
|
58365
|
-
if (
|
|
58809
|
+
if (graphql21.isInterfaceType(fieldType) || graphql21.isUnionType(fieldType)) {
|
|
58366
58810
|
return {
|
|
58367
58811
|
...node,
|
|
58368
58812
|
selectionSet: {
|
|
@@ -58370,9 +58814,9 @@ async function addTypename(config2, documents) {
|
|
|
58370
58814
|
selections: [
|
|
58371
58815
|
...node.selectionSet.selections,
|
|
58372
58816
|
{
|
|
58373
|
-
kind:
|
|
58817
|
+
kind: graphql21.Kind.FIELD,
|
|
58374
58818
|
name: {
|
|
58375
|
-
kind:
|
|
58819
|
+
kind: graphql21.Kind.NAME,
|
|
58376
58820
|
value: "__typename"
|
|
58377
58821
|
}
|
|
58378
58822
|
}
|
|
@@ -58386,10 +58830,10 @@ async function addTypename(config2, documents) {
|
|
|
58386
58830
|
}
|
|
58387
58831
|
|
|
58388
58832
|
// src/codegen/transforms/addID.ts
|
|
58389
|
-
var
|
|
58833
|
+
var graphql22 = __toESM(require_graphql2(), 1);
|
|
58390
58834
|
async function addID(config2, documents) {
|
|
58391
58835
|
for (const doc of documents) {
|
|
58392
|
-
doc.document =
|
|
58836
|
+
doc.document = graphql22.visit(doc.document, {
|
|
58393
58837
|
Field(node, key, parent, path2, ancestors) {
|
|
58394
58838
|
if (!node.selectionSet) {
|
|
58395
58839
|
return;
|
|
@@ -58402,7 +58846,7 @@ async function addID(config2, documents) {
|
|
|
58402
58846
|
const field = type.getFields()[node.name.value];
|
|
58403
58847
|
const fieldType = unwrapType(config2, field.type).type;
|
|
58404
58848
|
if (node.selectionSet?.selections.length > 0) {
|
|
58405
|
-
if (!
|
|
58849
|
+
if (!graphql22.isObjectType(fieldType) && !graphql22.isInterfaceType(fieldType)) {
|
|
58406
58850
|
return;
|
|
58407
58851
|
}
|
|
58408
58852
|
const keyFields = config2.keyFieldsForType(fieldType.name);
|
|
@@ -58417,9 +58861,9 @@ async function addID(config2, documents) {
|
|
|
58417
58861
|
continue;
|
|
58418
58862
|
}
|
|
58419
58863
|
selections.push({
|
|
58420
|
-
kind:
|
|
58864
|
+
kind: graphql22.Kind.FIELD,
|
|
58421
58865
|
name: {
|
|
58422
|
-
kind:
|
|
58866
|
+
kind: graphql22.Kind.NAME,
|
|
58423
58867
|
value: keyField
|
|
58424
58868
|
}
|
|
58425
58869
|
});
|
|
@@ -58437,266 +58881,6 @@ async function addID(config2, documents) {
|
|
|
58437
58881
|
}
|
|
58438
58882
|
}
|
|
58439
58883
|
|
|
58440
|
-
// src/codegen/transforms/fragmentVariables.ts
|
|
58441
|
-
var graphql22 = __toESM(require_graphql2(), 1);
|
|
58442
|
-
var GraphqlKinds2 = graphql22.Kind;
|
|
58443
|
-
async function fragmentVariables(config2, documents) {
|
|
58444
|
-
const fragments = collectFragments(config2, documents);
|
|
58445
|
-
const generatedFragments = {};
|
|
58446
|
-
const visitedFragments = /* @__PURE__ */ new Set();
|
|
58447
|
-
for (const doc2 of documents) {
|
|
58448
|
-
const operation = doc2.document.definitions.find(
|
|
58449
|
-
({ kind }) => kind === GraphqlKinds2.OPERATION_DEFINITION
|
|
58450
|
-
);
|
|
58451
|
-
if (!operation) {
|
|
58452
|
-
continue;
|
|
58453
|
-
}
|
|
58454
|
-
doc2.document = inlineFragmentArgs({
|
|
58455
|
-
config: config2,
|
|
58456
|
-
filepath: doc2.filename,
|
|
58457
|
-
fragmentDefinitions: fragments,
|
|
58458
|
-
document: doc2.document,
|
|
58459
|
-
generatedFragments,
|
|
58460
|
-
visitedFragments,
|
|
58461
|
-
scope: null
|
|
58462
|
-
});
|
|
58463
|
-
}
|
|
58464
|
-
const doc = {
|
|
58465
|
-
kind: graphql22.Kind.DOCUMENT,
|
|
58466
|
-
definitions: Object.values(generatedFragments)
|
|
58467
|
-
};
|
|
58468
|
-
documents.push({
|
|
58469
|
-
name: "generated::fragmentVariables",
|
|
58470
|
-
kind: "HoudiniFragment" /* Fragment */,
|
|
58471
|
-
document: doc,
|
|
58472
|
-
originalDocument: doc,
|
|
58473
|
-
generateStore: false,
|
|
58474
|
-
generateArtifact: false,
|
|
58475
|
-
filename: "generated::fragmentVariables",
|
|
58476
|
-
originalString: ""
|
|
58477
|
-
});
|
|
58478
|
-
}
|
|
58479
|
-
function inlineFragmentArgs({
|
|
58480
|
-
config: config2,
|
|
58481
|
-
filepath,
|
|
58482
|
-
fragmentDefinitions,
|
|
58483
|
-
document,
|
|
58484
|
-
generatedFragments,
|
|
58485
|
-
visitedFragments,
|
|
58486
|
-
scope,
|
|
58487
|
-
newName
|
|
58488
|
-
}) {
|
|
58489
|
-
if (!scope) {
|
|
58490
|
-
scope = operationScope(
|
|
58491
|
-
document.definitions.find(
|
|
58492
|
-
({ kind }) => kind === GraphqlKinds2.OPERATION_DEFINITION
|
|
58493
|
-
)
|
|
58494
|
-
);
|
|
58495
|
-
}
|
|
58496
|
-
const definitionArgs = fragmentArguments(
|
|
58497
|
-
config2,
|
|
58498
|
-
filepath,
|
|
58499
|
-
document
|
|
58500
|
-
).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
|
|
58501
|
-
const result = graphql22.visit(document, {
|
|
58502
|
-
FragmentSpread(node) {
|
|
58503
|
-
const { definition } = fragmentDefinitions[node.name.value];
|
|
58504
|
-
let { args, hash } = collectWithArguments(config2, filepath, node, scope);
|
|
58505
|
-
const newFragmentName = `${node.name.value}${hash}`;
|
|
58506
|
-
if (!visitedFragments.has(newFragmentName)) {
|
|
58507
|
-
visitedFragments.add(newFragmentName);
|
|
58508
|
-
const defaultArguments = collectDefaultArgumentValues(config2, filepath, definition);
|
|
58509
|
-
if (args) {
|
|
58510
|
-
for (const [field, value] of Object.entries(defaultArguments || {})) {
|
|
58511
|
-
if (!args[field]) {
|
|
58512
|
-
args[field] = value;
|
|
58513
|
-
}
|
|
58514
|
-
}
|
|
58515
|
-
generatedFragments[newFragmentName] = inlineFragmentArgs({
|
|
58516
|
-
config: config2,
|
|
58517
|
-
filepath,
|
|
58518
|
-
fragmentDefinitions,
|
|
58519
|
-
document: fragmentDefinitions[node.name.value].definition,
|
|
58520
|
-
generatedFragments,
|
|
58521
|
-
visitedFragments,
|
|
58522
|
-
scope: args,
|
|
58523
|
-
newName: newFragmentName
|
|
58524
|
-
});
|
|
58525
|
-
} else {
|
|
58526
|
-
const doc = fragmentDefinitions[node.name.value].document;
|
|
58527
|
-
const definitionIndex = doc.document.definitions.findIndex(
|
|
58528
|
-
(definition2) => definition2.kind === "FragmentDefinition" && definition2.name.value === node.name.value
|
|
58529
|
-
);
|
|
58530
|
-
const localDefinitions = [...doc.document.definitions];
|
|
58531
|
-
localDefinitions.splice(definitionIndex, 1);
|
|
58532
|
-
localDefinitions.push(
|
|
58533
|
-
inlineFragmentArgs({
|
|
58534
|
-
config: config2,
|
|
58535
|
-
filepath,
|
|
58536
|
-
fragmentDefinitions,
|
|
58537
|
-
document: fragmentDefinitions[node.name.value].definition,
|
|
58538
|
-
generatedFragments,
|
|
58539
|
-
visitedFragments,
|
|
58540
|
-
scope: defaultArguments,
|
|
58541
|
-
newName: ""
|
|
58542
|
-
})
|
|
58543
|
-
);
|
|
58544
|
-
doc.document = {
|
|
58545
|
-
...doc.document,
|
|
58546
|
-
definitions: localDefinitions
|
|
58547
|
-
};
|
|
58548
|
-
}
|
|
58549
|
-
if (node.name.value !== newFragmentName) {
|
|
58550
|
-
return {
|
|
58551
|
-
...node,
|
|
58552
|
-
name: {
|
|
58553
|
-
kind: "Name",
|
|
58554
|
-
value: newFragmentName
|
|
58555
|
-
}
|
|
58556
|
-
};
|
|
58557
|
-
}
|
|
58558
|
-
}
|
|
58559
|
-
},
|
|
58560
|
-
Argument(node) {
|
|
58561
|
-
const value = node.value;
|
|
58562
|
-
if (value.kind !== "Variable") {
|
|
58563
|
-
return;
|
|
58564
|
-
}
|
|
58565
|
-
if (!scope) {
|
|
58566
|
-
throw new HoudiniError({
|
|
58567
|
-
filepath,
|
|
58568
|
-
message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
|
|
58569
|
-
});
|
|
58570
|
-
}
|
|
58571
|
-
const newValue = scope[value.name.value];
|
|
58572
|
-
if (newValue) {
|
|
58573
|
-
return {
|
|
58574
|
-
...node,
|
|
58575
|
-
value: newValue
|
|
58576
|
-
};
|
|
58577
|
-
}
|
|
58578
|
-
if (definitionArgs[value.name.value] && definitionArgs[value.name.value].required) {
|
|
58579
|
-
throw new HoudiniError({
|
|
58580
|
-
filepath,
|
|
58581
|
-
message: "Missing value for required arg: " + value.name.value
|
|
58582
|
-
});
|
|
58583
|
-
}
|
|
58584
|
-
return null;
|
|
58585
|
-
}
|
|
58586
|
-
});
|
|
58587
|
-
if (newName) {
|
|
58588
|
-
result.name = {
|
|
58589
|
-
kind: graphql22.Kind.NAME,
|
|
58590
|
-
value: newName
|
|
58591
|
-
};
|
|
58592
|
-
}
|
|
58593
|
-
return result;
|
|
58594
|
-
}
|
|
58595
|
-
function withArguments(config2, node) {
|
|
58596
|
-
const withDirectives = node.directives?.filter(
|
|
58597
|
-
(directive) => directive.name.value === config2.withDirective
|
|
58598
|
-
);
|
|
58599
|
-
if (!withDirectives || withDirectives.length === 0) {
|
|
58600
|
-
return [];
|
|
58601
|
-
}
|
|
58602
|
-
return withDirectives.flatMap((directive) => directive.arguments || []);
|
|
58603
|
-
}
|
|
58604
|
-
function fragmentArguments(config2, filepath, definition) {
|
|
58605
|
-
const directives = definition.directives?.filter(
|
|
58606
|
-
(directive) => directive.name.value === config2.argumentsDirective
|
|
58607
|
-
);
|
|
58608
|
-
if (!directives || directives.length === 0) {
|
|
58609
|
-
return [];
|
|
58610
|
-
}
|
|
58611
|
-
return directives.flatMap(
|
|
58612
|
-
(directive) => directive.arguments?.flatMap((arg) => {
|
|
58613
|
-
if (arg.value.kind !== "ObjectValue") {
|
|
58614
|
-
throw new HoudiniError({
|
|
58615
|
-
filepath,
|
|
58616
|
-
message: "values of @argument must be objects"
|
|
58617
|
-
});
|
|
58618
|
-
}
|
|
58619
|
-
const typeArg = arg.value.fields?.find((arg2) => arg2.name.value === "type")?.value;
|
|
58620
|
-
if (!typeArg || typeArg.kind !== "StringValue") {
|
|
58621
|
-
return [];
|
|
58622
|
-
}
|
|
58623
|
-
let type = typeArg.value;
|
|
58624
|
-
let name2 = arg.name.value;
|
|
58625
|
-
let required = false;
|
|
58626
|
-
let defaultValue = arg.value.fields?.find((arg2) => arg2.name.value === "default")?.value || null;
|
|
58627
|
-
if (type[type.length - 1] === "!") {
|
|
58628
|
-
type = type.slice(0, -1);
|
|
58629
|
-
required = true;
|
|
58630
|
-
defaultValue = null;
|
|
58631
|
-
}
|
|
58632
|
-
return [
|
|
58633
|
-
{
|
|
58634
|
-
name: name2,
|
|
58635
|
-
type,
|
|
58636
|
-
required,
|
|
58637
|
-
defaultValue
|
|
58638
|
-
}
|
|
58639
|
-
];
|
|
58640
|
-
}) || []
|
|
58641
|
-
);
|
|
58642
|
-
}
|
|
58643
|
-
function collectDefaultArgumentValues(config2, filepath, definition) {
|
|
58644
|
-
let result = {};
|
|
58645
|
-
for (const { name: name2, required, defaultValue } of fragmentArguments(
|
|
58646
|
-
config2,
|
|
58647
|
-
filepath,
|
|
58648
|
-
definition
|
|
58649
|
-
)) {
|
|
58650
|
-
if (required || !defaultValue) {
|
|
58651
|
-
continue;
|
|
58652
|
-
}
|
|
58653
|
-
result[name2] = defaultValue;
|
|
58654
|
-
}
|
|
58655
|
-
return result;
|
|
58656
|
-
}
|
|
58657
|
-
function collectWithArguments(config2, filepath, node, scope = {}) {
|
|
58658
|
-
const withArgs = withArguments(config2, node);
|
|
58659
|
-
if (withArgs.length === 0) {
|
|
58660
|
-
return { args: null, hash: "" };
|
|
58661
|
-
}
|
|
58662
|
-
let args = {};
|
|
58663
|
-
for (const arg of withArgs) {
|
|
58664
|
-
let value = arg.value;
|
|
58665
|
-
if (value.kind === GraphqlKinds2.VARIABLE) {
|
|
58666
|
-
if (!scope || !scope[value.name.value]) {
|
|
58667
|
-
throw new HoudiniError({
|
|
58668
|
-
filepath,
|
|
58669
|
-
message: "Encountered undefined variable: " + value.name.value
|
|
58670
|
-
});
|
|
58671
|
-
}
|
|
58672
|
-
value = scope[value.name.value];
|
|
58673
|
-
}
|
|
58674
|
-
args[arg.name.value] = {
|
|
58675
|
-
...value,
|
|
58676
|
-
loc: void 0
|
|
58677
|
-
};
|
|
58678
|
-
}
|
|
58679
|
-
return {
|
|
58680
|
-
args,
|
|
58681
|
-
hash: "_" + murmurHash(JSON.stringify(args))
|
|
58682
|
-
};
|
|
58683
|
-
}
|
|
58684
|
-
function operationScope(operation) {
|
|
58685
|
-
return operation.variableDefinitions?.reduce(
|
|
58686
|
-
(scope, definition) => ({
|
|
58687
|
-
...scope,
|
|
58688
|
-
[definition.variable.name.value]: {
|
|
58689
|
-
kind: "Variable",
|
|
58690
|
-
name: {
|
|
58691
|
-
kind: "Name",
|
|
58692
|
-
value: definition.variable.name.value
|
|
58693
|
-
}
|
|
58694
|
-
}
|
|
58695
|
-
}),
|
|
58696
|
-
{}
|
|
58697
|
-
) || {};
|
|
58698
|
-
}
|
|
58699
|
-
|
|
58700
58884
|
// src/codegen/validators/typeCheck.ts
|
|
58701
58885
|
var graphql23 = __toESM(require_graphql2(), 1);
|
|
58702
58886
|
async function typeCheck(config2, docs) {
|
|
@@ -59876,7 +60060,6 @@ function testConfigFile({ plugins, ...config2 } = {}) {
|
|
|
59876
60060
|
}
|
|
59877
60061
|
}
|
|
59878
60062
|
},
|
|
59879
|
-
framework: "kit",
|
|
59880
60063
|
types: {
|
|
59881
60064
|
Ghost: {
|
|
59882
60065
|
keys: ["name", "aka"],
|