houdini 1.2.43 → 1.2.44

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.
@@ -31868,7 +31868,7 @@ var require_path_visitor = __commonJS({
31868
31868
  }
31869
31869
  return target;
31870
31870
  }
31871
- PathVisitor.visit = function visit19(node, methods) {
31871
+ PathVisitor.visit = function visit20(node, methods) {
31872
31872
  return PathVisitor.fromMethodsObject(methods).visit(node);
31873
31873
  };
31874
31874
  var PVp = PathVisitor.prototype;
@@ -32059,7 +32059,7 @@ var require_path_visitor = __commonJS({
32059
32059
  this.needToCallTraverse = false;
32060
32060
  return visitChildren(path3, PathVisitor.fromMethodsObject(newVisitor || this.visitor));
32061
32061
  };
32062
- sharedContextProtoMethods.visit = function visit19(path3, newVisitor) {
32062
+ sharedContextProtoMethods.visit = function visit20(path3, newVisitor) {
32063
32063
  if (!(this instanceof this.Context)) {
32064
32064
  throw new Error("");
32065
32065
  }
@@ -33452,7 +33452,7 @@ var require_main = __commonJS({
33452
33452
  var someField = _a.someField;
33453
33453
  var Type = _a.Type;
33454
33454
  var use = _a.use;
33455
- var visit19 = _a.visit;
33455
+ var visit20 = _a.visit;
33456
33456
  exports.astNodesAreEquivalent = astNodesAreEquivalent;
33457
33457
  exports.builders = builders;
33458
33458
  exports.builtInTypes = builtInTypes;
@@ -33469,7 +33469,7 @@ var require_main = __commonJS({
33469
33469
  exports.someField = someField;
33470
33470
  exports.Type = Type;
33471
33471
  exports.use = use;
33472
- exports.visit = visit19;
33472
+ exports.visit = visit20;
33473
33473
  Object.assign(namedTypes_1.namedTypes, n);
33474
33474
  }
33475
33475
  });
@@ -61315,7 +61315,7 @@ function watchAndRun(params) {
61315
61315
  }
61316
61316
 
61317
61317
  // src/codegen/index.ts
61318
- import * as graphql32 from "graphql";
61318
+ import * as graphql33 from "graphql";
61319
61319
 
61320
61320
  // src/lib/pipeline.ts
61321
61321
  async function runPipeline(config2, pipeline2, target) {
@@ -68456,8 +68456,22 @@ var query = documentPlugin(ArtifactKind.Query, function() {
68456
68456
  let lastVariables = null;
68457
68457
  return {
68458
68458
  start(ctx, { next }) {
68459
+ const runtimeScalarPayload = {
68460
+ session: ctx.session
68461
+ };
68459
68462
  ctx.variables = {
68460
68463
  ...lastVariables,
68464
+ ...Object.fromEntries(
68465
+ Object.entries(ctx.artifact.input?.runtimeScalars ?? {}).map(
68466
+ ([field, type]) => {
68467
+ const runtimeScalar = ctx.config.features?.runtimeScalars?.[type];
68468
+ if (!runtimeScalar) {
68469
+ return [field, type];
68470
+ }
68471
+ return [field, runtimeScalar.resolve(runtimeScalarPayload)];
68472
+ }
68473
+ )
68474
+ ),
68461
68475
  ...ctx.variables
68462
68476
  };
68463
68477
  next(ctx);
@@ -69037,6 +69051,9 @@ var Config = class {
69037
69051
  get loadingDirective() {
69038
69052
  return `loading`;
69039
69053
  }
69054
+ get runtimeScalarDirective() {
69055
+ return "__houdini__runtimeScalar";
69056
+ }
69040
69057
  get whenDirective() {
69041
69058
  return "when";
69042
69059
  }
@@ -69107,7 +69124,7 @@ var Config = class {
69107
69124
  const internalDirectives = this.#newSchemaInstance?.getDirectives().reduce((list, directive) => {
69108
69125
  return list.concat(directive.name);
69109
69126
  }, []) ?? [];
69110
- return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name));
69127
+ return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name) || name === this.runtimeScalarDirective);
69111
69128
  }
69112
69129
  get componentFieldDirective() {
69113
69130
  return "componentField";
@@ -69628,7 +69645,7 @@ function unwrapType(config2, type, wrappers = []) {
69628
69645
  }
69629
69646
  const namedType = config2.schema.getType(type.name.value || type.name);
69630
69647
  if (!namedType) {
69631
- throw new Error("Could not unwrap type: " + JSON.stringify(type));
69648
+ throw new Error("Unknown type: " + type.name.value || type.name);
69632
69649
  }
69633
69650
  return { type: namedType, wrappers };
69634
69651
  }
@@ -71438,7 +71455,7 @@ ${exportDefaultFrom(`./${doc.name}`, doc.name)}`,
71438
71455
 
71439
71456
  // src/codegen/generators/artifacts/inputs.ts
71440
71457
  import * as graphql8 from "graphql";
71441
- function inputObject(config2, inputs) {
71458
+ function inputObject(config2, inputs, runtimeScalars) {
71442
71459
  const visitedTypes = /* @__PURE__ */ new Set();
71443
71460
  const inputObj = {
71444
71461
  fields: inputs.reduce((fields, input) => {
@@ -71454,7 +71471,8 @@ function inputObject(config2, inputs) {
71454
71471
  ...fields,
71455
71472
  [input.variable.name.value]: input.defaultValue ? variableValue(input.defaultValue, {}) : void 0
71456
71473
  };
71457
- }, {})
71474
+ }, {}),
71475
+ runtimeScalars
71458
71476
  };
71459
71477
  for (const input of inputs) {
71460
71478
  walkInputs(config2, visitedTypes, inputObj, input.type);
@@ -73297,7 +73315,21 @@ function artifactGenerator(stats) {
73297
73315
  artifact.pluginData[plugin2.name] = plugin2.artifactData({ config: config2, document: doc }) ?? {};
73298
73316
  }
73299
73317
  if (inputs && inputs.length > 0) {
73300
- artifact.input = inputObject(config2, inputs);
73318
+ const runtimeScalars = inputs.reduce((prev, input) => {
73319
+ const runtimeScalarDirective = input.directives?.find(
73320
+ (directive2) => directive2.name.value === config2.runtimeScalarDirective
73321
+ );
73322
+ if (!runtimeScalarDirective) {
73323
+ return prev;
73324
+ }
73325
+ return {
73326
+ ...prev,
73327
+ [input.variable.name.value]: runtimeScalarDirective.arguments?.find(
73328
+ (arg) => arg.name.value === "type"
73329
+ )?.value?.value
73330
+ };
73331
+ }, {});
73332
+ artifact.input = inputObject(config2, inputs, runtimeScalars);
73301
73333
  }
73302
73334
  if (artifact.kind === "HoudiniQuery") {
73303
73335
  const cacheDirective = operations[0].directives?.find(
@@ -74389,17 +74421,20 @@ export * from "${module}"
74389
74421
  }
74390
74422
  }
74391
74423
  await fs_exports.writeFile(config2.typeIndexPath, indexContent);
74392
- if (missingScalars.size > 0) {
74393
- console.warn(`\u26A0\uFE0F Missing definitions for the following scalars: ${[...missingScalars].join(
74394
- ", "
74395
- )}
74424
+ const missingScalarNames = [...missingScalars].filter(
74425
+ (scalar) => !config2.configFile.features?.runtimeScalars?.[scalar]
74426
+ );
74427
+ if (missingScalarNames.length > 0) {
74428
+ console.warn(`\u26A0\uFE0F Missing definitions for the following scalars: ${[
74429
+ ...missingScalarNames
74430
+ ].join(", ")}
74396
74431
  Generated types will contain an any type in place of these values. To fix this, provide an equivalent
74397
74432
  type in your config file:
74398
74433
 
74399
74434
  {
74400
74435
  scalars: {
74401
74436
  ${cyan3(`/* in your case, something like */`)}
74402
- ${[...missingScalars].map(
74437
+ ${[...missingScalarNames].map(
74403
74438
  (c) => ` ${c}: { ${green3(`// <- The GraphQL Scalar`)}
74404
74439
  type: "${cyan3(`YourType_${c}`)}" ${green3(`// <- The TypeScript type`)}
74405
74440
  }`
@@ -76981,7 +77016,7 @@ ${config2.configFile.features?.componentFields ? `
76981
77016
  """
76982
77017
  @${config2.componentFieldDirective} marks an inline fragment as the selection for a component field
76983
77018
  """
76984
- directive @${config2.componentFieldDirective}(field: String!, prop: String, export: String, raw: String) on FRAGMENT_DEFINITION | INLINE_FRAGMENT
77019
+ directive @${config2.componentFieldDirective}(field: String!, prop: String, export: String, raw: String) on FRAGMENT_DEFINITION | INLINE_FRAGMENT | FIELD_DEFINITION
76985
77020
 
76986
77021
  ` : ""}
76987
77022
 
@@ -76992,7 +77027,7 @@ directive @${config2.componentFieldDirective}(field: String!, prop: String, expo
76992
77027
  }
76993
77028
  internalSchema += plugin2.schema({ config: config2 });
76994
77029
  }
76995
- const extensions = Object.entries(config2.componentFields).map(([parent2, fields]) => {
77030
+ let extensions = Object.entries(config2.componentFields).map(([parent2, fields]) => {
76996
77031
  return `
76997
77032
  extend type ${parent2} {
76998
77033
  ${Object.entries(fields).map(([fieldName, field]) => {
@@ -77004,11 +77039,12 @@ directive @${config2.componentFieldDirective}(field: String!, prop: String, expo
77004
77039
  return `${arg.name}:${typeName}${arg.required ? "!" : ""}`;
77005
77040
  }).join("\n") + ")";
77006
77041
  }
77007
- return `${fieldName}${argString}: ${config2.componentScalar}!`;
77042
+ return `${fieldName}${argString}: ${config2.componentScalar}! @componentField(field: "${fieldName}")`;
77008
77043
  }).join("\n")}
77009
77044
  }
77010
77045
  `;
77011
77046
  }).join("\n");
77047
+ extensions += `${Object.keys(config2.configFile.features?.runtimeScalars ?? {}).map((scalar) => `scalar ${scalar}`).join("\n")}`;
77012
77048
  config2.newSchema = graphql25.print(mergeTypeDefs2([internalSchema, config2.newSchema]));
77013
77049
  config2.schemaString += extensions;
77014
77050
  config2.schema = graphql25.buildSchema(
@@ -77203,8 +77239,50 @@ async function componentFields(config2, documents) {
77203
77239
  }
77204
77240
  }
77205
77241
 
77206
- // src/codegen/validators/typeCheck.ts
77242
+ // src/codegen/transforms/runtimeScalars.ts
77207
77243
  import * as graphql29 from "graphql";
77244
+ async function addTypename2(config2, documents) {
77245
+ for (const doc of documents) {
77246
+ doc.document = graphql29.visit(doc.document, {
77247
+ VariableDefinition(node) {
77248
+ const { type, wrappers } = unwrapType(config2, node.type);
77249
+ const runtimeScalar = config2.configFile.features?.runtimeScalars?.[type.name];
77250
+ if (runtimeScalar) {
77251
+ return {
77252
+ ...node,
77253
+ type: wrapType({
77254
+ type: config2.schema.getType(runtimeScalar.type),
77255
+ wrappers
77256
+ }),
77257
+ directives: [
77258
+ ...node.directives ?? [],
77259
+ {
77260
+ kind: "Directive",
77261
+ name: {
77262
+ kind: "Name",
77263
+ value: config2.runtimeScalarDirective
77264
+ },
77265
+ arguments: [
77266
+ {
77267
+ kind: "Argument",
77268
+ name: { kind: "Name", value: "type" },
77269
+ value: {
77270
+ kind: "StringValue",
77271
+ value: type.name
77272
+ }
77273
+ }
77274
+ ]
77275
+ }
77276
+ ]
77277
+ };
77278
+ }
77279
+ }
77280
+ });
77281
+ }
77282
+ }
77283
+
77284
+ // src/codegen/validators/typeCheck.ts
77285
+ import * as graphql30 from "graphql";
77208
77286
  async function typeCheck(config2, docs) {
77209
77287
  const errors = [];
77210
77288
  const freeLists = [];
@@ -77212,7 +77290,7 @@ async function typeCheck(config2, docs) {
77212
77290
  const listTypes = [];
77213
77291
  const fragments = {};
77214
77292
  for (const { document: parsed, originalString, filename } of docs) {
77215
- graphql29.visit(parsed, {
77293
+ graphql30.visit(parsed, {
77216
77294
  FragmentDefinition(definition) {
77217
77295
  fragments[definition.name.value] = definition;
77218
77296
  },
@@ -77257,14 +77335,14 @@ async function typeCheck(config2, docs) {
77257
77335
  );
77258
77336
  return;
77259
77337
  }
77260
- if (graphql29.isListType(rootType) || graphql29.isNonNullType(rootType) && graphql29.isListType(rootType.ofType)) {
77338
+ if (graphql30.isListType(rootType) || graphql30.isNonNullType(rootType) && graphql30.isListType(rootType.ofType)) {
77261
77339
  needsParent = true;
77262
77340
  break;
77263
77341
  }
77264
- if (graphql29.isNonNullType(rootType) && "ofType" in rootType) {
77342
+ if (graphql30.isNonNullType(rootType) && "ofType" in rootType) {
77265
77343
  rootType = rootType.ofType;
77266
77344
  }
77267
- if (graphql29.isScalarType(rootType)) {
77345
+ if (graphql30.isScalarType(rootType)) {
77268
77346
  break;
77269
77347
  }
77270
77348
  rootType = rootType?.getFields()[parent3.name.value]?.type;
@@ -77340,9 +77418,9 @@ async function typeCheck(config2, docs) {
77340
77418
  );
77341
77419
  }
77342
77420
  let targetTypes = [type];
77343
- if (graphql29.isUnionType(type)) {
77421
+ if (graphql30.isUnionType(type)) {
77344
77422
  targetTypes = config2.schema.getPossibleTypes(type);
77345
- } else if (graphql29.isInterfaceType(type)) {
77423
+ } else if (graphql30.isInterfaceType(type)) {
77346
77424
  try {
77347
77425
  for (const key of config2.keyFieldsForType(type.name)) {
77348
77426
  if (!type.getFields()[key]) {
@@ -77378,13 +77456,13 @@ async function typeCheck(config2, docs) {
77378
77456
  if (errors.length > 0) {
77379
77457
  throw errors;
77380
77458
  }
77381
- const rules = (filepath) => [...graphql29.specifiedRules].filter(
77459
+ const rules = (filepath) => [...graphql30.specifiedRules].filter(
77382
77460
  (rule) => ![
77383
- graphql29.NoUnusedFragmentsRule,
77384
- graphql29.KnownFragmentNamesRule,
77385
- graphql29.ExecutableDefinitionsRule,
77386
- graphql29.KnownDirectivesRule,
77387
- graphql29.KnownArgumentNamesRule
77461
+ graphql30.NoUnusedFragmentsRule,
77462
+ graphql30.KnownFragmentNamesRule,
77463
+ graphql30.ExecutableDefinitionsRule,
77464
+ graphql30.KnownDirectivesRule,
77465
+ graphql30.KnownArgumentNamesRule
77388
77466
  ].includes(rule)
77389
77467
  ).concat(
77390
77468
  validateLists({
@@ -77405,7 +77483,7 @@ async function typeCheck(config2, docs) {
77405
77483
  validateLoadingDirective(config2)
77406
77484
  );
77407
77485
  for (const { filename, document: parsed, originalString } of docs) {
77408
- for (const error of graphql29.validate(config2.schema, parsed, rules(filename))) {
77486
+ for (const error of graphql30.validate(config2.schema, parsed, rules(filename))) {
77409
77487
  errors.push(
77410
77488
  new HoudiniError({
77411
77489
  filepath: filename,
@@ -77434,20 +77512,20 @@ function validateRequiredDirective(config2, filepath) {
77434
77512
  if (!node.directives?.some(({ name }) => name.value === config2.requiredDirective))
77435
77513
  return;
77436
77514
  const parentType = parentTypeFromAncestors(config2.schema, filepath, ancestors);
77437
- if (!graphql29.isObjectType(parentType)) {
77515
+ if (!graphql30.isObjectType(parentType)) {
77438
77516
  ctx.reportError(
77439
- new graphql29.GraphQLError(
77517
+ new graphql30.GraphQLError(
77440
77518
  `@${config2.requiredDirective} may only be used on objects, not arguments`
77441
77519
  )
77442
77520
  );
77443
77521
  return;
77444
77522
  }
77445
77523
  const type = parentType.getFields()[node.name.value].type;
77446
- const isServerNullable = !graphql29.isNonNullType(type);
77524
+ const isServerNullable = !graphql30.isNonNullType(type);
77447
77525
  const isAlreadyClientNullable = isClientNullable(node, true);
77448
77526
  if (!isServerNullable && !isAlreadyClientNullable) {
77449
77527
  ctx.reportError(
77450
- new graphql29.GraphQLError(
77528
+ new graphql30.GraphQLError(
77451
77529
  `@${config2.requiredDirective} may only be used on nullable fields`
77452
77530
  )
77453
77531
  );
@@ -77469,7 +77547,7 @@ var validateLists = ({
77469
77547
  if (!config2.isListFragment(node.name.value)) {
77470
77548
  if (!fragments[node.name.value]) {
77471
77549
  ctx.reportError(
77472
- new graphql29.GraphQLError(
77550
+ new graphql30.GraphQLError(
77473
77551
  "Encountered unknown fragment: " + node.name.value
77474
77552
  )
77475
77553
  );
@@ -77479,7 +77557,7 @@ var validateLists = ({
77479
77557
  const listName = config2.listNameFromFragment(node.name.value);
77480
77558
  if (!lists.includes(listName)) {
77481
77559
  ctx.reportError(
77482
- new graphql29.GraphQLError(
77560
+ new graphql30.GraphQLError(
77483
77561
  "Encountered fragment referencing unknown list: " + listName
77484
77562
  )
77485
77563
  );
@@ -77504,7 +77582,7 @@ var validateLists = ({
77504
77582
  );
77505
77583
  if (parentArg) {
77506
77584
  ctx.reportError(
77507
- new graphql29.GraphQLError(
77585
+ new graphql30.GraphQLError(
77508
77586
  `@${config2.deprecatedlistDirectiveParentIDArg} should be defined only in it's own directive now`
77509
77587
  )
77510
77588
  );
@@ -77520,7 +77598,7 @@ var validateLists = ({
77520
77598
  return;
77521
77599
  }
77522
77600
  ctx.reportError(
77523
- new graphql29.GraphQLError(
77601
+ new graphql30.GraphQLError(
77524
77602
  `For this list fragment, you need to add or @${config2.listParentDirective} or @${config2.listAllListsDirective} directive to specify the behavior`
77525
77603
  )
77526
77604
  );
@@ -77530,7 +77608,7 @@ var validateLists = ({
77530
77608
  const directiveName = node.name.value;
77531
77609
  if (directiveName === "connection") {
77532
77610
  ctx.reportError(
77533
- new graphql29.GraphQLError(
77611
+ new graphql30.GraphQLError(
77534
77612
  "@connection was renamed to @list. Please change your components. If you were using `cache.connection` in your components, you will need to update that to `cache.list` too."
77535
77613
  )
77536
77614
  );
@@ -77539,7 +77617,7 @@ var validateLists = ({
77539
77617
  if (!config2.isInternalDirective(node.name.value)) {
77540
77618
  if (!config2.schema.getDirective(directiveName)) {
77541
77619
  ctx.reportError(
77542
- new graphql29.GraphQLError(
77620
+ new graphql30.GraphQLError(
77543
77621
  "Encountered unknown directive: " + directiveName
77544
77622
  )
77545
77623
  );
@@ -77548,7 +77626,7 @@ var validateLists = ({
77548
77626
  }
77549
77627
  if (config2.isListOperationDirective(directiveName) && !listTypes.includes(config2.listNameFromDirective(directiveName))) {
77550
77628
  ctx.reportError(
77551
- new graphql29.GraphQLError(
77629
+ new graphql30.GraphQLError(
77552
77630
  "Encountered directive referencing unknown list: " + directiveName
77553
77631
  )
77554
77632
  );
@@ -77559,7 +77637,7 @@ var validateLists = ({
77559
77637
  };
77560
77638
  function knownArguments(config2) {
77561
77639
  return function(ctx) {
77562
- const nativeValidator = graphql29.KnownArgumentNamesRule(ctx);
77640
+ const nativeValidator = graphql30.KnownArgumentNamesRule(ctx);
77563
77641
  return {
77564
77642
  ...nativeValidator,
77565
77643
  Directive(directiveNode) {
@@ -77594,7 +77672,7 @@ function validateFragmentArguments(config2, filepath, fragments) {
77594
77672
  for (const arg of node.arguments || []) {
77595
77673
  if (arg.value.kind !== "ObjectValue") {
77596
77674
  ctx.reportError(
77597
- new graphql29.GraphQLError("values in @arguments must be an object")
77675
+ new graphql30.GraphQLError("values in @arguments must be an object")
77598
77676
  );
77599
77677
  return;
77600
77678
  }
@@ -77604,13 +77682,13 @@ function validateFragmentArguments(config2, filepath, fragments) {
77604
77682
  );
77605
77683
  if (!typeArg) {
77606
77684
  ctx.reportError(
77607
- new graphql29.GraphQLError("missing type field for @arguments directive")
77685
+ new graphql30.GraphQLError("missing type field for @arguments directive")
77608
77686
  );
77609
77687
  return;
77610
77688
  }
77611
- if (typeArg.value.kind !== graphql29.Kind.STRING) {
77689
+ if (typeArg.value.kind !== graphql30.Kind.STRING) {
77612
77690
  ctx.reportError(
77613
- new graphql29.GraphQLError("type field to @arguments must be a string")
77691
+ new graphql30.GraphQLError("type field to @arguments must be a string")
77614
77692
  );
77615
77693
  return;
77616
77694
  }
@@ -77623,7 +77701,7 @@ function validateFragmentArguments(config2, filepath, fragments) {
77623
77701
  );
77624
77702
  if (typeArg.value.value !== defaultValueType) {
77625
77703
  ctx.reportError(
77626
- new graphql29.GraphQLError(
77704
+ new graphql30.GraphQLError(
77627
77705
  `Invalid default value provided for ${arg.name.value}. Expected ${typeArg.value.value}, found ${defaultValueType}`
77628
77706
  )
77629
77707
  );
@@ -77641,7 +77719,7 @@ function validateFragmentArguments(config2, filepath, fragments) {
77641
77719
  try {
77642
77720
  args = fragmentArguments(config2, filepath, fragments[fragmentName]);
77643
77721
  } catch (e2) {
77644
- ctx.reportError(new graphql29.GraphQLError(e2.message));
77722
+ ctx.reportError(new graphql30.GraphQLError(e2.message));
77645
77723
  return;
77646
77724
  }
77647
77725
  fragmentArguments2[fragmentName] = args;
@@ -77664,7 +77742,7 @@ function validateFragmentArguments(config2, filepath, fragments) {
77664
77742
  );
77665
77743
  if (missing.length > 0) {
77666
77744
  ctx.reportError(
77667
- new graphql29.GraphQLError(
77745
+ new graphql30.GraphQLError(
77668
77746
  `The following arguments are missing from the "${fragmentName}" fragment: ` + JSON.stringify(missing)
77669
77747
  )
77670
77748
  );
@@ -77675,7 +77753,7 @@ function validateFragmentArguments(config2, filepath, fragments) {
77675
77753
  );
77676
77754
  if (unknown.length > 0) {
77677
77755
  ctx.reportError(
77678
- new graphql29.GraphQLError(
77756
+ new graphql30.GraphQLError(
77679
77757
  "Encountered unknown arguments: " + JSON.stringify(unknown)
77680
77758
  )
77681
77759
  );
@@ -77687,7 +77765,7 @@ function validateFragmentArguments(config2, filepath, fragments) {
77687
77765
  for (const [applied, target] of zipped) {
77688
77766
  if (!valueIsType(config2, applied.value, target)) {
77689
77767
  ctx.reportError(
77690
- new graphql29.GraphQLError(
77768
+ new graphql30.GraphQLError(
77691
77769
  `Invalid argument type. Expected ${target}, found ${applied.value.kind}`
77692
77770
  )
77693
77771
  );
@@ -77729,7 +77807,7 @@ function valueIsType(config2, value, targetType) {
77729
77807
  }
77730
77808
  if (value.kind === "EnumValue" && targetType.kind === "NamedType") {
77731
77809
  const enumType = config2.schema.getType(targetType.name.value);
77732
- if (!graphql29.isEnumType(enumType)) {
77810
+ if (!graphql30.isEnumType(enumType)) {
77733
77811
  return false;
77734
77812
  }
77735
77813
  return enumType.getValues().some((enumValue) => enumValue.value === value.value);
@@ -77749,7 +77827,7 @@ function paginateArgs(config2, filepath) {
77749
77827
  }
77750
77828
  if (alreadyPaginated) {
77751
77829
  ctx.reportError(
77752
- new graphql29.GraphQLError(
77830
+ new graphql30.GraphQLError(
77753
77831
  `@${config2.paginateDirective} can only appear in a document once.`
77754
77832
  )
77755
77833
  );
@@ -77781,7 +77859,7 @@ function paginateArgs(config2, filepath) {
77781
77859
  const backwards = appliedArgs.has("last");
77782
77860
  if (!forward && !backwards) {
77783
77861
  ctx.reportError(
77784
- new graphql29.GraphQLError(
77862
+ new graphql30.GraphQLError(
77785
77863
  "A field with cursor-based pagination must have a first or last argument"
77786
77864
  )
77787
77865
  );
@@ -77795,7 +77873,7 @@ function paginateArgs(config2, filepath) {
77795
77873
  }
77796
77874
  if (forward && backwards && paginateMode === "Infinite") {
77797
77875
  ctx.reportError(
77798
- new graphql29.GraphQLError(
77876
+ new graphql30.GraphQLError(
77799
77877
  `A field with cursor pagination cannot go forwards an backwards simultaneously`
77800
77878
  )
77801
77879
  );
@@ -77809,7 +77887,7 @@ function paginateArgs(config2, filepath) {
77809
77887
  );
77810
77888
  if (!appliedLimitArg) {
77811
77889
  ctx.reportError(
77812
- new graphql29.GraphQLError(
77890
+ new graphql30.GraphQLError(
77813
77891
  "A field with offset-based pagination must have a limit argument"
77814
77892
  )
77815
77893
  );
@@ -77825,20 +77903,20 @@ function noUnusedFragmentArguments(config2) {
77825
77903
  const args = /* @__PURE__ */ new Set();
77826
77904
  return {
77827
77905
  enter(node) {
77828
- if (node.kind === graphql29.Kind.FRAGMENT_DEFINITION) {
77906
+ if (node.kind === graphql30.Kind.FRAGMENT_DEFINITION) {
77829
77907
  const definitionArguments = node.directives?.filter((directive) => directive.name.value === config2.argumentsDirective).flatMap((directive) => directive.arguments);
77830
77908
  for (const arg of definitionArguments?.map((arg2) => arg2?.name.value) || []) {
77831
77909
  args.add(arg);
77832
77910
  }
77833
- } else if (node.kind === graphql29.Kind.VARIABLE) {
77911
+ } else if (node.kind === graphql30.Kind.VARIABLE) {
77834
77912
  args.delete(node.name.value);
77835
77913
  }
77836
77914
  },
77837
77915
  leave(node) {
77838
- if (node.kind === graphql29.Kind.FRAGMENT_DEFINITION) {
77916
+ if (node.kind === graphql30.Kind.FRAGMENT_DEFINITION) {
77839
77917
  if (args.size > 0) {
77840
77918
  ctx.reportError(
77841
- new graphql29.GraphQLError(
77919
+ new graphql30.GraphQLError(
77842
77920
  "Encountered unused fragment arguments: " + [...args].join(",")
77843
77921
  )
77844
77922
  );
@@ -77874,7 +77952,7 @@ function nodeDirectives(config2, directives) {
77874
77952
  if (definition.kind === "OperationDefinition") {
77875
77953
  if (definition.operation !== "query") {
77876
77954
  ctx.reportError(
77877
- new graphql29.GraphQLError(
77955
+ new graphql30.GraphQLError(
77878
77956
  `@${node.name.value} must fall on a fragment or query document`
77879
77957
  )
77880
77958
  );
@@ -77886,7 +77964,7 @@ function nodeDirectives(config2, directives) {
77886
77964
  }
77887
77965
  if (!possibleNodes.includes(definitionType)) {
77888
77966
  ctx.reportError(
77889
- new graphql29.GraphQLError(paginateOnNonNodeMessage(node.name.value))
77967
+ new graphql30.GraphQLError(paginateOnNonNodeMessage(node.name.value))
77890
77968
  );
77891
77969
  }
77892
77970
  }
@@ -77905,7 +77983,7 @@ function checkMutationOperation(config2) {
77905
77983
  );
77906
77984
  if (append && prepend) {
77907
77985
  ctx.reportError(
77908
- new graphql29.GraphQLError(
77986
+ new graphql30.GraphQLError(
77909
77987
  `You can't apply both @${config2.listPrependDirective} and @${config2.listAppendDirective} at the same time`
77910
77988
  )
77911
77989
  );
@@ -77919,7 +77997,7 @@ function checkMutationOperation(config2) {
77919
77997
  );
77920
77998
  if (parentId && allLists) {
77921
77999
  ctx.reportError(
77922
- new graphql29.GraphQLError(
78000
+ new graphql30.GraphQLError(
77923
78001
  `You can't apply both @${config2.listParentDirective} and @${config2.listAllListsDirective} at the same time`
77924
78002
  )
77925
78003
  );
@@ -77941,7 +78019,7 @@ function checkMaskDirectives(config2) {
77941
78019
  );
77942
78020
  if (maskEnableDirective && maskDisableDirective) {
77943
78021
  ctx.reportError(
77944
- new graphql29.GraphQLError(
78022
+ new graphql30.GraphQLError(
77945
78023
  `You can't apply both @${config2.maskEnableDirective} and @${config2.maskDisableDirective} at the same time`
77946
78024
  )
77947
78025
  );
@@ -77983,7 +78061,7 @@ function validateLoadingDirective(config2) {
77983
78061
  );
77984
78062
  if (!parentLoading && !global2) {
77985
78063
  ctx.reportError(
77986
- new graphql29.GraphQLError(
78064
+ new graphql30.GraphQLError(
77987
78065
  `@${config2.loadingDirective} can only be applied on a field or fragment spread at the root of a document or on one whose parent also has @${config2.loadingDirective}`
77988
78066
  )
77989
78067
  );
@@ -78005,7 +78083,7 @@ function validateLoadingDirective(config2) {
78005
78083
  );
78006
78084
  if (!parentLoading && !global2) {
78007
78085
  ctx.reportError(
78008
- new graphql29.GraphQLError(
78086
+ new graphql30.GraphQLError(
78009
78087
  `@${config2.loadingDirective} can only be applied on a field or fragment spread at the root of a document or on one whose parent also has @${config2.loadingDirective}`
78010
78088
  )
78011
78089
  );
@@ -78020,7 +78098,7 @@ function getAndVerifyNodeInterface(config2) {
78020
78098
  if (!nodeInterface) {
78021
78099
  return null;
78022
78100
  }
78023
- if (!graphql29.isInterfaceType(nodeInterface)) {
78101
+ if (!graphql30.isInterfaceType(nodeInterface)) {
78024
78102
  displayInvalidNodeFieldMessage(config2);
78025
78103
  return null;
78026
78104
  }
@@ -78115,11 +78193,11 @@ async function uniqueDocumentNames(config2, docs) {
78115
78193
  }
78116
78194
 
78117
78195
  // src/codegen/validators/noIDAlias.ts
78118
- import * as graphql30 from "graphql";
78196
+ import * as graphql31 from "graphql";
78119
78197
  async function noIDAlias(config2, docs) {
78120
78198
  const errors = [];
78121
78199
  for (const { filename, document } of docs) {
78122
- graphql30.visit(document, {
78200
+ graphql31.visit(document, {
78123
78201
  Field(node, _, __, ___, ancestors) {
78124
78202
  const fieldType = parentTypeFromAncestors(config2.schema, filename, ancestors).name;
78125
78203
  if (config2.keyFieldsForType(fieldType).includes(node.alias?.value || "")) {
@@ -78158,11 +78236,11 @@ async function validatePlugins(config2, documents) {
78158
78236
  }
78159
78237
 
78160
78238
  // src/codegen/validators/componentFields.ts
78161
- import * as graphql31 from "graphql";
78239
+ import * as graphql32 from "graphql";
78162
78240
  async function componentFields2(config2, docs) {
78163
78241
  const errors = [];
78164
78242
  for (const { filename: filepath, document } of docs) {
78165
- graphql31.visit(document, {
78243
+ graphql32.visit(document, {
78166
78244
  FragmentDefinition(node, _, __, ___, ancestors) {
78167
78245
  const componentFieldDirective = node.directives?.find(
78168
78246
  (dir) => dir.name.value === config2.componentFieldDirective
@@ -78204,14 +78282,26 @@ async function componentFields2(config2, docs) {
78204
78282
  }
78205
78283
  const fieldValue = fieldArg.value?.kind === "StringValue" ? fieldArg.value.value : void 0;
78206
78284
  const propValue = propArg.value?.kind === "StringValue" ? propArg.value.value : void 0;
78285
+ const existingField = fieldValue && config2.componentFields[parent2]?.[fieldValue];
78207
78286
  const parentType = config2.schema.getType(parent2);
78208
- if (parentType && fieldValue && (graphql31.isObjectType(parentType) && parentType.getFields()[fieldValue] || config2.componentFields[parent2]?.[fieldValue])) {
78287
+ let conflict = false;
78288
+ if (existingField && existingField.filepath !== filepath) {
78289
+ conflict = true;
78290
+ } else if (parentType && fieldValue) {
78291
+ const fieldDef = graphql32.isObjectType(parentType) && parentType.getFields()[fieldValue];
78292
+ if (fieldDef && !fieldDef.astNode?.directives?.find(
78293
+ (dir) => dir.name.value === config2.componentFieldDirective
78294
+ )) {
78295
+ conflict = true;
78296
+ }
78297
+ }
78298
+ if (conflict) {
78209
78299
  errors.push({
78210
- message: `Duplicate component field definition for ${parent2}.${fieldValue}`,
78300
+ message: `Duplicate component field definition for ${parent2}.${fieldValue}.` + (existingField ? "The conflicting component field was defined in " + existingField.filepath : ""),
78211
78301
  filepath
78212
78302
  });
78213
78303
  }
78214
- if (parentType && graphql31.isAbstractType(parentType)) {
78304
+ if (parentType && graphql32.isAbstractType(parentType)) {
78215
78305
  errors.push({
78216
78306
  message: `Cannot add component field ${parent2}.${fieldValue} because ${parent2} is an abstract type`,
78217
78307
  filepath
@@ -78277,6 +78367,7 @@ async function runPipeline2(config2, docs) {
78277
78367
  [
78278
78368
  componentFields2,
78279
78369
  graphqlExtensions,
78370
+ addTypename2,
78280
78371
  ...wrapHook(beforeValidate),
78281
78372
  typeCheck,
78282
78373
  uniqueDocumentNames,
@@ -78431,12 +78522,12 @@ async function processJSFile(config2, contents) {
78431
78522
  return documents;
78432
78523
  }
78433
78524
  async function processGraphQLDocument(config2, filepath, document) {
78434
- const parsedDoc = graphql32.parse(document);
78525
+ const parsedDoc = graphql33.parse(document);
78435
78526
  const operations = parsedDoc.definitions.filter(
78436
- ({ kind: kind2 }) => kind2 === graphql32.Kind.OPERATION_DEFINITION
78527
+ ({ kind: kind2 }) => kind2 === graphql33.Kind.OPERATION_DEFINITION
78437
78528
  );
78438
78529
  const fragments = parsedDoc.definitions.filter(
78439
- ({ kind: kind2 }) => kind2 === graphql32.Kind.FRAGMENT_DEFINITION
78530
+ ({ kind: kind2 }) => kind2 === graphql33.Kind.FRAGMENT_DEFINITION
78440
78531
  );
78441
78532
  if (operations.length > 1) {
78442
78533
  throw new HoudiniError({