houdini 1.0.0-next.2 → 1.0.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/build/cmd-cjs/index.js +1380 -1190
  2. package/build/cmd-esm/index.js +1380 -1190
  3. package/build/codegen/generators/typescript/documentTypes.d.ts +2 -0
  4. package/build/codegen/generators/typescript/{imperativeCache.d.ts → imperativeTypeDef.d.ts} +1 -1
  5. package/build/codegen/transforms/fragmentVariables.d.ts +1 -0
  6. package/build/codegen-cjs/index.js +1225 -1037
  7. package/build/codegen-esm/index.js +1225 -1037
  8. package/build/lib/config.d.ts +1 -1
  9. package/build/lib/walk.d.ts +4 -1
  10. package/build/lib-cjs/index.js +10 -10
  11. package/build/lib-esm/index.js +10 -10
  12. package/build/runtime/cache/lists.d.ts +1 -0
  13. package/build/runtime/generated.d.ts +1 -0
  14. package/build/runtime/index.d.ts +1 -1
  15. package/build/runtime/lib/config.d.ts +21 -22
  16. package/build/runtime/lib/scalars.d.ts +2 -2
  17. package/build/runtime/public/cache.d.ts +19 -6
  18. package/build/runtime/public/record.d.ts +17 -17
  19. package/build/runtime/public/tests/test.d.ts +43 -0
  20. package/build/runtime/public/types.d.ts +8 -0
  21. package/build/runtime-cjs/cache/lists.d.ts +1 -0
  22. package/build/runtime-cjs/cache/lists.js +3 -0
  23. package/build/runtime-cjs/generated.d.ts +1 -0
  24. package/build/runtime-cjs/index.d.ts +1 -1
  25. package/build/runtime-cjs/lib/config.d.ts +21 -22
  26. package/build/runtime-cjs/lib/scalars.d.ts +2 -2
  27. package/build/runtime-cjs/public/cache.d.ts +19 -6
  28. package/build/runtime-cjs/public/cache.js +29 -32
  29. package/build/runtime-cjs/public/list.js +6 -28
  30. package/build/runtime-cjs/public/record.d.ts +17 -17
  31. package/build/runtime-cjs/public/record.js +22 -188
  32. package/build/runtime-cjs/public/tests/test.d.ts +43 -0
  33. package/build/runtime-cjs/public/tests/test.js +27 -2
  34. package/build/runtime-cjs/public/types.d.ts +8 -0
  35. package/build/runtime-esm/cache/lists.d.ts +1 -0
  36. package/build/runtime-esm/cache/lists.js +3 -0
  37. package/build/runtime-esm/generated.d.ts +1 -0
  38. package/build/runtime-esm/index.d.ts +1 -1
  39. package/build/runtime-esm/lib/config.d.ts +21 -22
  40. package/build/runtime-esm/lib/scalars.d.ts +2 -2
  41. package/build/runtime-esm/public/cache.d.ts +19 -6
  42. package/build/runtime-esm/public/cache.js +28 -30
  43. package/build/runtime-esm/public/list.js +6 -28
  44. package/build/runtime-esm/public/record.d.ts +17 -17
  45. package/build/runtime-esm/public/record.js +21 -184
  46. package/build/runtime-esm/public/tests/test.d.ts +43 -0
  47. package/build/runtime-esm/public/tests/test.js +26 -1
  48. package/build/runtime-esm/public/types.d.ts +8 -0
  49. package/build/test-cjs/index.js +1233 -1046
  50. package/build/test-esm/index.js +1233 -1046
  51. package/build/vite-cjs/index.js +1234 -1046
  52. package/build/vite-esm/index.js +1234 -1046
  53. package/package.json +1 -1
@@ -54349,8 +54349,7 @@ var Config = class {
54349
54349
  types: types14 = {},
54350
54350
  logLevel,
54351
54351
  defaultFragmentMasking = "enable",
54352
- schemaPollInterval = 2e3,
54353
- schemaPollHeaders = {},
54352
+ watchSchema,
54354
54353
  projectDir
54355
54354
  } = this.configFile;
54356
54355
  if (typeof schema === "string") {
@@ -54383,8 +54382,8 @@ var Config = class {
54383
54382
  this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
54384
54383
  this.defaultFragmentMasking = defaultFragmentMasking;
54385
54384
  this.routesDir = join(this.projectRoot, "src", "routes");
54386
- this.schemaPollInterval = schemaPollInterval;
54387
- this.schemaPollHeaders = schemaPollHeaders;
54385
+ this.schemaPollInterval = watchSchema?.interval ?? 2e3;
54386
+ this.schemaPollHeaders = watchSchema?.headers ?? {};
54388
54387
  this.rootDir = join(this.projectRoot, "$houdini");
54389
54388
  if (defaultKeys) {
54390
54389
  this.defaultKeys = defaultKeys;
@@ -54397,11 +54396,12 @@ var Config = class {
54397
54396
  }
54398
54397
  }
54399
54398
  async apiURL() {
54400
- if (!this.configFile.apiUrl) {
54399
+ const apiURL = this.configFile.watchSchema?.url;
54400
+ if (!apiURL) {
54401
54401
  return "";
54402
54402
  }
54403
54403
  const env = await this.getEnv();
54404
- return this.processEnvValues(env, this.configFile.apiUrl);
54404
+ return this.processEnvValues(env, apiURL);
54405
54405
  }
54406
54406
  get include() {
54407
54407
  if (this.configFile.include) {
@@ -54605,8 +54605,8 @@ var Config = class {
54605
54605
  pluginDirectory(name2) {
54606
54606
  return join(this.pluginRootDirectory, name2);
54607
54607
  }
54608
- get manualLoadDirective() {
54609
- return "manual_load";
54608
+ get loadDirective() {
54609
+ return "load";
54610
54610
  }
54611
54611
  get maskEnableDirective() {
54612
54612
  return "mask_enable";
@@ -54723,7 +54723,7 @@ var Config = class {
54723
54723
  this.withDirective,
54724
54724
  this.paginateDirective,
54725
54725
  this.cacheDirective,
54726
- this.manualLoadDirective,
54726
+ this.loadDirective,
54727
54727
  this.maskEnableDirective,
54728
54728
  this.maskDisableDirective
54729
54729
  ].includes(name2.value) || this.isDeleteDirective(name2.value);
@@ -54994,7 +54994,7 @@ async function cleanupFiles(pathFolder, listOfObj) {
54994
54994
  }
54995
54995
 
54996
54996
  // src/codegen/generators/artifacts/index.ts
54997
- var graphql11 = __toESM(require_graphql2(), 1);
54997
+ var graphql12 = __toESM(require_graphql2(), 1);
54998
54998
  var recast5 = __toESM(require_main2(), 1);
54999
54999
 
55000
55000
  // src/codegen/utils/commonjs.ts
@@ -55252,159 +55252,534 @@ function murmurHash(str) {
55252
55252
  return s;
55253
55253
  }
55254
55254
 
55255
- // src/codegen/generators/artifacts/indexFile.ts
55256
- async function writeIndexFile(config2, docs) {
55257
- const docsToGenerate = docs.filter((doc) => doc.generateArtifact).sort((a, b) => a.name.localeCompare(b.name));
55258
- let body = config2.module === "esm" ? docsToGenerate.reduce(
55259
- (content, doc) => content + `
55260
- export { default as ${doc.name}} from './${doc.name}'`,
55261
- ""
55262
- ) : docsToGenerate.reduce(
55263
- (content, doc) => content + `
55264
- ${exportDefaultFrom(`./${doc.name}`, doc.name)}`,
55265
- cjsIndexFilePreamble
55266
- );
55267
- await fs_exports.writeFile(path_exports.join(config2.artifactDirectory, "index.js"), body);
55268
- }
55269
-
55270
- // src/codegen/generators/artifacts/inputs.ts
55255
+ // src/codegen/transforms/fragmentVariables.ts
55271
55256
  var graphql3 = __toESM(require_graphql2(), 1);
55272
- var recast3 = __toESM(require_main2(), 1);
55273
- var AST3 = recast3.types.builders;
55274
- function inputObject(config2, inputs) {
55275
- const visitedTypes = /* @__PURE__ */ new Set();
55276
- const inputObj = {
55277
- fields: inputs.reduce((fields, input) => {
55278
- const { type } = unwrapType(config2, input.type);
55279
- return {
55280
- ...fields,
55281
- [input.variable.name.value]: type.name
55282
- };
55283
- }, {}),
55284
- types: {}
55285
- };
55286
- for (const input of inputs) {
55287
- walkInputs(config2, visitedTypes, inputObj, input.type);
55288
- }
55289
- return inputObj;
55290
- }
55291
- function walkInputs(config2, visitedTypes, inputObj, rootType) {
55292
- const { type } = unwrapType(config2, rootType);
55293
- if (visitedTypes.has(type.name)) {
55294
- return;
55295
- }
55296
- if (graphql3.isEnumType(type) || graphql3.isScalarType(type)) {
55297
- return;
55298
- }
55299
- if (graphql3.isUnionType(type)) {
55300
- return;
55301
- }
55302
- visitedTypes.add(type.name);
55303
- inputObj.types[type.name] = Object.values(type.getFields()).reduce(
55304
- (typeFields, field) => {
55305
- const { type: fieldType } = unwrapType(config2, field.type);
55306
- walkInputs(config2, visitedTypes, inputObj, fieldType);
55307
- return {
55308
- ...typeFields,
55309
- [field.name]: fieldType.toString()
55310
- };
55311
- },
55312
- {}
55313
- );
55314
- }
55315
55257
 
55316
- // src/codegen/generators/artifacts/operations.ts
55317
- var graphql5 = __toESM(require_graphql2(), 1);
55318
-
55319
- // src/codegen/generators/artifacts/utils.ts
55320
- var graphql4 = __toESM(require_graphql2(), 1);
55321
- var recast4 = __toESM(require_main2(), 1);
55322
- var AST4 = recast4.types.builders;
55323
- function serializeValue(value) {
55324
- if (Array.isArray(value)) {
55325
- return AST4.arrayExpression(value.map(serializeValue));
55258
+ // src/codegen/transforms/composeQueries.ts
55259
+ var import_graphql = __toESM(require_graphql2(), 1);
55260
+ async function includeFragmentDefinitions(config2, documents) {
55261
+ const fragments = collectFragments(config2, documents);
55262
+ for (const [index, { name: name2, document, filename }] of documents.entries()) {
55263
+ const operation = document.definitions.find(
55264
+ ({ kind }) => kind === import_graphql.Kind.OPERATION_DEFINITION
55265
+ );
55266
+ if (!operation) {
55267
+ continue;
55268
+ }
55269
+ const allFragments = flattenFragments(
55270
+ filename,
55271
+ { requiredFragments: findRequiredFragments(operation.selectionSet) },
55272
+ fragments
55273
+ );
55274
+ documents[index].document = {
55275
+ ...document,
55276
+ definitions: [
55277
+ operation,
55278
+ ...allFragments.map((fragmentName) => fragments[fragmentName].definition)
55279
+ ]
55280
+ };
55326
55281
  }
55327
- if (typeof value === "object" && value !== null) {
55328
- return AST4.objectExpression(
55329
- Object.entries(value).filter(([, value2]) => typeof value2 !== "undefined").map(
55330
- ([key, value2]) => AST4.objectProperty(AST4.stringLiteral(key), serializeValue(value2))
55331
- )
55282
+ }
55283
+ function collectFragments(config2, docs) {
55284
+ return docs.reduce((acc, doc) => {
55285
+ const definitions = doc.document.definitions.reduce(
55286
+ (prev, definition) => definition.kind !== "FragmentDefinition" ? prev : {
55287
+ ...prev,
55288
+ [definition.name.value]: {
55289
+ definition,
55290
+ requiredFragments: findRequiredFragments(definition.selectionSet),
55291
+ document: doc
55292
+ }
55293
+ },
55294
+ {}
55332
55295
  );
55296
+ return {
55297
+ ...acc,
55298
+ ...definitions
55299
+ };
55300
+ }, {});
55301
+ }
55302
+ function findRequiredFragments(selectionSet) {
55303
+ if (selectionSet.selections.length === 0) {
55304
+ return [];
55333
55305
  }
55334
- if (typeof value === "string") {
55335
- if (value.indexOf("\n") !== -1) {
55336
- return AST4.templateLiteral(
55337
- [AST4.templateElement({ raw: value, cooked: value }, true)],
55338
- []
55339
- );
55306
+ const referencedFragments = [];
55307
+ for (const selection2 of selectionSet.selections) {
55308
+ if (selection2.kind === import_graphql.Kind.FRAGMENT_SPREAD) {
55309
+ referencedFragments.push(selection2.name.value);
55310
+ } else if (selection2.selectionSet) {
55311
+ referencedFragments.push(...findRequiredFragments(selection2.selectionSet));
55340
55312
  }
55341
- return AST4.stringLiteral(value);
55342
55313
  }
55343
- return AST4.literal(value);
55314
+ return referencedFragments;
55344
55315
  }
55345
- function deepMerge(filepath, ...targets) {
55346
- if (typeof targets[0] !== "object") {
55347
- const matches = targets.filter((val) => val !== targets[0]).length === 0;
55348
- if (!matches) {
55349
- throw new HoudiniError({ filepath, message: "could not merge: " + targets });
55316
+ function flattenFragments(filepath, operation, fragments) {
55317
+ const frags = /* @__PURE__ */ new Set();
55318
+ const remaining = [...operation.requiredFragments];
55319
+ while (remaining.length > 0) {
55320
+ const nextFragment = remaining.shift();
55321
+ if (!nextFragment) {
55322
+ continue;
55350
55323
  }
55351
- return targets[0];
55352
- }
55353
- if (Array.isArray(targets[0])) {
55354
- return targets[0].concat(...targets.slice(1));
55355
- }
55356
- const fields = {};
55357
- for (const target of targets) {
55358
- for (const [key, value] of Object.entries(target)) {
55359
- if (!fields[key]) {
55360
- fields[key] = [];
55361
- }
55362
- fields[key].push(value);
55324
+ if (!frags.has(nextFragment)) {
55325
+ frags.add(nextFragment);
55326
+ } else {
55327
+ continue;
55328
+ }
55329
+ const targetFragment = fragments[nextFragment];
55330
+ if (!targetFragment) {
55331
+ throw new HoudiniError({
55332
+ filepath,
55333
+ message: "compose: could not find definition for fragment " + nextFragment
55334
+ });
55363
55335
  }
55336
+ remaining.push(...targetFragment.requiredFragments);
55364
55337
  }
55365
- return Object.fromEntries(
55366
- Object.entries(fields).map(([key, value]) => [key, deepMerge(filepath, ...value)])
55367
- );
55338
+ return [...frags];
55368
55339
  }
55369
- function convertValue(config2, val) {
55370
- let value;
55371
- let kind;
55372
- if (val.kind === graphql4.Kind.INT) {
55373
- value = parseInt(val.value, 10);
55374
- kind = "Int";
55375
- } else if (val.kind === graphql4.Kind.FLOAT) {
55376
- value = parseFloat(val.value);
55377
- kind = "Float";
55378
- } else if (val.kind === graphql4.Kind.BOOLEAN) {
55379
- value = val.value;
55380
- kind = "Boolean";
55381
- } else if (val.kind === graphql4.Kind.VARIABLE) {
55382
- value = val.name.value;
55383
- kind = "Variable";
55384
- } else if (val.kind === graphql4.Kind.STRING) {
55385
- value = val.value;
55386
- kind = "String";
55340
+
55341
+ // src/codegen/transforms/fragmentVariables.ts
55342
+ var GraphqlKinds2 = graphql3.Kind;
55343
+ async function fragmentVariables(config2, documents) {
55344
+ const fragments = collectFragments(config2, documents);
55345
+ const generatedFragments = {};
55346
+ const visitedFragments = /* @__PURE__ */ new Set();
55347
+ for (const doc2 of documents) {
55348
+ const operation = doc2.document.definitions.find(
55349
+ ({ kind }) => kind === GraphqlKinds2.OPERATION_DEFINITION
55350
+ );
55351
+ if (!operation) {
55352
+ continue;
55353
+ }
55354
+ doc2.document = inlineFragmentArgs({
55355
+ config: config2,
55356
+ filepath: doc2.filename,
55357
+ fragmentDefinitions: fragments,
55358
+ document: doc2.document,
55359
+ generatedFragments,
55360
+ visitedFragments,
55361
+ scope: null
55362
+ });
55387
55363
  }
55388
- return { kind, value };
55364
+ const doc = {
55365
+ kind: graphql3.Kind.DOCUMENT,
55366
+ definitions: Object.values(generatedFragments)
55367
+ };
55368
+ documents.push({
55369
+ name: "generated::fragmentVariables",
55370
+ kind: "HoudiniFragment" /* Fragment */,
55371
+ document: doc,
55372
+ originalDocument: doc,
55373
+ generateStore: false,
55374
+ generateArtifact: false,
55375
+ filename: "generated::fragmentVariables",
55376
+ originalString: ""
55377
+ });
55389
55378
  }
55390
-
55391
- // src/codegen/generators/artifacts/operations.ts
55392
- function operationsByPath(config2, filepath, definition, filterTypes) {
55393
- if (!definition) {
55394
- return {};
55379
+ function inlineFragmentArgs({
55380
+ config: config2,
55381
+ filepath,
55382
+ fragmentDefinitions,
55383
+ document,
55384
+ generatedFragments,
55385
+ visitedFragments,
55386
+ scope,
55387
+ newName
55388
+ }) {
55389
+ if (!scope) {
55390
+ scope = operationScope(
55391
+ document.definitions.find(
55392
+ ({ kind }) => kind === GraphqlKinds2.OPERATION_DEFINITION
55393
+ )
55394
+ );
55395
55395
  }
55396
- const pathOperations = {};
55397
- graphql5.visit(definition, {
55398
- FragmentSpread(node, _, __, ___, ancestors) {
55399
- if (!config2.isListFragment(node.name.value)) {
55400
- return;
55401
- }
55402
- const path2 = ancestorKey(ancestors);
55403
- if (!pathOperations[path2]) {
55404
- pathOperations[path2] = [];
55405
- }
55406
- pathOperations[path2].push(
55407
- operationObject({
55396
+ const definitionArgs = fragmentArguments(
55397
+ config2,
55398
+ filepath,
55399
+ document
55400
+ ).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
55401
+ const result = graphql3.visit(document, {
55402
+ FragmentSpread(node) {
55403
+ const { definition } = fragmentDefinitions[node.name.value];
55404
+ let { args, hash } = collectWithArguments(config2, filepath, node, scope);
55405
+ const newFragmentName = `${node.name.value}${hash}`;
55406
+ if (!visitedFragments.has(newFragmentName)) {
55407
+ visitedFragments.add(newFragmentName);
55408
+ const defaultArguments = collectDefaultArgumentValues(config2, filepath, definition);
55409
+ if (args) {
55410
+ for (const [field, value] of Object.entries(defaultArguments || {})) {
55411
+ if (!args[field]) {
55412
+ args[field] = value;
55413
+ }
55414
+ }
55415
+ generatedFragments[newFragmentName] = inlineFragmentArgs({
55416
+ config: config2,
55417
+ filepath,
55418
+ fragmentDefinitions,
55419
+ document: fragmentDefinitions[node.name.value].definition,
55420
+ generatedFragments,
55421
+ visitedFragments,
55422
+ scope: args,
55423
+ newName: newFragmentName
55424
+ });
55425
+ } else {
55426
+ const doc = fragmentDefinitions[node.name.value].document;
55427
+ const definitionIndex = doc.document.definitions.findIndex(
55428
+ (definition2) => definition2.kind === "FragmentDefinition" && definition2.name.value === node.name.value
55429
+ );
55430
+ const localDefinitions = [...doc.document.definitions];
55431
+ localDefinitions.splice(definitionIndex, 1);
55432
+ localDefinitions.push(
55433
+ inlineFragmentArgs({
55434
+ config: config2,
55435
+ filepath,
55436
+ fragmentDefinitions,
55437
+ document: fragmentDefinitions[node.name.value].definition,
55438
+ generatedFragments,
55439
+ visitedFragments,
55440
+ scope: defaultArguments,
55441
+ newName: ""
55442
+ })
55443
+ );
55444
+ doc.document = {
55445
+ ...doc.document,
55446
+ definitions: localDefinitions
55447
+ };
55448
+ }
55449
+ if (node.name.value !== newFragmentName) {
55450
+ return {
55451
+ ...node,
55452
+ name: {
55453
+ kind: "Name",
55454
+ value: newFragmentName
55455
+ }
55456
+ };
55457
+ }
55458
+ }
55459
+ },
55460
+ Argument(node) {
55461
+ const value = node.value;
55462
+ if (value.kind !== "Variable") {
55463
+ return;
55464
+ }
55465
+ if (!scope) {
55466
+ throw new HoudiniError({
55467
+ filepath,
55468
+ message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
55469
+ });
55470
+ }
55471
+ const newValue = scope[value.name.value];
55472
+ if (newValue) {
55473
+ return {
55474
+ ...node,
55475
+ value: newValue
55476
+ };
55477
+ }
55478
+ if (definitionArgs[value.name.value] && definitionArgs[value.name.value].required) {
55479
+ throw new HoudiniError({
55480
+ filepath,
55481
+ message: "Missing value for required arg: " + value.name.value
55482
+ });
55483
+ }
55484
+ return null;
55485
+ }
55486
+ });
55487
+ if (newName) {
55488
+ result.name = {
55489
+ kind: graphql3.Kind.NAME,
55490
+ value: newName
55491
+ };
55492
+ }
55493
+ return result;
55494
+ }
55495
+ function withArguments(config2, node) {
55496
+ const withDirectives = node.directives?.filter(
55497
+ (directive) => directive.name.value === config2.withDirective
55498
+ );
55499
+ if (!withDirectives || withDirectives.length === 0) {
55500
+ return [];
55501
+ }
55502
+ return withDirectives.flatMap((directive) => directive.arguments || []);
55503
+ }
55504
+ function fragmentArguments(config2, filepath, definition) {
55505
+ const directives = definition.directives?.filter(
55506
+ (directive) => directive.name.value === config2.argumentsDirective
55507
+ );
55508
+ if (!directives || directives.length === 0) {
55509
+ return [];
55510
+ }
55511
+ return directives.flatMap(
55512
+ (directive) => directive.arguments?.flatMap((arg) => {
55513
+ if (arg.value.kind !== "ObjectValue") {
55514
+ throw new HoudiniError({
55515
+ filepath,
55516
+ message: "values of @argument must be objects"
55517
+ });
55518
+ }
55519
+ const typeArg = arg.value.fields?.find((arg2) => arg2.name.value === "type")?.value;
55520
+ if (!typeArg || typeArg.kind !== "StringValue") {
55521
+ return [];
55522
+ }
55523
+ let type = typeArg.value;
55524
+ let name2 = arg.name.value;
55525
+ let required = false;
55526
+ let defaultValue = arg.value.fields?.find((arg2) => arg2.name.value === "default")?.value || null;
55527
+ if (type[type.length - 1] === "!") {
55528
+ type = type.slice(0, -1);
55529
+ required = true;
55530
+ defaultValue = null;
55531
+ }
55532
+ return [
55533
+ {
55534
+ name: name2,
55535
+ type,
55536
+ required,
55537
+ defaultValue
55538
+ }
55539
+ ];
55540
+ }) || []
55541
+ );
55542
+ }
55543
+ function collectDefaultArgumentValues(config2, filepath, definition) {
55544
+ let result = {};
55545
+ for (const { name: name2, required, defaultValue } of fragmentArguments(
55546
+ config2,
55547
+ filepath,
55548
+ definition
55549
+ )) {
55550
+ if (required || !defaultValue) {
55551
+ continue;
55552
+ }
55553
+ result[name2] = defaultValue;
55554
+ }
55555
+ return result;
55556
+ }
55557
+ function collectWithArguments(config2, filepath, node, scope = {}) {
55558
+ const withArgs = withArguments(config2, node);
55559
+ if (withArgs.length === 0) {
55560
+ return { args: null, hash: "" };
55561
+ }
55562
+ let args = {};
55563
+ for (const arg of withArgs) {
55564
+ let value = arg.value;
55565
+ if (value.kind === GraphqlKinds2.VARIABLE) {
55566
+ if (!scope || !scope[value.name.value]) {
55567
+ throw new HoudiniError({
55568
+ filepath,
55569
+ message: "Encountered undefined variable: " + value.name.value
55570
+ });
55571
+ }
55572
+ value = scope[value.name.value];
55573
+ }
55574
+ args[arg.name.value] = {
55575
+ ...value,
55576
+ loc: void 0
55577
+ };
55578
+ }
55579
+ return {
55580
+ args,
55581
+ hash: "_" + murmurHash(JSON.stringify(args))
55582
+ };
55583
+ }
55584
+ function operationScope(operation) {
55585
+ return operation.variableDefinitions?.reduce(
55586
+ (scope, definition) => ({
55587
+ ...scope,
55588
+ [definition.variable.name.value]: {
55589
+ kind: "Variable",
55590
+ name: {
55591
+ kind: "Name",
55592
+ value: definition.variable.name.value
55593
+ }
55594
+ }
55595
+ }),
55596
+ {}
55597
+ ) || {};
55598
+ }
55599
+ function fragmentArgumentsDefinitions(config2, filepath, definition) {
55600
+ const args = fragmentArguments(config2, filepath, definition);
55601
+ if (args.length === 0) {
55602
+ return [];
55603
+ }
55604
+ return args.map((arg) => {
55605
+ const innerType = {
55606
+ kind: "NamedType",
55607
+ name: {
55608
+ kind: "Name",
55609
+ value: arg.type
55610
+ }
55611
+ };
55612
+ return {
55613
+ kind: "VariableDefinition",
55614
+ type: arg.required ? innerType : {
55615
+ kind: "NonNullType",
55616
+ type: innerType
55617
+ },
55618
+ variable: {
55619
+ kind: "Variable",
55620
+ name: {
55621
+ kind: "Name",
55622
+ value: arg.name
55623
+ }
55624
+ },
55625
+ defaultValue: arg.defaultValue ?? void 0
55626
+ };
55627
+ });
55628
+ }
55629
+
55630
+ // src/codegen/generators/artifacts/indexFile.ts
55631
+ async function writeIndexFile(config2, docs) {
55632
+ const docsToGenerate = docs.filter((doc) => doc.generateArtifact).sort((a, b) => a.name.localeCompare(b.name));
55633
+ let body = config2.module === "esm" ? docsToGenerate.reduce(
55634
+ (content, doc) => content + `
55635
+ export { default as ${doc.name}} from './${doc.name}'`,
55636
+ ""
55637
+ ) : docsToGenerate.reduce(
55638
+ (content, doc) => content + `
55639
+ ${exportDefaultFrom(`./${doc.name}`, doc.name)}`,
55640
+ cjsIndexFilePreamble
55641
+ );
55642
+ await fs_exports.writeFile(path_exports.join(config2.artifactDirectory, "index.js"), body);
55643
+ }
55644
+
55645
+ // src/codegen/generators/artifacts/inputs.ts
55646
+ var graphql4 = __toESM(require_graphql2(), 1);
55647
+ var recast3 = __toESM(require_main2(), 1);
55648
+ var AST3 = recast3.types.builders;
55649
+ function inputObject(config2, inputs) {
55650
+ const visitedTypes = /* @__PURE__ */ new Set();
55651
+ const inputObj = {
55652
+ fields: inputs.reduce((fields, input) => {
55653
+ const { type } = unwrapType(config2, input.type);
55654
+ return {
55655
+ ...fields,
55656
+ [input.variable.name.value]: type.name
55657
+ };
55658
+ }, {}),
55659
+ types: {}
55660
+ };
55661
+ for (const input of inputs) {
55662
+ walkInputs(config2, visitedTypes, inputObj, input.type);
55663
+ }
55664
+ return inputObj;
55665
+ }
55666
+ function walkInputs(config2, visitedTypes, inputObj, rootType) {
55667
+ const { type } = unwrapType(config2, rootType);
55668
+ if (visitedTypes.has(type.name)) {
55669
+ return;
55670
+ }
55671
+ if (graphql4.isEnumType(type) || graphql4.isScalarType(type)) {
55672
+ return;
55673
+ }
55674
+ if (graphql4.isUnionType(type)) {
55675
+ return;
55676
+ }
55677
+ visitedTypes.add(type.name);
55678
+ inputObj.types[type.name] = Object.values(type.getFields()).reduce(
55679
+ (typeFields, field) => {
55680
+ const { type: fieldType } = unwrapType(config2, field.type);
55681
+ walkInputs(config2, visitedTypes, inputObj, fieldType);
55682
+ return {
55683
+ ...typeFields,
55684
+ [field.name]: fieldType.toString()
55685
+ };
55686
+ },
55687
+ {}
55688
+ );
55689
+ }
55690
+
55691
+ // src/codegen/generators/artifacts/operations.ts
55692
+ var graphql6 = __toESM(require_graphql2(), 1);
55693
+
55694
+ // src/codegen/generators/artifacts/utils.ts
55695
+ var graphql5 = __toESM(require_graphql2(), 1);
55696
+ var recast4 = __toESM(require_main2(), 1);
55697
+ var AST4 = recast4.types.builders;
55698
+ function serializeValue(value) {
55699
+ if (Array.isArray(value)) {
55700
+ return AST4.arrayExpression(value.map(serializeValue));
55701
+ }
55702
+ if (typeof value === "object" && value !== null) {
55703
+ return AST4.objectExpression(
55704
+ Object.entries(value).filter(([, value2]) => typeof value2 !== "undefined").map(
55705
+ ([key, value2]) => AST4.objectProperty(AST4.stringLiteral(key), serializeValue(value2))
55706
+ )
55707
+ );
55708
+ }
55709
+ if (typeof value === "string") {
55710
+ if (value.indexOf("\n") !== -1) {
55711
+ return AST4.templateLiteral(
55712
+ [AST4.templateElement({ raw: value, cooked: value }, true)],
55713
+ []
55714
+ );
55715
+ }
55716
+ return AST4.stringLiteral(value);
55717
+ }
55718
+ return AST4.literal(value);
55719
+ }
55720
+ function deepMerge(filepath, ...targets) {
55721
+ if (typeof targets[0] !== "object") {
55722
+ const matches = targets.filter((val) => val !== targets[0]).length === 0;
55723
+ if (!matches) {
55724
+ throw new HoudiniError({ filepath, message: "could not merge: " + targets });
55725
+ }
55726
+ return targets[0];
55727
+ }
55728
+ if (Array.isArray(targets[0])) {
55729
+ return targets[0].concat(...targets.slice(1));
55730
+ }
55731
+ const fields = {};
55732
+ for (const target of targets) {
55733
+ for (const [key, value] of Object.entries(target)) {
55734
+ if (!fields[key]) {
55735
+ fields[key] = [];
55736
+ }
55737
+ fields[key].push(value);
55738
+ }
55739
+ }
55740
+ return Object.fromEntries(
55741
+ Object.entries(fields).map(([key, value]) => [key, deepMerge(filepath, ...value)])
55742
+ );
55743
+ }
55744
+ function convertValue(config2, val) {
55745
+ let value;
55746
+ let kind;
55747
+ if (val.kind === graphql5.Kind.INT) {
55748
+ value = parseInt(val.value, 10);
55749
+ kind = "Int";
55750
+ } else if (val.kind === graphql5.Kind.FLOAT) {
55751
+ value = parseFloat(val.value);
55752
+ kind = "Float";
55753
+ } else if (val.kind === graphql5.Kind.BOOLEAN) {
55754
+ value = val.value;
55755
+ kind = "Boolean";
55756
+ } else if (val.kind === graphql5.Kind.VARIABLE) {
55757
+ value = val.name.value;
55758
+ kind = "Variable";
55759
+ } else if (val.kind === graphql5.Kind.STRING) {
55760
+ value = val.value;
55761
+ kind = "String";
55762
+ }
55763
+ return { kind, value };
55764
+ }
55765
+
55766
+ // src/codegen/generators/artifacts/operations.ts
55767
+ function operationsByPath(config2, filepath, definition, filterTypes) {
55768
+ if (!definition) {
55769
+ return {};
55770
+ }
55771
+ const pathOperations = {};
55772
+ graphql6.visit(definition, {
55773
+ FragmentSpread(node, _, __, ___, ancestors) {
55774
+ if (!config2.isListFragment(node.name.value)) {
55775
+ return;
55776
+ }
55777
+ const path2 = ancestorKey(ancestors);
55778
+ if (!pathOperations[path2]) {
55779
+ pathOperations[path2] = [];
55780
+ }
55781
+ pathOperations[path2].push(
55782
+ operationObject({
55408
55783
  config: config2,
55409
55784
  filepath,
55410
55785
  listName: config2.listNameFromFragment(node.name.value),
@@ -55553,7 +55928,7 @@ function ancestorKey(ancestors) {
55553
55928
  }
55554
55929
 
55555
55930
  // src/codegen/generators/artifacts/selection.ts
55556
- var graphql10 = __toESM(require_graphql2(), 1);
55931
+ var graphql11 = __toESM(require_graphql2(), 1);
55557
55932
 
55558
55933
  // ../../node_modules/.pnpm/@kitql+helper@0.5.0/node_modules/@kitql/helper/index.mjs
55559
55934
  var config = {
@@ -55593,16 +55968,16 @@ function logYellow(str) {
55593
55968
  }
55594
55969
 
55595
55970
  // src/codegen/transforms/list.ts
55596
- var graphql8 = __toESM(require_graphql2(), 1);
55971
+ var graphql9 = __toESM(require_graphql2(), 1);
55597
55972
 
55598
55973
  // src/codegen/utils/objectIdentificationSelection.ts
55599
- var graphql6 = __toESM(require_graphql2(), 1);
55974
+ var graphql7 = __toESM(require_graphql2(), 1);
55600
55975
  var objectIdentificationSelection = (config2, type) => {
55601
55976
  return config2.keyFieldsForType(type.name).map((key) => {
55602
55977
  return {
55603
- kind: graphql6.Kind.FIELD,
55978
+ kind: graphql7.Kind.FIELD,
55604
55979
  name: {
55605
- kind: graphql6.Kind.NAME,
55980
+ kind: graphql7.Kind.NAME,
55606
55981
  value: key
55607
55982
  }
55608
55983
  };
@@ -55610,7 +55985,7 @@ var objectIdentificationSelection = (config2, type) => {
55610
55985
  };
55611
55986
 
55612
55987
  // src/codegen/transforms/paginate.ts
55613
- var graphql7 = __toESM(require_graphql2(), 1);
55988
+ var graphql8 = __toESM(require_graphql2(), 1);
55614
55989
  async function paginate(config2, documents) {
55615
55990
  const newDocs = [];
55616
55991
  for (const doc of documents) {
@@ -55643,7 +56018,7 @@ async function paginate(config2, documents) {
55643
56018
  };
55644
56019
  let cursorType = "String";
55645
56020
  let paginationPath = [];
55646
- doc.document = graphql7.visit(doc.document, {
56021
+ doc.document = graphql8.visit(doc.document, {
55647
56022
  Field(node, _, __, ___, ancestors) {
55648
56023
  const paginateDirective = node.directives?.find(
55649
56024
  (directive) => directive.name.value === config2.paginateDirective
@@ -55670,7 +56045,7 @@ async function paginate(config2, documents) {
55670
56045
  flags.offset.enabled = offsetPagination;
55671
56046
  flags.limit.enabled = offsetPagination;
55672
56047
  paginationPath = ancestors.filter(
55673
- (ancestor) => !Array.isArray(ancestor) && ancestor.kind === graphql7.Kind.FIELD
56048
+ (ancestor) => !Array.isArray(ancestor) && ancestor.kind === graphql8.Kind.FIELD
55674
56049
  ).concat(node).map((field) => field.alias?.value || field.name.value);
55675
56050
  return {
55676
56051
  ...node,
@@ -55691,7 +56066,7 @@ async function paginate(config2, documents) {
55691
56066
  refetchUpdate = "prepend" /* prepend */;
55692
56067
  }
55693
56068
  let fragment = "";
55694
- doc.document = graphql7.visit(doc.document, {
56069
+ doc.document = graphql8.visit(doc.document, {
55695
56070
  OperationDefinition(node) {
55696
56071
  if (node.operation !== "query") {
55697
56072
  throw new HoudiniError({
@@ -55745,9 +56120,9 @@ async function paginate(config2, documents) {
55745
56120
  directives: [
55746
56121
  ...node.directives || [],
55747
56122
  {
55748
- kind: graphql7.Kind.DIRECTIVE,
56123
+ kind: graphql8.Kind.DIRECTIVE,
55749
56124
  name: {
55750
- kind: graphql7.Kind.NAME,
56125
+ kind: graphql8.Kind.NAME,
55751
56126
  value: config2.argumentsDirective
55752
56127
  }
55753
56128
  }
@@ -55810,16 +56185,16 @@ async function paginate(config2, documents) {
55810
56185
  const paginationArgs = Object.entries(flags).filter(([_, { enabled }]) => enabled).map(([key, value]) => ({ name: key, ...value }));
55811
56186
  const fragmentSpreadSelection = [
55812
56187
  {
55813
- kind: graphql7.Kind.FRAGMENT_SPREAD,
56188
+ kind: graphql8.Kind.FRAGMENT_SPREAD,
55814
56189
  name: {
55815
- kind: graphql7.Kind.NAME,
56190
+ kind: graphql8.Kind.NAME,
55816
56191
  value: fragmentName
55817
56192
  },
55818
56193
  directives: [
55819
56194
  {
55820
- kind: graphql7.Kind.DIRECTIVE,
56195
+ kind: graphql8.Kind.DIRECTIVE,
55821
56196
  name: {
55822
- kind: graphql7.Kind.NAME,
56197
+ kind: graphql8.Kind.NAME,
55823
56198
  value: config2.withDirective
55824
56199
  },
55825
56200
  ["arguments"]: paginationArgs.map(
@@ -55847,29 +56222,29 @@ async function paginate(config2, documents) {
55847
56222
  });
55848
56223
  const typeConfig = config2.typeConfig?.[fragment];
55849
56224
  const queryDoc = {
55850
- kind: graphql7.Kind.DOCUMENT,
56225
+ kind: graphql8.Kind.DOCUMENT,
55851
56226
  definitions: [
55852
56227
  {
55853
- kind: graphql7.Kind.OPERATION_DEFINITION,
56228
+ kind: graphql8.Kind.OPERATION_DEFINITION,
55854
56229
  name: {
55855
- kind: graphql7.Kind.NAME,
56230
+ kind: graphql8.Kind.NAME,
55856
56231
  value: refetchQueryName
55857
56232
  },
55858
56233
  operation: "query",
55859
56234
  variableDefinitions: paginationArgs.map(
55860
56235
  (arg) => ({
55861
- kind: graphql7.Kind.VARIABLE_DEFINITION,
56236
+ kind: graphql8.Kind.VARIABLE_DEFINITION,
55862
56237
  type: {
55863
- kind: graphql7.Kind.NAMED_TYPE,
56238
+ kind: graphql8.Kind.NAMED_TYPE,
55864
56239
  name: {
55865
- kind: graphql7.Kind.NAME,
56240
+ kind: graphql8.Kind.NAME,
55866
56241
  value: arg.type
55867
56242
  }
55868
56243
  },
55869
56244
  variable: {
55870
- kind: graphql7.Kind.VARIABLE,
56245
+ kind: graphql8.Kind.VARIABLE,
55871
56246
  name: {
55872
- kind: graphql7.Kind.NAME,
56247
+ kind: graphql8.Kind.NAME,
55873
56248
  value: arg.name
55874
56249
  }
55875
56250
  },
@@ -55881,12 +56256,12 @@ async function paginate(config2, documents) {
55881
56256
  ).concat(
55882
56257
  !nodeQuery ? [] : keys.map(
55883
56258
  (key) => ({
55884
- kind: graphql7.Kind.VARIABLE_DEFINITION,
56259
+ kind: graphql8.Kind.VARIABLE_DEFINITION,
55885
56260
  type: key.type,
55886
56261
  variable: {
55887
- kind: graphql7.Kind.VARIABLE,
56262
+ kind: graphql8.Kind.VARIABLE,
55888
56263
  name: {
55889
- kind: graphql7.Kind.NAME,
56264
+ kind: graphql8.Kind.NAME,
55890
56265
  value: key.name
55891
56266
  }
55892
56267
  }
@@ -55894,42 +56269,42 @@ async function paginate(config2, documents) {
55894
56269
  )
55895
56270
  ),
55896
56271
  selectionSet: {
55897
- kind: graphql7.Kind.SELECTION_SET,
56272
+ kind: graphql8.Kind.SELECTION_SET,
55898
56273
  selections: !nodeQuery ? fragmentSpreadSelection : [
55899
56274
  {
55900
- kind: graphql7.Kind.FIELD,
56275
+ kind: graphql8.Kind.FIELD,
55901
56276
  name: {
55902
- kind: graphql7.Kind.NAME,
56277
+ kind: graphql8.Kind.NAME,
55903
56278
  value: typeConfig?.resolve?.queryField || "node"
55904
56279
  },
55905
56280
  ["arguments"]: keys.map((key) => ({
55906
- kind: graphql7.Kind.ARGUMENT,
56281
+ kind: graphql8.Kind.ARGUMENT,
55907
56282
  name: {
55908
- kind: graphql7.Kind.NAME,
56283
+ kind: graphql8.Kind.NAME,
55909
56284
  value: key.name
55910
56285
  },
55911
56286
  value: {
55912
- kind: graphql7.Kind.VARIABLE,
56287
+ kind: graphql8.Kind.VARIABLE,
55913
56288
  name: {
55914
- kind: graphql7.Kind.NAME,
56289
+ kind: graphql8.Kind.NAME,
55915
56290
  value: key.name
55916
56291
  }
55917
56292
  }
55918
56293
  })),
55919
56294
  selectionSet: {
55920
- kind: graphql7.Kind.SELECTION_SET,
56295
+ kind: graphql8.Kind.SELECTION_SET,
55921
56296
  selections: [
55922
56297
  {
55923
- kind: graphql7.Kind.FIELD,
56298
+ kind: graphql8.Kind.FIELD,
55924
56299
  name: {
55925
- kind: graphql7.Kind.NAME,
56300
+ kind: graphql8.Kind.NAME,
55926
56301
  value: "__typename"
55927
56302
  }
55928
56303
  },
55929
56304
  ...(typeConfig?.keys || ["id"]).map((key) => ({
55930
- kind: graphql7.Kind.FIELD,
56305
+ kind: graphql8.Kind.FIELD,
55931
56306
  name: {
55932
- kind: graphql7.Kind.NAME,
56307
+ kind: graphql8.Kind.NAME,
55933
56308
  value: key
55934
56309
  }
55935
56310
  })),
@@ -55991,15 +56366,15 @@ function replaceArgumentsWithVariables(args, flags) {
55991
56366
  }
55992
56367
  function variableAsArgument(name2, variable) {
55993
56368
  return {
55994
- kind: graphql7.Kind.ARGUMENT,
56369
+ kind: graphql8.Kind.ARGUMENT,
55995
56370
  name: {
55996
- kind: graphql7.Kind.NAME,
56371
+ kind: graphql8.Kind.NAME,
55997
56372
  value: name2
55998
56373
  },
55999
56374
  value: {
56000
- kind: graphql7.Kind.VARIABLE,
56375
+ kind: graphql8.Kind.VARIABLE,
56001
56376
  name: {
56002
- kind: graphql7.Kind.NAME,
56377
+ kind: graphql8.Kind.NAME,
56003
56378
  value: variable ?? name2
56004
56379
  }
56005
56380
  }
@@ -56007,18 +56382,18 @@ function variableAsArgument(name2, variable) {
56007
56382
  }
56008
56383
  function staticVariableDefinition(name2, type, defaultValue, variableName) {
56009
56384
  return {
56010
- kind: graphql7.Kind.VARIABLE_DEFINITION,
56385
+ kind: graphql8.Kind.VARIABLE_DEFINITION,
56011
56386
  type: {
56012
- kind: graphql7.Kind.NAMED_TYPE,
56387
+ kind: graphql8.Kind.NAMED_TYPE,
56013
56388
  name: {
56014
- kind: graphql7.Kind.NAME,
56389
+ kind: graphql8.Kind.NAME,
56015
56390
  value: type
56016
56391
  }
56017
56392
  },
56018
56393
  variable: {
56019
- kind: graphql7.Kind.VARIABLE,
56394
+ kind: graphql8.Kind.VARIABLE,
56020
56395
  name: {
56021
- kind: graphql7.Kind.NAME,
56396
+ kind: graphql8.Kind.NAME,
56022
56397
  value: variableName ?? name2
56023
56398
  }
56024
56399
  },
@@ -56030,9 +56405,9 @@ function staticVariableDefinition(name2, type, defaultValue, variableName) {
56030
56405
  }
56031
56406
  function argumentNode(name2, value) {
56032
56407
  return {
56033
- kind: graphql7.Kind.ARGUMENT,
56408
+ kind: graphql8.Kind.ARGUMENT,
56034
56409
  name: {
56035
- kind: graphql7.Kind.NAME,
56410
+ kind: graphql8.Kind.NAME,
56036
56411
  value: name2
56037
56412
  },
56038
56413
  value: objectNode(value)
@@ -56040,16 +56415,16 @@ function argumentNode(name2, value) {
56040
56415
  }
56041
56416
  function objectNode([type, defaultValue]) {
56042
56417
  const node = {
56043
- kind: graphql7.Kind.OBJECT,
56418
+ kind: graphql8.Kind.OBJECT,
56044
56419
  fields: [
56045
56420
  {
56046
- kind: graphql7.Kind.OBJECT_FIELD,
56421
+ kind: graphql8.Kind.OBJECT_FIELD,
56047
56422
  name: {
56048
- kind: graphql7.Kind.NAME,
56423
+ kind: graphql8.Kind.NAME,
56049
56424
  value: "type"
56050
56425
  },
56051
56426
  value: {
56052
- kind: graphql7.Kind.STRING,
56427
+ kind: graphql8.Kind.STRING,
56053
56428
  value: type
56054
56429
  }
56055
56430
  }
@@ -56057,8 +56432,8 @@ function objectNode([type, defaultValue]) {
56057
56432
  };
56058
56433
  if (defaultValue) {
56059
56434
  node.fields.push({
56060
- kind: graphql7.Kind.OBJECT_FIELD,
56061
- name: { kind: graphql7.Kind.NAME, value: "default" },
56435
+ kind: graphql8.Kind.OBJECT_FIELD,
56436
+ name: { kind: graphql8.Kind.NAME, value: "default" },
56062
56437
  value: {
56063
56438
  kind: typeof defaultValue === "number" ? "IntValue" : "StringValue",
56064
56439
  value: defaultValue.toString()
@@ -56069,34 +56444,34 @@ function objectNode([type, defaultValue]) {
56069
56444
  }
56070
56445
  var pageInfoSelection = [
56071
56446
  {
56072
- kind: graphql7.Kind.FIELD,
56447
+ kind: graphql8.Kind.FIELD,
56073
56448
  name: {
56074
- kind: graphql7.Kind.NAME,
56449
+ kind: graphql8.Kind.NAME,
56075
56450
  value: "edges"
56076
56451
  },
56077
56452
  selectionSet: {
56078
- kind: graphql7.Kind.SELECTION_SET,
56453
+ kind: graphql8.Kind.SELECTION_SET,
56079
56454
  selections: [
56080
56455
  {
56081
- kind: graphql7.Kind.FIELD,
56456
+ kind: graphql8.Kind.FIELD,
56082
56457
  name: {
56083
- kind: graphql7.Kind.NAME,
56458
+ kind: graphql8.Kind.NAME,
56084
56459
  value: "cursor"
56085
56460
  }
56086
56461
  },
56087
56462
  {
56088
- kind: graphql7.Kind.FIELD,
56463
+ kind: graphql8.Kind.FIELD,
56089
56464
  name: {
56090
- kind: graphql7.Kind.NAME,
56465
+ kind: graphql8.Kind.NAME,
56091
56466
  value: "node"
56092
56467
  },
56093
56468
  selectionSet: {
56094
- kind: graphql7.Kind.SELECTION_SET,
56469
+ kind: graphql8.Kind.SELECTION_SET,
56095
56470
  selections: [
56096
56471
  {
56097
- kind: graphql7.Kind.FIELD,
56472
+ kind: graphql8.Kind.FIELD,
56098
56473
  name: {
56099
- kind: graphql7.Kind.NAME,
56474
+ kind: graphql8.Kind.NAME,
56100
56475
  value: "__typename"
56101
56476
  }
56102
56477
  }
@@ -56107,39 +56482,39 @@ var pageInfoSelection = [
56107
56482
  }
56108
56483
  },
56109
56484
  {
56110
- kind: graphql7.Kind.FIELD,
56485
+ kind: graphql8.Kind.FIELD,
56111
56486
  name: {
56112
- kind: graphql7.Kind.NAME,
56487
+ kind: graphql8.Kind.NAME,
56113
56488
  value: "pageInfo"
56114
56489
  },
56115
56490
  selectionSet: {
56116
- kind: graphql7.Kind.SELECTION_SET,
56491
+ kind: graphql8.Kind.SELECTION_SET,
56117
56492
  selections: [
56118
56493
  {
56119
- kind: graphql7.Kind.FIELD,
56494
+ kind: graphql8.Kind.FIELD,
56120
56495
  name: {
56121
- kind: graphql7.Kind.NAME,
56496
+ kind: graphql8.Kind.NAME,
56122
56497
  value: "hasPreviousPage"
56123
56498
  }
56124
56499
  },
56125
56500
  {
56126
- kind: graphql7.Kind.FIELD,
56501
+ kind: graphql8.Kind.FIELD,
56127
56502
  name: {
56128
- kind: graphql7.Kind.NAME,
56503
+ kind: graphql8.Kind.NAME,
56129
56504
  value: "hasNextPage"
56130
56505
  }
56131
56506
  },
56132
56507
  {
56133
- kind: graphql7.Kind.FIELD,
56508
+ kind: graphql8.Kind.FIELD,
56134
56509
  name: {
56135
- kind: graphql7.Kind.NAME,
56510
+ kind: graphql8.Kind.NAME,
56136
56511
  value: "startCursor"
56137
56512
  }
56138
56513
  },
56139
56514
  {
56140
- kind: graphql7.Kind.FIELD,
56515
+ kind: graphql8.Kind.FIELD,
56141
56516
  name: {
56142
- kind: graphql7.Kind.NAME,
56517
+ kind: graphql8.Kind.NAME,
56143
56518
  value: "endCursor"
56144
56519
  }
56145
56520
  }
@@ -56153,15 +56528,15 @@ async function addListFragments(config2, documents) {
56153
56528
  const lists = {};
56154
56529
  const errors = [];
56155
56530
  for (const doc of documents) {
56156
- doc.document = graphql8.visit(doc.document, {
56531
+ doc.document = graphql9.visit(doc.document, {
56157
56532
  Directive(node, key, parent, path2, ancestors) {
56158
56533
  if ([config2.listDirective, config2.paginateDirective].includes(node.name.value)) {
56159
56534
  const nameArg = node.arguments?.find((arg) => arg.name.value === "name");
56160
56535
  let error = {
56161
- ...new graphql8.GraphQLError(
56536
+ ...new graphql9.GraphQLError(
56162
56537
  "",
56163
56538
  node,
56164
- new graphql8.Source(""),
56539
+ new graphql9.Source(""),
56165
56540
  node.loc ? [node.loc.start, node.loc.end] : null,
56166
56541
  path2
56167
56542
  ),
@@ -56213,7 +56588,7 @@ async function addListFragments(config2, documents) {
56213
56588
  {
56214
56589
  kind: "Argument",
56215
56590
  name: {
56216
- kind: graphql8.Kind.NAME,
56591
+ kind: graphql9.Kind.NAME,
56217
56592
  value: "connection"
56218
56593
  },
56219
56594
  value: {
@@ -56263,7 +56638,7 @@ async function addListFragments(config2, documents) {
56263
56638
  const validDeletes = [
56264
56639
  ...new Set(
56265
56640
  Object.values(lists).map(({ type }) => {
56266
- if (!(type instanceof graphql8.GraphQLObjectType)) {
56641
+ if (!(type instanceof graphql9.GraphQLObjectType)) {
56267
56642
  return "";
56268
56643
  }
56269
56644
  if (config2.keyFieldsForType(type.name).length !== 1) {
@@ -56277,7 +56652,7 @@ async function addListFragments(config2, documents) {
56277
56652
  return;
56278
56653
  }
56279
56654
  const generatedDoc = {
56280
- kind: graphql8.Kind.DOCUMENT,
56655
+ kind: graphql9.Kind.DOCUMENT,
56281
56656
  definitions: Object.entries(lists).flatMap(
56282
56657
  ([name2, { selection: selection2, type }]) => {
56283
56658
  const schemaType = config2.schema.getType(type.name);
@@ -56285,7 +56660,7 @@ async function addListFragments(config2, documents) {
56285
56660
  throw new HoudiniError({ message: "Lists must have a selection" });
56286
56661
  }
56287
56662
  const fragmentSelection = {
56288
- kind: graphql8.Kind.SELECTION_SET,
56663
+ kind: graphql9.Kind.SELECTION_SET,
56289
56664
  selections: [...selection2.selections]
56290
56665
  };
56291
56666
  if (schemaType && fragmentSelection && !fragmentSelection?.selections.find(
@@ -56300,14 +56675,14 @@ async function addListFragments(config2, documents) {
56300
56675
  {
56301
56676
  name: {
56302
56677
  value: config2.listInsertFragment(name2),
56303
- kind: graphql8.Kind.NAME
56678
+ kind: graphql9.Kind.NAME
56304
56679
  },
56305
- kind: graphql8.Kind.FRAGMENT_DEFINITION,
56680
+ kind: graphql9.Kind.FRAGMENT_DEFINITION,
56306
56681
  selectionSet: fragmentSelection,
56307
56682
  typeCondition: {
56308
- kind: graphql8.Kind.NAMED_TYPE,
56683
+ kind: graphql9.Kind.NAMED_TYPE,
56309
56684
  name: {
56310
- kind: graphql8.Kind.NAME,
56685
+ kind: graphql9.Kind.NAME,
56311
56686
  value: type.name
56312
56687
  }
56313
56688
  }
@@ -56315,32 +56690,32 @@ async function addListFragments(config2, documents) {
56315
56690
  {
56316
56691
  name: {
56317
56692
  value: config2.listToggleFragment(name2),
56318
- kind: graphql8.Kind.NAME
56693
+ kind: graphql9.Kind.NAME
56319
56694
  },
56320
- kind: graphql8.Kind.FRAGMENT_DEFINITION,
56695
+ kind: graphql9.Kind.FRAGMENT_DEFINITION,
56321
56696
  selectionSet: fragmentSelection,
56322
56697
  typeCondition: {
56323
- kind: graphql8.Kind.NAMED_TYPE,
56698
+ kind: graphql9.Kind.NAMED_TYPE,
56324
56699
  name: {
56325
- kind: graphql8.Kind.NAME,
56700
+ kind: graphql9.Kind.NAME,
56326
56701
  value: type.name
56327
56702
  }
56328
56703
  }
56329
56704
  },
56330
56705
  {
56331
- kind: graphql8.Kind.FRAGMENT_DEFINITION,
56706
+ kind: graphql9.Kind.FRAGMENT_DEFINITION,
56332
56707
  name: {
56333
56708
  value: config2.listRemoveFragment(name2),
56334
- kind: graphql8.Kind.NAME
56709
+ kind: graphql9.Kind.NAME
56335
56710
  },
56336
56711
  selectionSet: {
56337
- kind: graphql8.Kind.SELECTION_SET,
56712
+ kind: graphql9.Kind.SELECTION_SET,
56338
56713
  selections: [...objectIdentificationSelection(config2, type)]
56339
56714
  },
56340
56715
  typeCondition: {
56341
- kind: graphql8.Kind.NAMED_TYPE,
56716
+ kind: graphql9.Kind.NAMED_TYPE,
56342
56717
  name: {
56343
- kind: graphql8.Kind.NAME,
56718
+ kind: graphql9.Kind.NAME,
56344
56719
  value: type.name
56345
56720
  }
56346
56721
  }
@@ -56349,14 +56724,14 @@ async function addListFragments(config2, documents) {
56349
56724
  }
56350
56725
  ).concat(
56351
56726
  ...validDeletes.map((typeName) => ({
56352
- kind: graphql8.Kind.DIRECTIVE_DEFINITION,
56727
+ kind: graphql9.Kind.DIRECTIVE_DEFINITION,
56353
56728
  name: {
56354
- kind: graphql8.Kind.NAME,
56729
+ kind: graphql9.Kind.NAME,
56355
56730
  value: config2.listDeleteDirective(typeName)
56356
56731
  },
56357
56732
  locations: [
56358
56733
  {
56359
- kind: graphql8.Kind.NAME,
56734
+ kind: graphql9.Kind.NAME,
56360
56735
  value: "FIELD"
56361
56736
  }
56362
56737
  ],
@@ -56364,8 +56739,8 @@ async function addListFragments(config2, documents) {
56364
56739
  }))
56365
56740
  )
56366
56741
  };
56367
- config2.newSchema += "\n" + generatedDoc.definitions.filter((c) => c.kind !== "FragmentDefinition").map(graphql8.print).join("\n\n");
56368
- config2.newDocuments += "\n" + generatedDoc.definitions.filter((c) => c.kind === "FragmentDefinition").map(graphql8.print).join("\n\n");
56742
+ config2.newSchema += "\n" + generatedDoc.definitions.filter((c) => c.kind !== "FragmentDefinition").map(graphql9.print).join("\n\n");
56743
+ config2.newDocuments += "\n" + generatedDoc.definitions.filter((c) => c.kind === "FragmentDefinition").map(graphql9.print).join("\n\n");
56369
56744
  documents.push({
56370
56745
  name: "generated::lists",
56371
56746
  kind: "HoudiniFragment" /* Fragment */,
@@ -56450,11 +56825,11 @@ var nodeNotDefinedMessage = (config2) => `Looks like you are trying to use the $
56450
56825
  For more information, visit this link: ${siteURL}/guides/pagination`;
56451
56826
 
56452
56827
  // src/codegen/generators/artifacts/fieldKey.ts
56453
- var graphql9 = __toESM(require_graphql2(), 1);
56828
+ var graphql10 = __toESM(require_graphql2(), 1);
56454
56829
  function fieldKey(config2, field) {
56455
56830
  const attributeName = field.alias?.value || field.name.value;
56456
- const printed = graphql9.print(field);
56457
- const secondParse = graphql9.parse(`{${printed}}`).definitions[0].selectionSet.selections[0];
56831
+ const printed = graphql10.print(field);
56832
+ const secondParse = graphql10.parse(`{${printed}}`).definitions[0].selectionSet.selections[0];
56458
56833
  const paginated = !!field.directives?.find(
56459
56834
  (directive) => directive.name.value === config2.paginateDirective
56460
56835
  );
@@ -56549,8 +56924,8 @@ function selection({
56549
56924
  const typeConditionName = field.typeCondition.name.value;
56550
56925
  const typeCondition = config2.schema.getType(typeConditionName);
56551
56926
  const possibleTypes = [];
56552
- if (!graphql10.isAbstractType(typeCondition)) {
56553
- } else if (graphql10.isAbstractType(parentType)) {
56927
+ if (!graphql11.isAbstractType(typeCondition)) {
56928
+ } else if (graphql11.isAbstractType(parentType)) {
56554
56929
  const possibleParentTypes = config2.schema.getPossibleTypes(parentType).map((type) => type.name);
56555
56930
  for (const possible of config2.schema.getPossibleTypes(typeCondition)) {
56556
56931
  if (possibleParentTypes.includes(possible.name)) {
@@ -56598,7 +56973,7 @@ function selection({
56598
56973
  } else {
56599
56974
  let typeRef = type.getFields()[field.name.value].type;
56600
56975
  fieldType = getRootType(typeRef);
56601
- nullable = !graphql10.isNonNullType(typeRef);
56976
+ nullable = !graphql11.isNonNullType(typeRef);
56602
56977
  }
56603
56978
  const typeName = fieldType.toString();
56604
56979
  const pathSoFar = path2.concat(attributeName);
@@ -56663,7 +57038,7 @@ function selection({
56663
57038
  {}
56664
57039
  );
56665
57040
  }
56666
- if (graphql10.isInterfaceType(fieldType) || graphql10.isUnionType(fieldType)) {
57041
+ if (graphql11.isInterfaceType(fieldType) || graphql11.isUnionType(fieldType)) {
56667
57042
  fieldObj.abstract = true;
56668
57043
  }
56669
57044
  object.fields = {
@@ -56720,7 +57095,7 @@ function artifactGenerator(stats) {
56720
57095
  return async function(config2, docs) {
56721
57096
  const filterTypes = {};
56722
57097
  for (const doc of docs) {
56723
- graphql11.visit(doc.document, {
57098
+ graphql12.visit(doc.document, {
56724
57099
  Directive(node, _, __, ___, ancestors) {
56725
57100
  if (node.name.value !== config2.listDirective) {
56726
57101
  return;
@@ -56779,7 +57154,7 @@ function artifactGenerator(stats) {
56779
57154
  return;
56780
57155
  }
56781
57156
  const usedVariableNames = /* @__PURE__ */ new Set();
56782
- let documentWithoutInternalDirectives = graphql11.visit(document, {
57157
+ let documentWithoutInternalDirectives = graphql12.visit(document, {
56783
57158
  Directive(node) {
56784
57159
  if (config2.isInternalDirective(node)) {
56785
57160
  return null;
@@ -56792,7 +57167,7 @@ function artifactGenerator(stats) {
56792
57167
  }
56793
57168
  }
56794
57169
  });
56795
- let documentWithoutExtraVariables = graphql11.visit(
57170
+ let documentWithoutExtraVariables = graphql12.visit(
56796
57171
  documentWithoutInternalDirectives,
56797
57172
  {
56798
57173
  VariableDefinition(variableDefinitionNode) {
@@ -56803,13 +57178,13 @@ function artifactGenerator(stats) {
56803
57178
  }
56804
57179
  }
56805
57180
  );
56806
- let rawString = graphql11.print(documentWithoutExtraVariables);
57181
+ let rawString = graphql12.print(documentWithoutExtraVariables);
56807
57182
  let docKind = doc.kind;
56808
57183
  const operations = document.definitions.filter(
56809
- ({ kind }) => kind === graphql11.Kind.OPERATION_DEFINITION
57184
+ ({ kind }) => kind === graphql12.Kind.OPERATION_DEFINITION
56810
57185
  );
56811
57186
  const fragments = document.definitions.filter(
56812
- ({ kind }) => kind === graphql11.Kind.FRAGMENT_DEFINITION
57187
+ ({ kind }) => kind === graphql12.Kind.FRAGMENT_DEFINITION
56813
57188
  );
56814
57189
  let rootType = "";
56815
57190
  let selectionSet;
@@ -56842,7 +57217,13 @@ function artifactGenerator(stats) {
56842
57217
  rootType = matchingFragment.typeCondition.name.value;
56843
57218
  selectionSet = matchingFragment.selectionSet;
56844
57219
  }
56845
- const inputs = operations[0]?.variableDefinitions;
57220
+ let inputs = operations[0]?.variableDefinitions;
57221
+ let directive = fragments[0]?.directives?.find(
57222
+ (directive2) => directive2.name.value === config2.argumentsDirective
57223
+ );
57224
+ if (docKind === "HoudiniFragment" /* Fragment */ && directive) {
57225
+ inputs = fragmentArgumentsDefinitions(config2, doc.filename, fragments[0]);
57226
+ }
56846
57227
  const mergedSelection = flattenSelections({
56847
57228
  config: config2,
56848
57229
  filepath: doc.filename,
@@ -56903,7 +57284,7 @@ function artifactGenerator(stats) {
56903
57284
  }
56904
57285
  if (docKind === "HoudiniQuery") {
56905
57286
  const cacheDirective = operations[0].directives?.find(
56906
- (directive) => directive.name.value === config2.cacheDirective
57287
+ (directive2) => directive2.name.value === config2.cacheDirective
56907
57288
  );
56908
57289
  if (cacheDirective) {
56909
57290
  const args = cacheDirective.arguments?.reduce(
@@ -57119,19 +57500,19 @@ async function generatePluginRuntime(config2, plugin) {
57119
57500
  );
57120
57501
  }
57121
57502
 
57122
- // src/codegen/generators/typescript/index.ts
57123
- var recast12 = __toESM(require_main2(), 1);
57503
+ // src/codegen/generators/typescript/documentTypes.ts
57504
+ var recast11 = __toESM(require_main2(), 1);
57124
57505
 
57125
57506
  // src/codegen/generators/typescript/addReferencedInputTypes.ts
57126
- var graphql14 = __toESM(require_graphql2(), 1);
57507
+ var graphql15 = __toESM(require_graphql2(), 1);
57127
57508
  var recast9 = __toESM(require_main2(), 1);
57128
57509
 
57129
57510
  // src/codegen/generators/typescript/typeReference.ts
57130
- var graphql13 = __toESM(require_graphql2(), 1);
57511
+ var graphql14 = __toESM(require_graphql2(), 1);
57131
57512
  var recast8 = __toESM(require_main2(), 1);
57132
57513
 
57133
57514
  // src/codegen/generators/typescript/types.ts
57134
- var graphql12 = __toESM(require_graphql2(), 1);
57515
+ var graphql13 = __toESM(require_graphql2(), 1);
57135
57516
  var recast7 = __toESM(require_main2(), 1);
57136
57517
  var AST7 = recast7.types.builders;
57137
57518
  function readonlyProperty(prop, enable = true) {
@@ -57162,336 +57543,89 @@ function scalarPropertyValue(config2, missingScalars, target) {
57162
57543
  return AST7.tsBooleanKeyword();
57163
57544
  }
57164
57545
  case "ID": {
57165
- return AST7.tsStringKeyword();
57166
- }
57167
- default: {
57168
- if (graphql12.isNonNullType(target) && "ofType" in target) {
57169
- return scalarPropertyValue(
57170
- config2,
57171
- missingScalars,
57172
- target.ofType
57173
- );
57174
- }
57175
- if (config2.scalars?.[target.name]) {
57176
- return AST7.tsTypeReference(AST7.identifier(config2.scalars?.[target.name].type));
57177
- }
57178
- missingScalars.add(target.name);
57179
- return AST7.tsAnyKeyword();
57180
- }
57181
- }
57182
- }
57183
-
57184
- // src/codegen/generators/typescript/typeReference.ts
57185
- var AST8 = recast8.types.builders;
57186
- function tsTypeReference(config2, missingScalars, definition) {
57187
- const { type, wrappers } = unwrapType(config2, definition.type);
57188
- let result;
57189
- if (graphql13.isScalarType(type)) {
57190
- result = scalarPropertyValue(config2, missingScalars, type);
57191
- } else {
57192
- result = AST8.tsTypeReference(AST8.identifier(type.name));
57193
- }
57194
- for (const toWrap of wrappers) {
57195
- if (toWrap === "NonNull" /* NonNull */) {
57196
- continue;
57197
- } else if (toWrap === "Nullable" /* Nullable */) {
57198
- result = nullableField(result, true);
57199
- } else if (toWrap === "List" /* List */) {
57200
- result = AST8.tsArrayType(AST8.tsParenthesizedType(result));
57201
- }
57202
- }
57203
- return result;
57204
- }
57205
-
57206
- // src/codegen/generators/typescript/addReferencedInputTypes.ts
57207
- var AST9 = recast9.types.builders;
57208
- function addReferencedInputTypes(config2, filepath, body, visitedTypes, missingScalars, rootType) {
57209
- const { type } = unwrapType(config2, rootType);
57210
- if (graphql14.isScalarType(type)) {
57211
- return;
57212
- }
57213
- if (visitedTypes.has(type.name)) {
57214
- return;
57215
- }
57216
- if (graphql14.isUnionType(type)) {
57217
- throw new HoudiniError({ filepath, message: "Input Unions are not supported yet. Sorry!" });
57218
- }
57219
- visitedTypes.add(type.name);
57220
- if (graphql14.isEnumType(type)) {
57221
- ensureImports({
57222
- config: config2,
57223
- body,
57224
- import: [type.name],
57225
- sourceModule: "$houdini/graphql/enums",
57226
- importKind: "type"
57227
- });
57228
- return;
57229
- }
57230
- const members = [];
57231
- for (const field of Object.values(type.getFields())) {
57232
- addReferencedInputTypes(config2, filepath, body, visitedTypes, missingScalars, field.type);
57233
- members.push(
57234
- AST9.tsPropertySignature(
57235
- AST9.identifier(field.name),
57236
- AST9.tsTypeAnnotation(tsTypeReference(config2, missingScalars, field)),
57237
- graphql14.isNullableType(field.type)
57238
- )
57239
- );
57240
- }
57241
- body.push(AST9.tsTypeAliasDeclaration(AST9.identifier(type.name), AST9.tsTypeLiteral(members)));
57242
- }
57243
-
57244
- // src/codegen/generators/typescript/imperativeCache.ts
57245
- var graphql15 = __toESM(require_graphql2(), 1);
57246
- var recast10 = __toESM(require_main2(), 1);
57247
- var AST10 = recast10.types.builders;
57248
- async function imperativeCacheTypef(config2, docs) {
57249
- const target = path_exports.join(config2.runtimeDirectory, "generated.d.ts");
57250
- const body = [];
57251
- const declaration = AST10.tsTypeAliasDeclaration(
57252
- AST10.identifier(CacheTypeDefName),
57253
- AST10.tsTypeLiteral([
57254
- AST10.tsPropertySignature(
57255
- AST10.identifier("types"),
57256
- AST10.tsTypeAnnotation(typeDefinitions(config2, body))
57257
- ),
57258
- AST10.tsPropertySignature(
57259
- AST10.identifier("lists"),
57260
- AST10.tsTypeAnnotation(listDefinitions(config2, docs))
57261
- )
57262
- ])
57263
- );
57264
- declaration.declare = true;
57265
- const importRecord = AST10.importDeclaration(
57266
- [AST10.importSpecifier(AST10.identifier("Record"))],
57267
- AST10.stringLiteral("./public/record")
57268
- );
57269
- importRecord.importKind = "type";
57270
- await fs_exports.writeFile(
57271
- target,
57272
- recast10.prettyPrint(
57273
- AST10.program([importRecord, ...body, AST10.exportNamedDeclaration(declaration)])
57274
- ).code
57275
- );
57276
- }
57277
- function typeDefinitions(config2, body) {
57278
- const operationTypes = [config2.schema.getMutationType(), config2.schema.getSubscriptionType()].filter(Boolean).map((type) => type?.name);
57279
- const visitedTypes = /* @__PURE__ */ new Set();
57280
- const types14 = Object.values(config2.schema.getTypeMap()).filter(
57281
- (type) => !graphql15.isAbstractType(type) && !graphql15.isScalarType(type) && !graphql15.isEnumType(type) && !graphql15.isInputObjectType(type) && !type.name.startsWith("__") && !operationTypes.includes(type.name)
57282
- );
57283
- return AST10.tsTypeLiteral(
57284
- types14.map((type) => {
57285
- let typeName = type.name;
57286
- if (config2.schema.getQueryType() && config2.schema.getQueryType()?.name === type.name) {
57287
- typeName = "__ROOT__";
57288
- }
57289
- let idFields = AST10.tsNeverKeyword();
57290
- const keys = keyFieldsForType(config2.configFile, type.name);
57291
- if (graphql15.isObjectType(type) && keys.length > 0 && keys.every((key) => type.getFields()[key])) {
57292
- idFields = AST10.tsTypeLiteral(
57293
- keys.map((key) => {
57294
- const fieldType = type.getFields()[key];
57295
- const unwrapped = unwrapType(config2, fieldType.type);
57296
- return AST10.tsPropertySignature(
57297
- AST10.identifier(key),
57298
- AST10.tsTypeAnnotation(
57299
- scalarPropertyValue(config2, /* @__PURE__ */ new Set(), unwrapped.type)
57300
- )
57301
- );
57302
- })
57303
- );
57304
- } else if (typeName === "__ROOT__") {
57305
- idFields = AST10.tsTypeLiteral([]);
57306
- }
57307
- let fields = AST10.tsTypeLiteral([]);
57308
- if (graphql15.isObjectType(type)) {
57309
- fields = AST10.tsTypeLiteral(
57310
- Object.entries(type.getFields()).map(
57311
- ([key, fieldType]) => {
57312
- const unwrapped = unwrapType(config2, fieldType.type);
57313
- let typeOptions = AST10.tsUnionType([]);
57314
- if (graphql15.isScalarType(unwrapped.type)) {
57315
- typeOptions.types.push(
57316
- scalarPropertyValue(config2, /* @__PURE__ */ new Set(), unwrapped.type)
57317
- );
57318
- } else if (graphql15.isEnumType(unwrapped.type)) {
57319
- typeOptions.types.push(
57320
- AST10.tsTypeReference(AST10.identifier(unwrapped.type.name))
57321
- );
57322
- } else if (!graphql15.isAbstractType(unwrapped.type)) {
57323
- typeOptions.types.push(record(unwrapped.type.name));
57324
- } else {
57325
- typeOptions.types.push(
57326
- ...config2.schema.getPossibleTypes(unwrapped.type).map((type2) => record(type2.name))
57327
- );
57328
- }
57329
- for (const wrapper of unwrapped.wrappers) {
57330
- if (wrapper === "Nullable" /* Nullable */) {
57331
- typeOptions = AST10.tsParenthesizedType(
57332
- AST10.tsUnionType([typeOptions, AST10.tsNullKeyword()])
57333
- );
57334
- } else if (wrapper === "List" /* List */) {
57335
- typeOptions = AST10.tsArrayType(
57336
- AST10.tsParenthesizedType(typeOptions)
57337
- );
57338
- }
57339
- }
57340
- if (typeOptions.type === "TSParenthesizedType") {
57341
- typeOptions = typeOptions.typeAnnotation;
57342
- }
57343
- let args = AST10.tsNeverKeyword();
57344
- if (fieldType.args?.length > 0) {
57345
- args = AST10.tsTypeLiteral(
57346
- fieldType.args.map((arg) => {
57347
- addReferencedInputTypes(
57348
- config2,
57349
- "",
57350
- body,
57351
- visitedTypes,
57352
- /* @__PURE__ */ new Set(),
57353
- arg.type
57354
- );
57355
- const prop = AST10.tsPropertySignature(
57356
- AST10.identifier(arg.name),
57357
- AST10.tsTypeAnnotation(
57358
- tsTypeReference(config2, /* @__PURE__ */ new Set(), arg)
57359
- )
57360
- );
57361
- const unwrapped2 = unwrapType(config2, arg.type);
57362
- prop.optional = unwrapped2.wrappers[unwrapped2.wrappers.length - 1] === "Nullable" /* Nullable */;
57363
- return prop;
57364
- })
57365
- );
57366
- }
57367
- return AST10.tsPropertySignature(
57368
- AST10.identifier(key),
57369
- AST10.tsTypeAnnotation(
57370
- AST10.tsTypeLiteral([
57371
- AST10.tsPropertySignature(
57372
- AST10.identifier("type"),
57373
- AST10.tsTypeAnnotation(typeOptions)
57374
- ),
57375
- AST10.tsPropertySignature(
57376
- AST10.identifier("args"),
57377
- AST10.tsTypeAnnotation(args)
57378
- )
57379
- ])
57380
- )
57381
- );
57382
- }
57383
- )
57546
+ return AST7.tsStringKeyword();
57547
+ }
57548
+ default: {
57549
+ if (graphql13.isNonNullType(target) && "ofType" in target) {
57550
+ return scalarPropertyValue(
57551
+ config2,
57552
+ missingScalars,
57553
+ target.ofType
57384
57554
  );
57385
57555
  }
57386
- return AST10.tsPropertySignature(
57387
- AST10.identifier(typeName),
57388
- AST10.tsTypeAnnotation(
57389
- AST10.tsTypeLiteral([
57390
- AST10.tsPropertySignature(
57391
- AST10.identifier("idFields"),
57392
- AST10.tsTypeAnnotation(idFields)
57393
- ),
57394
- AST10.tsPropertySignature(
57395
- AST10.identifier("fields"),
57396
- AST10.tsTypeAnnotation(fields)
57397
- )
57398
- ])
57399
- )
57400
- );
57401
- })
57402
- );
57403
- }
57404
- function listDefinitions(config2, docs) {
57405
- const lists = [];
57406
- const visitedLists = /* @__PURE__ */ new Set();
57407
- for (const doc of docs) {
57408
- graphql15.visit(doc.document, {
57409
- Directive(node, key, parent, path2, ancestors) {
57410
- if (![config2.listDirective, config2.paginateDirective].includes(node.name.value)) {
57411
- return;
57412
- }
57413
- const nameArg = node.arguments?.find((arg) => arg.name.value === "name");
57414
- const nameValue = nameArg?.value?.value || "";
57415
- if (!nameValue || visitedLists.has(nameValue)) {
57416
- return;
57417
- }
57418
- visitedLists.add(nameValue);
57419
- const parentType = parentTypeFromAncestors(
57420
- config2.schema,
57421
- doc.filename,
57422
- ancestors.slice(0, -1)
57423
- );
57424
- const targetField = ancestors[ancestors.length - 1];
57425
- const targetFieldDefinition = parentType.getFields()[targetField.name.value];
57426
- const { type: listType } = unwrapType(config2, targetFieldDefinition.type);
57427
- const possibleTypes = [];
57428
- if (graphql15.isAbstractType(listType)) {
57429
- possibleTypes.push(
57430
- ...config2.schema.getPossibleTypes(listType).map((possible) => possible.name)
57431
- );
57432
- } else {
57433
- possibleTypes.push(listType.name);
57434
- }
57435
- lists.push(
57436
- AST10.tsPropertySignature(
57437
- AST10.identifier(nameValue),
57438
- AST10.tsTypeAnnotation(
57439
- AST10.tsTypeLiteral([
57440
- AST10.tsPropertySignature(
57441
- AST10.identifier("types"),
57442
- AST10.tsTypeAnnotation(
57443
- AST10.tsUnionType(
57444
- possibleTypes.map(
57445
- (possible) => AST10.tsLiteralType(AST10.stringLiteral(possible))
57446
- )
57447
- )
57448
- )
57449
- ),
57450
- AST10.tsPropertySignature(
57451
- AST10.identifier("filters"),
57452
- AST10.tsTypeAnnotation(
57453
- targetFieldDefinition.args.length === 0 ? AST10.tsNeverKeyword() : AST10.tsTypeLiteral(
57454
- targetFieldDefinition.args.map((arg) => {
57455
- const argDef = AST10.tsPropertySignature(
57456
- AST10.identifier(arg.name),
57457
- AST10.tsTypeAnnotation(
57458
- tsTypeReference(
57459
- config2,
57460
- /* @__PURE__ */ new Set(),
57461
- arg
57462
- )
57463
- )
57464
- );
57465
- argDef.optional = true;
57466
- return argDef;
57467
- })
57468
- )
57469
- )
57470
- )
57471
- ])
57472
- )
57473
- )
57474
- );
57556
+ if (config2.scalars?.[target.name]) {
57557
+ return AST7.tsTypeReference(AST7.identifier(config2.scalars?.[target.name].type));
57475
57558
  }
57476
- });
57559
+ missingScalars.add(target.name);
57560
+ return AST7.tsAnyKeyword();
57561
+ }
57477
57562
  }
57478
- return AST10.tsTypeLiteral(lists);
57479
57563
  }
57480
- var CacheTypeDefName = "CacheTypeDef";
57481
- function record(name2) {
57482
- return AST10.tsTypeReference(
57483
- AST10.identifier("Record"),
57484
- AST10.tsTypeParameterInstantiation([
57485
- AST10.tsTypeReference(AST10.identifier(CacheTypeDefName)),
57486
- AST10.tsLiteralType(AST10.stringLiteral(name2))
57487
- ])
57488
- );
57564
+
57565
+ // src/codegen/generators/typescript/typeReference.ts
57566
+ var AST8 = recast8.types.builders;
57567
+ function tsTypeReference(config2, missingScalars, definition) {
57568
+ const { type, wrappers } = unwrapType(config2, definition.type);
57569
+ let result;
57570
+ if (graphql14.isScalarType(type)) {
57571
+ result = scalarPropertyValue(config2, missingScalars, type);
57572
+ } else {
57573
+ result = AST8.tsTypeReference(AST8.identifier(type.name));
57574
+ }
57575
+ for (const toWrap of wrappers) {
57576
+ if (toWrap === "NonNull" /* NonNull */) {
57577
+ continue;
57578
+ } else if (toWrap === "Nullable" /* Nullable */) {
57579
+ result = nullableField(result, true);
57580
+ } else if (toWrap === "List" /* List */) {
57581
+ result = AST8.tsArrayType(AST8.tsParenthesizedType(result));
57582
+ }
57583
+ }
57584
+ return result;
57585
+ }
57586
+
57587
+ // src/codegen/generators/typescript/addReferencedInputTypes.ts
57588
+ var AST9 = recast9.types.builders;
57589
+ function addReferencedInputTypes(config2, filepath, body, visitedTypes, missingScalars, rootType) {
57590
+ const { type } = unwrapType(config2, rootType);
57591
+ if (graphql15.isScalarType(type)) {
57592
+ return;
57593
+ }
57594
+ if (visitedTypes.has(type.name)) {
57595
+ return;
57596
+ }
57597
+ if (graphql15.isUnionType(type)) {
57598
+ throw new HoudiniError({ filepath, message: "Input Unions are not supported yet. Sorry!" });
57599
+ }
57600
+ visitedTypes.add(type.name);
57601
+ if (graphql15.isEnumType(type)) {
57602
+ ensureImports({
57603
+ config: config2,
57604
+ body,
57605
+ import: [type.name],
57606
+ sourceModule: "$houdini/graphql/enums",
57607
+ importKind: "type"
57608
+ });
57609
+ return;
57610
+ }
57611
+ const members = [];
57612
+ for (const field of Object.values(type.getFields())) {
57613
+ addReferencedInputTypes(config2, filepath, body, visitedTypes, missingScalars, field.type);
57614
+ members.push(
57615
+ AST9.tsPropertySignature(
57616
+ AST9.identifier(field.name),
57617
+ AST9.tsTypeAnnotation(tsTypeReference(config2, missingScalars, field)),
57618
+ graphql15.isNullableType(field.type)
57619
+ )
57620
+ );
57621
+ }
57622
+ body.push(AST9.tsTypeAliasDeclaration(AST9.identifier(type.name), AST9.tsTypeLiteral(members)));
57489
57623
  }
57490
57624
 
57491
57625
  // src/codegen/generators/typescript/inlineType.ts
57492
57626
  var graphql16 = __toESM(require_graphql2(), 1);
57493
- var recast11 = __toESM(require_main2(), 1);
57494
- var AST11 = recast11.types.builders;
57627
+ var recast10 = __toESM(require_main2(), 1);
57628
+ var AST10 = recast10.types.builders;
57495
57629
  var fragmentKey = "$fragments";
57496
57630
  function inlineType({
57497
57631
  config: config2,
@@ -57520,7 +57654,7 @@ function inlineType({
57520
57654
  });
57521
57655
  visitedTypes.add(type.name);
57522
57656
  }
57523
- result = AST11.tsTypeReference(AST11.identifier(type.name));
57657
+ result = AST10.tsTypeReference(AST10.identifier(type.name));
57524
57658
  } else if (selections) {
57525
57659
  const rootObj = type;
57526
57660
  const inlineFragments = {};
@@ -57571,7 +57705,7 @@ function inlineType({
57571
57705
  selectedFields.push(selection2);
57572
57706
  }
57573
57707
  }
57574
- result = AST11.tsTypeLiteral([
57708
+ result = AST10.tsTypeLiteral([
57575
57709
  ...(selectedFields || []).filter(
57576
57710
  (field) => field.kind === "Field"
57577
57711
  ).map((selection2) => {
@@ -57591,9 +57725,9 @@ function inlineType({
57591
57725
  allOptional
57592
57726
  });
57593
57727
  const prop = readonlyProperty(
57594
- AST11.tsPropertySignature(
57595
- AST11.identifier(attributeName),
57596
- AST11.tsTypeAnnotation(attributeType)
57728
+ AST10.tsPropertySignature(
57729
+ AST10.identifier(attributeName),
57730
+ AST10.tsTypeAnnotation(attributeType)
57597
57731
  ),
57598
57732
  allowReadonly
57599
57733
  );
@@ -57607,15 +57741,15 @@ function inlineType({
57607
57741
  if (includeFragments && fragmentSpreads && fragmentSpreads.length) {
57608
57742
  result.members.push(
57609
57743
  readonlyProperty(
57610
- AST11.tsPropertySignature(
57611
- AST11.identifier(fragmentKey),
57612
- AST11.tsTypeAnnotation(
57613
- AST11.tsTypeLiteral(
57744
+ AST10.tsPropertySignature(
57745
+ AST10.identifier(fragmentKey),
57746
+ AST10.tsTypeAnnotation(
57747
+ AST10.tsTypeLiteral(
57614
57748
  (fragmentSpreads || []).map(
57615
- (fragmentSpread) => AST11.tsPropertySignature(
57616
- AST11.identifier(fragmentSpread.name.value),
57617
- AST11.tsTypeAnnotation(
57618
- AST11.tsLiteralType(AST11.booleanLiteral(true))
57749
+ (fragmentSpread) => AST10.tsPropertySignature(
57750
+ AST10.identifier(fragmentSpread.name.value),
57751
+ AST10.tsTypeAnnotation(
57752
+ AST10.tsLiteralType(AST10.booleanLiteral(true))
57619
57753
  )
57620
57754
  )
57621
57755
  )
@@ -57661,9 +57795,9 @@ function inlineType({
57661
57795
  }
57662
57796
  objectType.members.push(
57663
57797
  readonlyProperty(
57664
- AST11.tsPropertySignature(
57665
- AST11.identifier("__typename"),
57666
- AST11.tsTypeAnnotation(AST11.tsLiteralType(AST11.stringLiteral(typeName)))
57798
+ AST10.tsPropertySignature(
57799
+ AST10.identifier("__typename"),
57800
+ AST10.tsTypeAnnotation(AST10.tsLiteralType(AST10.stringLiteral(typeName)))
57667
57801
  ),
57668
57802
  allowReadonly
57669
57803
  )
@@ -57674,8 +57808,8 @@ function inlineType({
57674
57808
  if (Object.keys(inlineFragmentSelections).length > 0) {
57675
57809
  let selectionTypes = Object.entries(inlineFragmentSelections).map(
57676
57810
  ([typeName, { type: type2, tsType }]) => {
57677
- return AST11.tsParenthesizedType(
57678
- AST11.tsIntersectionType(
57811
+ return AST10.tsParenthesizedType(
57812
+ AST10.tsIntersectionType(
57679
57813
  [tsType].flatMap((type3) => {
57680
57814
  if (type3.type === "TSUnionType") {
57681
57815
  return type3.types.filter(
@@ -57688,9 +57822,9 @@ function inlineType({
57688
57822
  );
57689
57823
  }
57690
57824
  );
57691
- result = AST11.tsIntersectionType([
57825
+ result = AST10.tsIntersectionType([
57692
57826
  result,
57693
- AST11.tsParenthesizedType(AST11.tsUnionType(selectionTypes))
57827
+ AST10.tsParenthesizedType(AST10.tsUnionType(selectionTypes))
57694
57828
  ]);
57695
57829
  }
57696
57830
  } else {
@@ -57702,7 +57836,7 @@ function inlineType({
57702
57836
  } else if (toWrap === "NonNull" /* NonNull */) {
57703
57837
  continue;
57704
57838
  } else if (toWrap === "List" /* List */) {
57705
- result = AST11.tsArrayType(AST11.tsParenthesizedType(result));
57839
+ result = AST10.tsArrayType(AST10.tsParenthesizedType(result));
57706
57840
  }
57707
57841
  }
57708
57842
  return result;
@@ -57746,9 +57880,9 @@ function selectionTypeInfo(schema, filepath, rootType, selection2) {
57746
57880
  return { field, type: selectionType };
57747
57881
  }
57748
57882
 
57749
- // src/codegen/generators/typescript/index.ts
57750
- var AST12 = recast12.types.builders;
57751
- async function typescriptGenerator(config2, docs) {
57883
+ // src/codegen/generators/typescript/documentTypes.ts
57884
+ var AST11 = recast11.types.builders;
57885
+ async function generateDocumentTypes(config2, docs) {
57752
57886
  const typePaths = [];
57753
57887
  const fragmentDefinitions = {};
57754
57888
  for (const document of docs) {
@@ -57765,7 +57899,7 @@ async function typescriptGenerator(config2, docs) {
57765
57899
  return;
57766
57900
  }
57767
57901
  const typeDefPath = config2.artifactTypePath(originalDocument);
57768
- const program = AST12.program([]);
57902
+ const program = AST11.program([]);
57769
57903
  const visitedTypes = /* @__PURE__ */ new Set();
57770
57904
  let definition = originalDocument.definitions.find(
57771
57905
  (def) => (def.kind === "OperationDefinition" || def.kind === "FragmentDefinition") && def.name?.value === name2
@@ -57798,21 +57932,21 @@ async function typescriptGenerator(config2, docs) {
57798
57932
  missingScalars
57799
57933
  );
57800
57934
  }
57801
- await fs_exports.writeFile(typeDefPath, recast12.print(program).code);
57935
+ await fs_exports.writeFile(typeDefPath, recast11.print(program).code);
57802
57936
  typePaths.push(typeDefPath);
57803
57937
  })
57804
57938
  );
57805
- const typeIndex = AST12.program(
57939
+ const typeIndex = AST11.program(
57806
57940
  typePaths.sort((a, b) => a.localeCompare(b)).map((typePath) => {
57807
- return AST12.exportAllDeclaration(
57808
- AST12.literal(
57941
+ return AST11.exportAllDeclaration(
57942
+ AST11.literal(
57809
57943
  "./" + path_exports.relative(path_exports.resolve(config2.typeIndexPath, ".."), typePath).replace(/\.[^/.]+\.[^/.]+$/, "")
57810
57944
  ),
57811
57945
  null
57812
57946
  );
57813
57947
  }).concat([
57814
- AST12.exportAllDeclaration(AST12.literal("./runtime"), null),
57815
- AST12.exportAllDeclaration(AST12.literal("./graphql"), null)
57948
+ AST11.exportAllDeclaration(AST11.literal("./runtime"), null),
57949
+ AST11.exportAllDeclaration(AST11.literal("./graphql"), null)
57816
57950
  ])
57817
57951
  );
57818
57952
  const export_default_as = ({ module: module2, as }) => `
@@ -57821,7 +57955,7 @@ export { default as ${as} } from "${module2}"
57821
57955
  const export_star_from = ({ module: module2 }) => `
57822
57956
  export * from "${module2}"
57823
57957
  `;
57824
- let indexContent = recast12.print(typeIndex).code;
57958
+ let indexContent = recast11.print(typeIndex).code;
57825
57959
  for (const plugin of config2.plugins) {
57826
57960
  if (!plugin.index_file) {
57827
57961
  continue;
@@ -57842,7 +57976,6 @@ export * from "${module2}"
57842
57976
  }
57843
57977
  }
57844
57978
  await fs_exports.writeFile(config2.typeIndexPath, indexContent);
57845
- await imperativeCacheTypef(config2, docs);
57846
57979
  if (missingScalars.size > 0) {
57847
57980
  console.warn(`\u26A0\uFE0F Missing definitions for the following scalars: ${[...missingScalars].join(
57848
57981
  ", "
@@ -57884,23 +58017,23 @@ async function generateOperationTypeDefs(config2, filepath, body, definition, se
57884
58017
  const optimisticTypeName = `${definition.name.value}$optimistic`;
57885
58018
  const hasInputs = definition.variableDefinitions && definition.variableDefinitions.length > 0;
57886
58019
  body.push(
57887
- AST12.exportNamedDeclaration(
57888
- AST12.tsTypeAliasDeclaration(
57889
- AST12.identifier(definition.name.value),
57890
- AST12.tsTypeLiteral([
58020
+ AST11.exportNamedDeclaration(
58021
+ AST11.tsTypeAliasDeclaration(
58022
+ AST11.identifier(definition.name.value),
58023
+ AST11.tsTypeLiteral([
57891
58024
  readonlyProperty(
57892
- AST12.tsPropertySignature(
57893
- AST12.stringLiteral("input"),
57894
- AST12.tsTypeAnnotation(AST12.tsTypeReference(AST12.identifier(inputTypeName)))
58025
+ AST11.tsPropertySignature(
58026
+ AST11.stringLiteral("input"),
58027
+ AST11.tsTypeAnnotation(AST11.tsTypeReference(AST11.identifier(inputTypeName)))
57895
58028
  )
57896
58029
  ),
57897
58030
  readonlyProperty(
57898
- AST12.tsPropertySignature(
57899
- AST12.stringLiteral("result"),
57900
- AST12.tsTypeAnnotation(
57901
- definition.operation === "mutation" ? AST12.tsTypeReference(AST12.identifier(shapeTypeName)) : AST12.tsUnionType([
57902
- AST12.tsTypeReference(AST12.identifier(shapeTypeName)),
57903
- AST12.tsUndefinedKeyword()
58031
+ AST11.tsPropertySignature(
58032
+ AST11.stringLiteral("result"),
58033
+ AST11.tsTypeAnnotation(
58034
+ definition.operation === "mutation" ? AST11.tsTypeReference(AST11.identifier(shapeTypeName)) : AST11.tsUnionType([
58035
+ AST11.tsTypeReference(AST11.identifier(shapeTypeName)),
58036
+ AST11.tsUndefinedKeyword()
57904
58037
  ])
57905
58038
  )
57906
58039
  )
@@ -57908,9 +58041,9 @@ async function generateOperationTypeDefs(config2, filepath, body, definition, se
57908
58041
  ])
57909
58042
  )
57910
58043
  ),
57911
- AST12.exportNamedDeclaration(
57912
- AST12.tsTypeAliasDeclaration(
57913
- AST12.identifier(shapeTypeName),
58044
+ AST11.exportNamedDeclaration(
58045
+ AST11.tsTypeAliasDeclaration(
58046
+ AST11.identifier(shapeTypeName),
57914
58047
  inlineType({
57915
58048
  config: config2,
57916
58049
  filepath,
@@ -57938,15 +58071,15 @@ async function generateOperationTypeDefs(config2, filepath, body, definition, se
57938
58071
  );
57939
58072
  }
57940
58073
  body.push(
57941
- AST12.exportNamedDeclaration(
57942
- AST12.tsTypeAliasDeclaration(
57943
- AST12.identifier(inputTypeName),
57944
- AST12.tsTypeLiteral(
58074
+ AST11.exportNamedDeclaration(
58075
+ AST11.tsTypeAliasDeclaration(
58076
+ AST11.identifier(inputTypeName),
58077
+ AST11.tsTypeLiteral(
57945
58078
  (definition.variableDefinitions || []).map(
57946
58079
  (definition2) => {
57947
- return AST12.tsPropertySignature(
57948
- AST12.identifier(definition2.variable.name.value),
57949
- AST12.tsTypeAnnotation(
58080
+ return AST11.tsPropertySignature(
58081
+ AST11.identifier(definition2.variable.name.value),
58082
+ AST11.tsTypeAnnotation(
57950
58083
  tsTypeReference(config2, missingScalars, definition2)
57951
58084
  ),
57952
58085
  definition2.type.kind !== "NonNullType"
@@ -57959,16 +58092,16 @@ async function generateOperationTypeDefs(config2, filepath, body, definition, se
57959
58092
  );
57960
58093
  } else {
57961
58094
  body.push(
57962
- AST12.exportNamedDeclaration(
57963
- AST12.tsTypeAliasDeclaration(AST12.identifier(inputTypeName), AST12.tsNullKeyword())
58095
+ AST11.exportNamedDeclaration(
58096
+ AST11.tsTypeAliasDeclaration(AST11.identifier(inputTypeName), AST11.tsNullKeyword())
57964
58097
  )
57965
58098
  );
57966
58099
  }
57967
58100
  if (definition.operation === "mutation") {
57968
58101
  body.push(
57969
- AST12.exportNamedDeclaration(
57970
- AST12.tsTypeAliasDeclaration(
57971
- AST12.identifier(optimisticTypeName),
58102
+ AST11.exportNamedDeclaration(
58103
+ AST11.tsTypeAliasDeclaration(
58104
+ AST11.identifier(optimisticTypeName),
57972
58105
  inlineType({
57973
58106
  config: config2,
57974
58107
  filepath,
@@ -57994,65 +58127,463 @@ async function generateFragmentTypeDefs(config2, filepath, body, selections, def
57994
58127
  }
57995
58128
  const propTypeName = definition.name.value;
57996
58129
  const shapeTypeName = `${definition.name.value}$data`;
58130
+ const inputTypeName = `${definition.name.value}$input`;
57997
58131
  const type = config2.schema.getType(definition.typeCondition.name.value);
57998
58132
  if (!type) {
57999
58133
  throw new Error("Should not get here");
58000
58134
  }
58135
+ let extraExports = [];
58136
+ let directive = definition.directives?.find(
58137
+ (directive2) => directive2.name.value === config2.argumentsDirective
58138
+ );
58139
+ if (directive) {
58140
+ extraExports.push(
58141
+ AST11.exportNamedDeclaration(
58142
+ AST11.tsTypeAliasDeclaration(
58143
+ AST11.identifier(inputTypeName),
58144
+ AST11.tsTypeLiteral(
58145
+ (fragmentArgumentsDefinitions(config2, filepath, definition) || []).map(
58146
+ (definition2) => {
58147
+ return AST11.tsPropertySignature(
58148
+ AST11.identifier(definition2.variable.name.value),
58149
+ AST11.tsTypeAnnotation(
58150
+ tsTypeReference(config2, missingScalars, definition2)
58151
+ ),
58152
+ definition2.type.kind !== "NonNullType"
58153
+ );
58154
+ }
58155
+ )
58156
+ )
58157
+ )
58158
+ )
58159
+ );
58160
+ }
58001
58161
  body.push(
58002
- AST12.exportNamedDeclaration(
58003
- AST12.tsTypeAliasDeclaration(
58004
- AST12.identifier(propTypeName),
58005
- AST12.tsTypeLiteral([
58162
+ ...extraExports,
58163
+ AST11.exportNamedDeclaration(
58164
+ AST11.tsTypeAliasDeclaration(
58165
+ AST11.identifier(propTypeName),
58166
+ AST11.tsTypeLiteral([
58006
58167
  readonlyProperty(
58007
- AST12.tsPropertySignature(
58008
- AST12.stringLiteral("shape"),
58009
- AST12.tsTypeAnnotation(
58010
- AST12.tsTypeReference(AST12.identifier(shapeTypeName))
58168
+ AST11.tsPropertySignature(
58169
+ AST11.stringLiteral("shape"),
58170
+ AST11.tsTypeAnnotation(
58171
+ AST11.tsTypeReference(AST11.identifier(shapeTypeName))
58011
58172
  ),
58012
58173
  true
58013
58174
  )
58014
58175
  ),
58015
58176
  readonlyProperty(
58016
- AST12.tsPropertySignature(
58017
- AST12.stringLiteral(fragmentKey),
58177
+ AST11.tsPropertySignature(
58178
+ AST11.stringLiteral(fragmentKey),
58179
+ AST11.tsTypeAnnotation(
58180
+ AST11.tsTypeLiteral([
58181
+ AST11.tsPropertySignature(
58182
+ AST11.stringLiteral(propTypeName),
58183
+ AST11.tsTypeAnnotation(
58184
+ AST11.tsLiteralType(AST11.booleanLiteral(true))
58185
+ )
58186
+ )
58187
+ ])
58188
+ )
58189
+ )
58190
+ )
58191
+ ])
58192
+ )
58193
+ ),
58194
+ AST11.exportNamedDeclaration(
58195
+ AST11.tsTypeAliasDeclaration(
58196
+ AST11.identifier(shapeTypeName),
58197
+ inlineType({
58198
+ config: config2,
58199
+ filepath,
58200
+ rootType: type,
58201
+ selections,
58202
+ root: true,
58203
+ allowReadonly: true,
58204
+ body,
58205
+ visitedTypes,
58206
+ missingScalars,
58207
+ includeFragments: true
58208
+ })
58209
+ )
58210
+ )
58211
+ );
58212
+ }
58213
+ }
58214
+
58215
+ // src/codegen/generators/typescript/imperativeTypeDef.ts
58216
+ var graphql17 = __toESM(require_graphql2(), 1);
58217
+ var recast12 = __toESM(require_main2(), 1);
58218
+ var AST12 = recast12.types.builders;
58219
+ async function imperativeCacheTypef(config2, docs) {
58220
+ const returnType = (doc) => config2.plugins.find((plugin) => plugin.graphql_tag_return)?.graphql_tag_return?.({
58221
+ config: config2,
58222
+ doc,
58223
+ ensure_import({ identifier, module: module2 }) {
58224
+ ensureImports({
58225
+ config: config2,
58226
+ body,
58227
+ sourceModule: module2,
58228
+ import: [identifier]
58229
+ });
58230
+ }
58231
+ }) ?? "any";
58232
+ const target = path_exports.join(config2.runtimeDirectory, "generated.d.ts");
58233
+ const body = [];
58234
+ const declaration = AST12.tsTypeAliasDeclaration(
58235
+ AST12.identifier(CacheTypeDefName),
58236
+ AST12.tsTypeLiteral([
58237
+ AST12.tsPropertySignature(
58238
+ AST12.identifier("types"),
58239
+ AST12.tsTypeAnnotation(typeDefinitions(config2, body, docs, returnType))
58240
+ ),
58241
+ AST12.tsPropertySignature(
58242
+ AST12.identifier("lists"),
58243
+ AST12.tsTypeAnnotation(listDefinitions(config2, docs))
58244
+ ),
58245
+ AST12.tsPropertySignature(
58246
+ AST12.identifier("queries"),
58247
+ AST12.tsTypeAnnotation(queryDefinitions(config2, body, docs, returnType))
58248
+ )
58249
+ ])
58250
+ );
58251
+ declaration.declare = true;
58252
+ const importRecord = AST12.importDeclaration(
58253
+ [AST12.importSpecifier(AST12.identifier("Record"))],
58254
+ AST12.stringLiteral("./public/record")
58255
+ );
58256
+ importRecord.importKind = "type";
58257
+ await fs_exports.writeFile(
58258
+ target,
58259
+ recast12.prettyPrint(
58260
+ AST12.program([importRecord, ...body, AST12.exportNamedDeclaration(declaration)])
58261
+ ).code
58262
+ );
58263
+ }
58264
+ function typeDefinitions(config2, body, docs, returnType) {
58265
+ const operationTypes = [config2.schema.getMutationType(), config2.schema.getSubscriptionType()].filter(Boolean).map((type) => type?.name);
58266
+ const visitedTypes = /* @__PURE__ */ new Set();
58267
+ const types14 = Object.values(config2.schema.getTypeMap()).filter(
58268
+ (type) => !graphql17.isAbstractType(type) && !graphql17.isScalarType(type) && !graphql17.isEnumType(type) && !graphql17.isInputObjectType(type) && !type.name.startsWith("__") && !operationTypes.includes(type.name)
58269
+ );
58270
+ const fragmentMap = fragmentListMap(
58271
+ config2,
58272
+ types14.map((type) => type.name),
58273
+ body,
58274
+ docs,
58275
+ returnType
58276
+ );
58277
+ return AST12.tsTypeLiteral(
58278
+ types14.map((type) => {
58279
+ let typeName = type.name;
58280
+ if (config2.schema.getQueryType() && config2.schema.getQueryType()?.name === type.name) {
58281
+ typeName = "__ROOT__";
58282
+ }
58283
+ let idFields = AST12.tsNeverKeyword();
58284
+ const keys = keyFieldsForType(config2.configFile, type.name);
58285
+ if (graphql17.isObjectType(type) && keys.length > 0 && keys.every((key) => type.getFields()[key])) {
58286
+ idFields = AST12.tsTypeLiteral(
58287
+ keys.map((key) => {
58288
+ const fieldType = type.getFields()[key];
58289
+ const unwrapped = unwrapType(config2, fieldType.type);
58290
+ return AST12.tsPropertySignature(
58291
+ AST12.identifier(key),
58292
+ AST12.tsTypeAnnotation(
58293
+ scalarPropertyValue(config2, /* @__PURE__ */ new Set(), unwrapped.type)
58294
+ )
58295
+ );
58296
+ })
58297
+ );
58298
+ } else if (typeName === "__ROOT__") {
58299
+ idFields = AST12.tsTypeLiteral([]);
58300
+ }
58301
+ let fields = AST12.tsTypeLiteral([]);
58302
+ if (graphql17.isObjectType(type)) {
58303
+ fields = AST12.tsTypeLiteral(
58304
+ Object.entries(type.getFields()).map(
58305
+ ([key, fieldType]) => {
58306
+ const unwrapped = unwrapType(config2, fieldType.type);
58307
+ let typeOptions = AST12.tsUnionType([]);
58308
+ if (graphql17.isScalarType(unwrapped.type)) {
58309
+ typeOptions.types.push(
58310
+ scalarPropertyValue(config2, /* @__PURE__ */ new Set(), unwrapped.type)
58311
+ );
58312
+ } else if (graphql17.isEnumType(unwrapped.type)) {
58313
+ typeOptions.types.push(
58314
+ AST12.tsTypeReference(AST12.identifier(unwrapped.type.name))
58315
+ );
58316
+ } else if (!graphql17.isAbstractType(unwrapped.type)) {
58317
+ typeOptions.types.push(record(unwrapped.type.name));
58318
+ } else {
58319
+ typeOptions.types.push(
58320
+ ...config2.schema.getPossibleTypes(unwrapped.type).map((type2) => record(type2.name))
58321
+ );
58322
+ }
58323
+ for (const wrapper of unwrapped.wrappers) {
58324
+ if (wrapper === "Nullable" /* Nullable */) {
58325
+ typeOptions = AST12.tsParenthesizedType(
58326
+ AST12.tsUnionType([typeOptions, AST12.tsNullKeyword()])
58327
+ );
58328
+ } else if (wrapper === "List" /* List */) {
58329
+ typeOptions = AST12.tsArrayType(
58330
+ AST12.tsParenthesizedType(typeOptions)
58331
+ );
58332
+ }
58333
+ }
58334
+ if (typeOptions.type === "TSParenthesizedType") {
58335
+ typeOptions = typeOptions.typeAnnotation;
58336
+ }
58337
+ let args = AST12.tsNeverKeyword();
58338
+ if (fieldType.args?.length > 0) {
58339
+ args = AST12.tsTypeLiteral(
58340
+ fieldType.args.map((arg) => {
58341
+ addReferencedInputTypes(
58342
+ config2,
58343
+ "",
58344
+ body,
58345
+ visitedTypes,
58346
+ /* @__PURE__ */ new Set(),
58347
+ arg.type
58348
+ );
58349
+ const prop = AST12.tsPropertySignature(
58350
+ AST12.identifier(arg.name),
58351
+ AST12.tsTypeAnnotation(
58352
+ tsTypeReference(config2, /* @__PURE__ */ new Set(), arg)
58353
+ )
58354
+ );
58355
+ const unwrapped2 = unwrapType(config2, arg.type);
58356
+ prop.optional = unwrapped2.wrappers[unwrapped2.wrappers.length - 1] === "Nullable" /* Nullable */;
58357
+ return prop;
58358
+ })
58359
+ );
58360
+ }
58361
+ return AST12.tsPropertySignature(
58362
+ AST12.identifier(key),
58018
58363
  AST12.tsTypeAnnotation(
58019
58364
  AST12.tsTypeLiteral([
58020
58365
  AST12.tsPropertySignature(
58021
- AST12.stringLiteral(propTypeName),
58022
- AST12.tsTypeAnnotation(
58023
- AST12.tsLiteralType(AST12.booleanLiteral(true))
58024
- )
58366
+ AST12.identifier("type"),
58367
+ AST12.tsTypeAnnotation(typeOptions)
58368
+ ),
58369
+ AST12.tsPropertySignature(
58370
+ AST12.identifier("args"),
58371
+ AST12.tsTypeAnnotation(args)
58025
58372
  )
58026
58373
  ])
58027
58374
  )
58028
- )
58375
+ );
58376
+ }
58377
+ )
58378
+ );
58379
+ }
58380
+ return AST12.tsPropertySignature(
58381
+ AST12.identifier(typeName),
58382
+ AST12.tsTypeAnnotation(
58383
+ AST12.tsTypeLiteral([
58384
+ AST12.tsPropertySignature(
58385
+ AST12.identifier("idFields"),
58386
+ AST12.tsTypeAnnotation(idFields)
58387
+ ),
58388
+ AST12.tsPropertySignature(
58389
+ AST12.identifier("fields"),
58390
+ AST12.tsTypeAnnotation(fields)
58391
+ ),
58392
+ AST12.tsPropertySignature(
58393
+ AST12.identifier("fragments"),
58394
+ AST12.tsTypeAnnotation(fragmentMap[typeName] ?? AST12.tsTupleType([]))
58029
58395
  )
58030
58396
  ])
58031
58397
  )
58398
+ );
58399
+ })
58400
+ );
58401
+ }
58402
+ function listDefinitions(config2, docs) {
58403
+ const lists = [];
58404
+ const visitedLists = /* @__PURE__ */ new Set();
58405
+ for (const doc of docs) {
58406
+ graphql17.visit(doc.document, {
58407
+ Directive(node, key, parent, path2, ancestors) {
58408
+ if (![config2.listDirective, config2.paginateDirective].includes(node.name.value)) {
58409
+ return;
58410
+ }
58411
+ const nameArg = node.arguments?.find((arg) => arg.name.value === "name");
58412
+ const nameValue = nameArg?.value?.value || "";
58413
+ if (!nameValue || visitedLists.has(nameValue)) {
58414
+ return;
58415
+ }
58416
+ visitedLists.add(nameValue);
58417
+ const parentType = parentTypeFromAncestors(
58418
+ config2.schema,
58419
+ doc.filename,
58420
+ ancestors.slice(0, -1)
58421
+ );
58422
+ const targetField = ancestors[ancestors.length - 1];
58423
+ const targetFieldDefinition = parentType.getFields()[targetField.name.value];
58424
+ const { type: listType } = unwrapType(config2, targetFieldDefinition.type);
58425
+ const possibleTypes = [];
58426
+ if (graphql17.isAbstractType(listType)) {
58427
+ possibleTypes.push(
58428
+ ...config2.schema.getPossibleTypes(listType).map((possible) => possible.name)
58429
+ );
58430
+ } else {
58431
+ possibleTypes.push(listType.name);
58432
+ }
58433
+ lists.push(
58434
+ AST12.tsPropertySignature(
58435
+ AST12.identifier(nameValue),
58436
+ AST12.tsTypeAnnotation(
58437
+ AST12.tsTypeLiteral([
58438
+ AST12.tsPropertySignature(
58439
+ AST12.identifier("types"),
58440
+ AST12.tsTypeAnnotation(
58441
+ AST12.tsUnionType(
58442
+ possibleTypes.map(
58443
+ (possible) => AST12.tsLiteralType(AST12.stringLiteral(possible))
58444
+ )
58445
+ )
58446
+ )
58447
+ ),
58448
+ AST12.tsPropertySignature(
58449
+ AST12.identifier("filters"),
58450
+ AST12.tsTypeAnnotation(
58451
+ targetFieldDefinition.args.length === 0 ? AST12.tsNeverKeyword() : AST12.tsTypeLiteral(
58452
+ targetFieldDefinition.args.map((arg) => {
58453
+ const argDef = AST12.tsPropertySignature(
58454
+ AST12.identifier(arg.name),
58455
+ AST12.tsTypeAnnotation(
58456
+ tsTypeReference(
58457
+ config2,
58458
+ /* @__PURE__ */ new Set(),
58459
+ arg
58460
+ )
58461
+ )
58462
+ );
58463
+ argDef.optional = true;
58464
+ return argDef;
58465
+ })
58466
+ )
58467
+ )
58468
+ )
58469
+ ])
58470
+ )
58471
+ )
58472
+ );
58473
+ }
58474
+ });
58475
+ }
58476
+ return AST12.tsTypeLiteral(lists);
58477
+ }
58478
+ function queryDefinitions(config2, body, docs, returnType) {
58479
+ return AST12.tsTupleType(
58480
+ docs.reduce((prev, doc) => {
58481
+ if (doc.kind !== "HoudiniQuery" /* Query */ || !doc.generateStore) {
58482
+ return prev;
58483
+ }
58484
+ const definition = doc.document.definitions.find(
58485
+ (def) => def.kind === "OperationDefinition" && def.operation === "query"
58486
+ );
58487
+ if (!definition) {
58488
+ return prev;
58489
+ }
58490
+ const runtimeType = returnType(doc);
58491
+ const [shapeType, inputType] = ensureImports({
58492
+ config: config2,
58493
+ body,
58494
+ sourceModule: path_exports.relative(
58495
+ config2.runtimeDirectory,
58496
+ config2.artifactImportPath(doc.name)
58497
+ ),
58498
+ import: [`${doc.name}$result`, `${doc.name}$input`]
58499
+ });
58500
+ return prev.concat(
58501
+ AST12.tsTupleType([
58502
+ AST12.tsTypeReference(AST12.identifier(runtimeType)),
58503
+ AST12.tsTypeReference(AST12.identifier(shapeType)),
58504
+ AST12.tsTypeReference(AST12.identifier(inputType))
58505
+ ])
58506
+ );
58507
+ }, [])
58508
+ );
58509
+ }
58510
+ function fragmentListMap(config2, concreteTypes, body, docs, return_type) {
58511
+ return docs.reduce((prev, doc) => {
58512
+ if (doc.kind !== "HoudiniFragment" /* Fragment */) {
58513
+ return prev;
58514
+ }
58515
+ const definition = doc.document.definitions.find(
58516
+ (def) => def.kind === "FragmentDefinition" && def.name.value === doc.name
58517
+ );
58518
+ if (!definition || !concreteTypes.includes(definition.typeCondition.name.value)) {
58519
+ return prev;
58520
+ }
58521
+ const typeName = definition.typeCondition.name.value;
58522
+ const previousValue = prev[typeName]?.elementTypes ?? [];
58523
+ const tagResult = return_type(doc);
58524
+ const [shapeType] = ensureImports({
58525
+ config: config2,
58526
+ body,
58527
+ sourceModule: path_exports.relative(
58528
+ config2.runtimeDirectory,
58529
+ config2.artifactImportPath(doc.name)
58032
58530
  ),
58033
- AST12.exportNamedDeclaration(
58034
- AST12.tsTypeAliasDeclaration(
58035
- AST12.identifier(shapeTypeName),
58036
- inlineType({
58531
+ import: [`${definition.name.value}$data`]
58532
+ });
58533
+ let inputType = AST12.tsNeverKeyword();
58534
+ let directive = definition.directives?.find(
58535
+ (directive2) => directive2.name.value === config2.argumentsDirective
58536
+ );
58537
+ if (directive) {
58538
+ inputType = AST12.tsTypeReference(
58539
+ AST12.identifier(
58540
+ ensureImports({
58037
58541
  config: config2,
58038
- filepath,
58039
- rootType: type,
58040
- selections,
58041
- root: true,
58042
- allowReadonly: true,
58043
58542
  body,
58044
- visitedTypes,
58045
- missingScalars,
58046
- includeFragments: true
58047
- })
58543
+ sourceModule: path_exports.relative(
58544
+ config2.runtimeDirectory,
58545
+ config2.artifactImportPath(doc.name)
58546
+ ),
58547
+ import: [`${definition.name.value}$input`]
58548
+ })[0]
58549
+ )
58550
+ );
58551
+ }
58552
+ return {
58553
+ ...prev,
58554
+ [typeName]: AST12.tsTupleType(
58555
+ previousValue.concat(
58556
+ AST12.tsTupleType([
58557
+ AST12.tsTypeReference(AST12.identifier(tagResult)),
58558
+ AST12.tsTypeReference(AST12.identifier(shapeType)),
58559
+ inputType
58560
+ ])
58048
58561
  )
58049
58562
  )
58050
- );
58051
- }
58563
+ };
58564
+ }, {});
58565
+ }
58566
+ var CacheTypeDefName = "CacheTypeDef";
58567
+ function record(name2) {
58568
+ return AST12.tsTypeReference(
58569
+ AST12.identifier("Record"),
58570
+ AST12.tsTypeParameterInstantiation([
58571
+ AST12.tsTypeReference(AST12.identifier(CacheTypeDefName)),
58572
+ AST12.tsLiteralType(AST12.stringLiteral(name2))
58573
+ ])
58574
+ );
58575
+ }
58576
+
58577
+ // src/codegen/generators/typescript/index.ts
58578
+ async function typescriptGenerator(config2, docs) {
58579
+ await Promise.all([
58580
+ generateDocumentTypes(config2, docs),
58581
+ imperativeCacheTypef(config2, docs)
58582
+ ]);
58052
58583
  }
58053
58584
 
58054
58585
  // src/codegen/generators/persistedQueries/index.ts
58055
- var graphql17 = __toESM(require_graphql2(), 1);
58586
+ var graphql18 = __toESM(require_graphql2(), 1);
58056
58587
  async function persistOutputGenerator(config2, docs) {
58057
58588
  if (typeof config2.persistedQueryPath !== "string" || config2.persistedQueryPath.length === 0)
58058
58589
  return;
@@ -58064,8 +58595,8 @@ async function persistOutputGenerator(config2, docs) {
58064
58595
  if (!generateArtifact) {
58065
58596
  return acc;
58066
58597
  }
58067
- let rawString = graphql17.print(
58068
- graphql17.visit(document, {
58598
+ let rawString = graphql18.print(
58599
+ graphql18.visit(document, {
58069
58600
  Directive(node) {
58070
58601
  if (config2.isInternalDirective(node)) {
58071
58602
  return null;
@@ -58074,7 +58605,7 @@ async function persistOutputGenerator(config2, docs) {
58074
58605
  })
58075
58606
  );
58076
58607
  const operations = document.definitions.filter(
58077
- ({ kind }) => kind === graphql17.Kind.OPERATION_DEFINITION
58608
+ ({ kind }) => kind === graphql18.Kind.OPERATION_DEFINITION
58078
58609
  );
58079
58610
  if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
58080
58611
  acc[hashDocument(rawString)] = rawString;
@@ -58087,11 +58618,11 @@ async function persistOutputGenerator(config2, docs) {
58087
58618
  }
58088
58619
 
58089
58620
  // src/codegen/generators/definitions/enums.ts
58090
- var graphql18 = __toESM(require_graphql2(), 1);
58621
+ var graphql19 = __toESM(require_graphql2(), 1);
58091
58622
  var recast13 = __toESM(require_main2(), 1);
58092
58623
  var AST13 = recast13.types.builders;
58093
58624
  async function definitionsGenerator(config2) {
58094
- const enums = graphql18.parse(graphql18.printSchema(config2.schema)).definitions.filter(
58625
+ const enums = graphql19.parse(graphql19.printSchema(config2.schema)).definitions.filter(
58095
58626
  (definition) => definition.kind === "EnumTypeDefinition"
58096
58627
  ).filter((def) => !config2.isInternalEnum(def));
58097
58628
  const runtimeDefinitions = recast13.print(
@@ -58181,91 +58712,8 @@ async function writeIndexFile2(config2, docs) {
58181
58712
  await fs_exports.writeFile(path_exports.join(config2.rootDir, "index.js"), body);
58182
58713
  }
58183
58714
 
58184
- // src/codegen/transforms/composeQueries.ts
58185
- var import_graphql = __toESM(require_graphql2(), 1);
58186
- async function includeFragmentDefinitions(config2, documents) {
58187
- const fragments = collectFragments(config2, documents);
58188
- for (const [index, { name: name2, document, filename }] of documents.entries()) {
58189
- const operation = document.definitions.find(
58190
- ({ kind }) => kind === import_graphql.Kind.OPERATION_DEFINITION
58191
- );
58192
- if (!operation) {
58193
- continue;
58194
- }
58195
- const allFragments = flattenFragments(
58196
- filename,
58197
- { requiredFragments: findRequiredFragments(operation.selectionSet) },
58198
- fragments
58199
- );
58200
- documents[index].document = {
58201
- ...document,
58202
- definitions: [
58203
- operation,
58204
- ...allFragments.map((fragmentName) => fragments[fragmentName].definition)
58205
- ]
58206
- };
58207
- }
58208
- }
58209
- function collectFragments(config2, docs) {
58210
- return docs.reduce((acc, doc) => {
58211
- const definitions = doc.document.definitions.reduce(
58212
- (prev, definition) => definition.kind !== "FragmentDefinition" ? prev : {
58213
- ...prev,
58214
- [definition.name.value]: {
58215
- definition,
58216
- requiredFragments: findRequiredFragments(definition.selectionSet),
58217
- document: doc
58218
- }
58219
- },
58220
- {}
58221
- );
58222
- return {
58223
- ...acc,
58224
- ...definitions
58225
- };
58226
- }, {});
58227
- }
58228
- function findRequiredFragments(selectionSet) {
58229
- if (selectionSet.selections.length === 0) {
58230
- return [];
58231
- }
58232
- const referencedFragments = [];
58233
- for (const selection2 of selectionSet.selections) {
58234
- if (selection2.kind === import_graphql.Kind.FRAGMENT_SPREAD) {
58235
- referencedFragments.push(selection2.name.value);
58236
- } else if (selection2.selectionSet) {
58237
- referencedFragments.push(...findRequiredFragments(selection2.selectionSet));
58238
- }
58239
- }
58240
- return referencedFragments;
58241
- }
58242
- function flattenFragments(filepath, operation, fragments) {
58243
- const frags = /* @__PURE__ */ new Set();
58244
- const remaining = [...operation.requiredFragments];
58245
- while (remaining.length > 0) {
58246
- const nextFragment = remaining.shift();
58247
- if (!nextFragment) {
58248
- continue;
58249
- }
58250
- if (!frags.has(nextFragment)) {
58251
- frags.add(nextFragment);
58252
- } else {
58253
- continue;
58254
- }
58255
- const targetFragment = fragments[nextFragment];
58256
- if (!targetFragment) {
58257
- throw new HoudiniError({
58258
- filepath,
58259
- message: "compose: could not find definition for fragment " + nextFragment
58260
- });
58261
- }
58262
- remaining.push(...targetFragment.requiredFragments);
58263
- }
58264
- return [...frags];
58265
- }
58266
-
58267
58715
  // src/codegen/transforms/schema.ts
58268
- var graphql19 = __toESM(require_graphql2(), 1);
58716
+ var graphql20 = __toESM(require_graphql2(), 1);
58269
58717
  async function graphqlExtensions(config2, documents) {
58270
58718
  const internalSchema = `
58271
58719
  enum CachePolicy {
@@ -58329,9 +58777,9 @@ directive @${config2.argumentsDirective} on FRAGMENT_DEFINITION
58329
58777
  directive @${config2.cacheDirective}(${config2.cachePolicyArg}: CachePolicy, ${config2.cachePartialArg}: Boolean) on QUERY
58330
58778
 
58331
58779
  """
58332
- @${config2.manualLoadDirective} is used to disable automatic fetch (no load, no auto fetch in component), you will have to do it manually.
58780
+ @${config2.loadDirective} is used to disable automatic fetch (no load, no auto fetch in component), you will have to do it manually.
58333
58781
  """
58334
- directive @${config2.manualLoadDirective} on QUERY
58782
+ directive @${config2.loadDirective} on QUERY
58335
58783
 
58336
58784
  """
58337
58785
  @${config2.maskEnableDirective} to enable masking on fragment (overwriting the global conf)
@@ -58343,19 +58791,19 @@ directive @${config2.maskEnableDirective} on FRAGMENT_SPREAD
58343
58791
  """
58344
58792
  directive @${config2.maskDisableDirective} on FRAGMENT_SPREAD
58345
58793
  `;
58346
- let currentSchema = graphql19.printSchema(config2.schema);
58794
+ let currentSchema = graphql20.printSchema(config2.schema);
58347
58795
  if (!currentSchema.includes(`directive @${config2.listDirective}`)) {
58348
58796
  currentSchema += internalSchema;
58349
58797
  }
58350
58798
  config2.newSchema += internalSchema;
58351
- config2.schema = graphql19.buildSchema(currentSchema);
58799
+ config2.schema = graphql20.buildSchema(currentSchema);
58352
58800
  }
58353
58801
 
58354
58802
  // src/codegen/transforms/typename.ts
58355
- var graphql20 = __toESM(require_graphql2(), 1);
58803
+ var graphql21 = __toESM(require_graphql2(), 1);
58356
58804
  async function addTypename(config2, documents) {
58357
58805
  for (const doc of documents) {
58358
- doc.document = graphql20.visit(doc.document, {
58806
+ doc.document = graphql21.visit(doc.document, {
58359
58807
  Field(node, key, parent, path2, ancestors) {
58360
58808
  if (!node.selectionSet) {
58361
58809
  return;
@@ -58367,7 +58815,7 @@ async function addTypename(config2, documents) {
58367
58815
  );
58368
58816
  const field = type.getFields()[node.name.value];
58369
58817
  const fieldType = unwrapType(config2, field.type).type;
58370
- if (graphql20.isInterfaceType(fieldType) || graphql20.isUnionType(fieldType)) {
58818
+ if (graphql21.isInterfaceType(fieldType) || graphql21.isUnionType(fieldType)) {
58371
58819
  return {
58372
58820
  ...node,
58373
58821
  selectionSet: {
@@ -58375,9 +58823,9 @@ async function addTypename(config2, documents) {
58375
58823
  selections: [
58376
58824
  ...node.selectionSet.selections,
58377
58825
  {
58378
- kind: graphql20.Kind.FIELD,
58826
+ kind: graphql21.Kind.FIELD,
58379
58827
  name: {
58380
- kind: graphql20.Kind.NAME,
58828
+ kind: graphql21.Kind.NAME,
58381
58829
  value: "__typename"
58382
58830
  }
58383
58831
  }
@@ -58391,10 +58839,10 @@ async function addTypename(config2, documents) {
58391
58839
  }
58392
58840
 
58393
58841
  // src/codegen/transforms/addID.ts
58394
- var graphql21 = __toESM(require_graphql2(), 1);
58842
+ var graphql22 = __toESM(require_graphql2(), 1);
58395
58843
  async function addID(config2, documents) {
58396
58844
  for (const doc of documents) {
58397
- doc.document = graphql21.visit(doc.document, {
58845
+ doc.document = graphql22.visit(doc.document, {
58398
58846
  Field(node, key, parent, path2, ancestors) {
58399
58847
  if (!node.selectionSet) {
58400
58848
  return;
@@ -58407,7 +58855,7 @@ async function addID(config2, documents) {
58407
58855
  const field = type.getFields()[node.name.value];
58408
58856
  const fieldType = unwrapType(config2, field.type).type;
58409
58857
  if (node.selectionSet?.selections.length > 0) {
58410
- if (!graphql21.isObjectType(fieldType) && !graphql21.isInterfaceType(fieldType)) {
58858
+ if (!graphql22.isObjectType(fieldType) && !graphql22.isInterfaceType(fieldType)) {
58411
58859
  return;
58412
58860
  }
58413
58861
  const keyFields = config2.keyFieldsForType(fieldType.name);
@@ -58422,9 +58870,9 @@ async function addID(config2, documents) {
58422
58870
  continue;
58423
58871
  }
58424
58872
  selections.push({
58425
- kind: graphql21.Kind.FIELD,
58873
+ kind: graphql22.Kind.FIELD,
58426
58874
  name: {
58427
- kind: graphql21.Kind.NAME,
58875
+ kind: graphql22.Kind.NAME,
58428
58876
  value: keyField
58429
58877
  }
58430
58878
  });
@@ -58442,266 +58890,6 @@ async function addID(config2, documents) {
58442
58890
  }
58443
58891
  }
58444
58892
 
58445
- // src/codegen/transforms/fragmentVariables.ts
58446
- var graphql22 = __toESM(require_graphql2(), 1);
58447
- var GraphqlKinds2 = graphql22.Kind;
58448
- async function fragmentVariables(config2, documents) {
58449
- const fragments = collectFragments(config2, documents);
58450
- const generatedFragments = {};
58451
- const visitedFragments = /* @__PURE__ */ new Set();
58452
- for (const doc2 of documents) {
58453
- const operation = doc2.document.definitions.find(
58454
- ({ kind }) => kind === GraphqlKinds2.OPERATION_DEFINITION
58455
- );
58456
- if (!operation) {
58457
- continue;
58458
- }
58459
- doc2.document = inlineFragmentArgs({
58460
- config: config2,
58461
- filepath: doc2.filename,
58462
- fragmentDefinitions: fragments,
58463
- document: doc2.document,
58464
- generatedFragments,
58465
- visitedFragments,
58466
- scope: null
58467
- });
58468
- }
58469
- const doc = {
58470
- kind: graphql22.Kind.DOCUMENT,
58471
- definitions: Object.values(generatedFragments)
58472
- };
58473
- documents.push({
58474
- name: "generated::fragmentVariables",
58475
- kind: "HoudiniFragment" /* Fragment */,
58476
- document: doc,
58477
- originalDocument: doc,
58478
- generateStore: false,
58479
- generateArtifact: false,
58480
- filename: "generated::fragmentVariables",
58481
- originalString: ""
58482
- });
58483
- }
58484
- function inlineFragmentArgs({
58485
- config: config2,
58486
- filepath,
58487
- fragmentDefinitions,
58488
- document,
58489
- generatedFragments,
58490
- visitedFragments,
58491
- scope,
58492
- newName
58493
- }) {
58494
- if (!scope) {
58495
- scope = operationScope(
58496
- document.definitions.find(
58497
- ({ kind }) => kind === GraphqlKinds2.OPERATION_DEFINITION
58498
- )
58499
- );
58500
- }
58501
- const definitionArgs = fragmentArguments(
58502
- config2,
58503
- filepath,
58504
- document
58505
- ).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
58506
- const result = graphql22.visit(document, {
58507
- FragmentSpread(node) {
58508
- const { definition } = fragmentDefinitions[node.name.value];
58509
- let { args, hash } = collectWithArguments(config2, filepath, node, scope);
58510
- const newFragmentName = `${node.name.value}${hash}`;
58511
- if (!visitedFragments.has(newFragmentName)) {
58512
- visitedFragments.add(newFragmentName);
58513
- const defaultArguments = collectDefaultArgumentValues(config2, filepath, definition);
58514
- if (args) {
58515
- for (const [field, value] of Object.entries(defaultArguments || {})) {
58516
- if (!args[field]) {
58517
- args[field] = value;
58518
- }
58519
- }
58520
- generatedFragments[newFragmentName] = inlineFragmentArgs({
58521
- config: config2,
58522
- filepath,
58523
- fragmentDefinitions,
58524
- document: fragmentDefinitions[node.name.value].definition,
58525
- generatedFragments,
58526
- visitedFragments,
58527
- scope: args,
58528
- newName: newFragmentName
58529
- });
58530
- } else {
58531
- const doc = fragmentDefinitions[node.name.value].document;
58532
- const definitionIndex = doc.document.definitions.findIndex(
58533
- (definition2) => definition2.kind === "FragmentDefinition" && definition2.name.value === node.name.value
58534
- );
58535
- const localDefinitions = [...doc.document.definitions];
58536
- localDefinitions.splice(definitionIndex, 1);
58537
- localDefinitions.push(
58538
- inlineFragmentArgs({
58539
- config: config2,
58540
- filepath,
58541
- fragmentDefinitions,
58542
- document: fragmentDefinitions[node.name.value].definition,
58543
- generatedFragments,
58544
- visitedFragments,
58545
- scope: defaultArguments,
58546
- newName: ""
58547
- })
58548
- );
58549
- doc.document = {
58550
- ...doc.document,
58551
- definitions: localDefinitions
58552
- };
58553
- }
58554
- if (node.name.value !== newFragmentName) {
58555
- return {
58556
- ...node,
58557
- name: {
58558
- kind: "Name",
58559
- value: newFragmentName
58560
- }
58561
- };
58562
- }
58563
- }
58564
- },
58565
- Argument(node) {
58566
- const value = node.value;
58567
- if (value.kind !== "Variable") {
58568
- return;
58569
- }
58570
- if (!scope) {
58571
- throw new HoudiniError({
58572
- filepath,
58573
- message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
58574
- });
58575
- }
58576
- const newValue = scope[value.name.value];
58577
- if (newValue) {
58578
- return {
58579
- ...node,
58580
- value: newValue
58581
- };
58582
- }
58583
- if (definitionArgs[value.name.value] && definitionArgs[value.name.value].required) {
58584
- throw new HoudiniError({
58585
- filepath,
58586
- message: "Missing value for required arg: " + value.name.value
58587
- });
58588
- }
58589
- return null;
58590
- }
58591
- });
58592
- if (newName) {
58593
- result.name = {
58594
- kind: graphql22.Kind.NAME,
58595
- value: newName
58596
- };
58597
- }
58598
- return result;
58599
- }
58600
- function withArguments(config2, node) {
58601
- const withDirectives = node.directives?.filter(
58602
- (directive) => directive.name.value === config2.withDirective
58603
- );
58604
- if (!withDirectives || withDirectives.length === 0) {
58605
- return [];
58606
- }
58607
- return withDirectives.flatMap((directive) => directive.arguments || []);
58608
- }
58609
- function fragmentArguments(config2, filepath, definition) {
58610
- const directives = definition.directives?.filter(
58611
- (directive) => directive.name.value === config2.argumentsDirective
58612
- );
58613
- if (!directives || directives.length === 0) {
58614
- return [];
58615
- }
58616
- return directives.flatMap(
58617
- (directive) => directive.arguments?.flatMap((arg) => {
58618
- if (arg.value.kind !== "ObjectValue") {
58619
- throw new HoudiniError({
58620
- filepath,
58621
- message: "values of @argument must be objects"
58622
- });
58623
- }
58624
- const typeArg = arg.value.fields?.find((arg2) => arg2.name.value === "type")?.value;
58625
- if (!typeArg || typeArg.kind !== "StringValue") {
58626
- return [];
58627
- }
58628
- let type = typeArg.value;
58629
- let name2 = arg.name.value;
58630
- let required = false;
58631
- let defaultValue = arg.value.fields?.find((arg2) => arg2.name.value === "default")?.value || null;
58632
- if (type[type.length - 1] === "!") {
58633
- type = type.slice(0, -1);
58634
- required = true;
58635
- defaultValue = null;
58636
- }
58637
- return [
58638
- {
58639
- name: name2,
58640
- type,
58641
- required,
58642
- defaultValue
58643
- }
58644
- ];
58645
- }) || []
58646
- );
58647
- }
58648
- function collectDefaultArgumentValues(config2, filepath, definition) {
58649
- let result = {};
58650
- for (const { name: name2, required, defaultValue } of fragmentArguments(
58651
- config2,
58652
- filepath,
58653
- definition
58654
- )) {
58655
- if (required || !defaultValue) {
58656
- continue;
58657
- }
58658
- result[name2] = defaultValue;
58659
- }
58660
- return result;
58661
- }
58662
- function collectWithArguments(config2, filepath, node, scope = {}) {
58663
- const withArgs = withArguments(config2, node);
58664
- if (withArgs.length === 0) {
58665
- return { args: null, hash: "" };
58666
- }
58667
- let args = {};
58668
- for (const arg of withArgs) {
58669
- let value = arg.value;
58670
- if (value.kind === GraphqlKinds2.VARIABLE) {
58671
- if (!scope || !scope[value.name.value]) {
58672
- throw new HoudiniError({
58673
- filepath,
58674
- message: "Encountered undefined variable: " + value.name.value
58675
- });
58676
- }
58677
- value = scope[value.name.value];
58678
- }
58679
- args[arg.name.value] = {
58680
- ...value,
58681
- loc: void 0
58682
- };
58683
- }
58684
- return {
58685
- args,
58686
- hash: "_" + murmurHash(JSON.stringify(args))
58687
- };
58688
- }
58689
- function operationScope(operation) {
58690
- return operation.variableDefinitions?.reduce(
58691
- (scope, definition) => ({
58692
- ...scope,
58693
- [definition.variable.name.value]: {
58694
- kind: "Variable",
58695
- name: {
58696
- kind: "Name",
58697
- value: definition.variable.name.value
58698
- }
58699
- }
58700
- }),
58701
- {}
58702
- ) || {};
58703
- }
58704
-
58705
58893
  // src/codegen/validators/typeCheck.ts
58706
58894
  var graphql23 = __toESM(require_graphql2(), 1);
58707
58895
  async function typeCheck(config2, docs) {
@@ -59881,7 +60069,6 @@ function testConfigFile({ plugins, ...config2 } = {}) {
59881
60069
  }
59882
60070
  }
59883
60071
  },
59884
- framework: "kit",
59885
60072
  types: {
59886
60073
  Ghost: {
59887
60074
  keys: ["name", "aka"],