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.
@@ -24851,7 +24851,7 @@ var require_path_visitor = __commonJS({
24851
24851
  }
24852
24852
  return target;
24853
24853
  }
24854
- PathVisitor.visit = function visit18(node, methods) {
24854
+ PathVisitor.visit = function visit19(node, methods) {
24855
24855
  return PathVisitor.fromMethodsObject(methods).visit(node);
24856
24856
  };
24857
24857
  var PVp = PathVisitor.prototype;
@@ -25042,7 +25042,7 @@ var require_path_visitor = __commonJS({
25042
25042
  this.needToCallTraverse = false;
25043
25043
  return visitChildren(path2, PathVisitor.fromMethodsObject(newVisitor || this.visitor));
25044
25044
  };
25045
- sharedContextProtoMethods.visit = function visit18(path2, newVisitor) {
25045
+ sharedContextProtoMethods.visit = function visit19(path2, newVisitor) {
25046
25046
  if (!(this instanceof this.Context)) {
25047
25047
  throw new Error("");
25048
25048
  }
@@ -26435,7 +26435,7 @@ var require_main = __commonJS({
26435
26435
  var someField = _a.someField;
26436
26436
  var Type = _a.Type;
26437
26437
  var use = _a.use;
26438
- var visit18 = _a.visit;
26438
+ var visit19 = _a.visit;
26439
26439
  exports.astNodesAreEquivalent = astNodesAreEquivalent;
26440
26440
  exports.builders = builders;
26441
26441
  exports.builtInTypes = builtInTypes;
@@ -26452,7 +26452,7 @@ var require_main = __commonJS({
26452
26452
  exports.someField = someField;
26453
26453
  exports.Type = Type;
26454
26454
  exports.use = use;
26455
- exports.visit = visit18;
26455
+ exports.visit = visit19;
26456
26456
  Object.assign(namedTypes_1.namedTypes, n);
26457
26457
  }
26458
26458
  });
@@ -53825,10 +53825,10 @@ var require_lib6 = __commonJS({
53825
53825
 
53826
53826
  // src/test/index.ts
53827
53827
  var import_memfs2 = __toESM(require_lib(), 1);
53828
- import * as graphql33 from "graphql";
53828
+ import * as graphql34 from "graphql";
53829
53829
 
53830
53830
  // src/codegen/index.ts
53831
- import * as graphql32 from "graphql";
53831
+ import * as graphql33 from "graphql";
53832
53832
 
53833
53833
  // src/lib/pipeline.ts
53834
53834
  async function runPipeline(config, pipeline, target) {
@@ -56703,8 +56703,22 @@ var query = documentPlugin(ArtifactKind.Query, function() {
56703
56703
  let lastVariables = null;
56704
56704
  return {
56705
56705
  start(ctx, { next }) {
56706
+ const runtimeScalarPayload = {
56707
+ session: ctx.session
56708
+ };
56706
56709
  ctx.variables = {
56707
56710
  ...lastVariables,
56711
+ ...Object.fromEntries(
56712
+ Object.entries(ctx.artifact.input?.runtimeScalars ?? {}).map(
56713
+ ([field, type]) => {
56714
+ const runtimeScalar = ctx.config.features?.runtimeScalars?.[type];
56715
+ if (!runtimeScalar) {
56716
+ return [field, type];
56717
+ }
56718
+ return [field, runtimeScalar.resolve(runtimeScalarPayload)];
56719
+ }
56720
+ )
56721
+ ),
56708
56722
  ...ctx.variables
56709
56723
  };
56710
56724
  next(ctx);
@@ -57284,6 +57298,9 @@ var Config = class {
57284
57298
  get loadingDirective() {
57285
57299
  return `loading`;
57286
57300
  }
57301
+ get runtimeScalarDirective() {
57302
+ return "__houdini__runtimeScalar";
57303
+ }
57287
57304
  get whenDirective() {
57288
57305
  return "when";
57289
57306
  }
@@ -57354,7 +57371,7 @@ var Config = class {
57354
57371
  const internalDirectives = this.#newSchemaInstance?.getDirectives().reduce((list, directive) => {
57355
57372
  return list.concat(directive.name);
57356
57373
  }, []) ?? [];
57357
- return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name));
57374
+ return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name) || name === this.runtimeScalarDirective);
57358
57375
  }
57359
57376
  get componentFieldDirective() {
57360
57377
  return "componentField";
@@ -57637,7 +57654,7 @@ function unwrapType(config, type, wrappers = []) {
57637
57654
  }
57638
57655
  const namedType = config.schema.getType(type.name.value || type.name);
57639
57656
  if (!namedType) {
57640
- throw new Error("Could not unwrap type: " + JSON.stringify(type));
57657
+ throw new Error("Unknown type: " + type.name.value || type.name);
57641
57658
  }
57642
57659
  return { type: namedType, wrappers };
57643
57660
  }
@@ -58750,7 +58767,7 @@ ${exportDefaultFrom(`./${doc.name}`, doc.name)}`,
58750
58767
 
58751
58768
  // src/codegen/generators/artifacts/inputs.ts
58752
58769
  import * as graphql8 from "graphql";
58753
- function inputObject(config, inputs) {
58770
+ function inputObject(config, inputs, runtimeScalars) {
58754
58771
  const visitedTypes = /* @__PURE__ */ new Set();
58755
58772
  const inputObj = {
58756
58773
  fields: inputs.reduce((fields, input) => {
@@ -58766,7 +58783,8 @@ function inputObject(config, inputs) {
58766
58783
  ...fields,
58767
58784
  [input.variable.name.value]: input.defaultValue ? variableValue(input.defaultValue, {}) : void 0
58768
58785
  };
58769
- }, {})
58786
+ }, {}),
58787
+ runtimeScalars
58770
58788
  };
58771
58789
  for (const input of inputs) {
58772
58790
  walkInputs(config, visitedTypes, inputObj, input.type);
@@ -60609,7 +60627,21 @@ function artifactGenerator(stats) {
60609
60627
  artifact.pluginData[plugin2.name] = plugin2.artifactData({ config, document: doc }) ?? {};
60610
60628
  }
60611
60629
  if (inputs && inputs.length > 0) {
60612
- artifact.input = inputObject(config, inputs);
60630
+ const runtimeScalars = inputs.reduce((prev, input) => {
60631
+ const runtimeScalarDirective = input.directives?.find(
60632
+ (directive2) => directive2.name.value === config.runtimeScalarDirective
60633
+ );
60634
+ if (!runtimeScalarDirective) {
60635
+ return prev;
60636
+ }
60637
+ return {
60638
+ ...prev,
60639
+ [input.variable.name.value]: runtimeScalarDirective.arguments?.find(
60640
+ (arg) => arg.name.value === "type"
60641
+ )?.value?.value
60642
+ };
60643
+ }, {});
60644
+ artifact.input = inputObject(config, inputs, runtimeScalars);
60613
60645
  }
60614
60646
  if (artifact.kind === "HoudiniQuery") {
60615
60647
  const cacheDirective = operations[0].directives?.find(
@@ -61701,17 +61733,20 @@ export * from "${module}"
61701
61733
  }
61702
61734
  }
61703
61735
  await fs_exports.writeFile(config.typeIndexPath, indexContent);
61704
- if (missingScalars.size > 0) {
61705
- console.warn(`\u26A0\uFE0F Missing definitions for the following scalars: ${[...missingScalars].join(
61706
- ", "
61707
- )}
61736
+ const missingScalarNames = [...missingScalars].filter(
61737
+ (scalar) => !config.configFile.features?.runtimeScalars?.[scalar]
61738
+ );
61739
+ if (missingScalarNames.length > 0) {
61740
+ console.warn(`\u26A0\uFE0F Missing definitions for the following scalars: ${[
61741
+ ...missingScalarNames
61742
+ ].join(", ")}
61708
61743
  Generated types will contain an any type in place of these values. To fix this, provide an equivalent
61709
61744
  type in your config file:
61710
61745
 
61711
61746
  {
61712
61747
  scalars: {
61713
61748
  ${cyan2(`/* in your case, something like */`)}
61714
- ${[...missingScalars].map(
61749
+ ${[...missingScalarNames].map(
61715
61750
  (c) => ` ${c}: { ${green2(`// <- The GraphQL Scalar`)}
61716
61751
  type: "${cyan2(`YourType_${c}`)}" ${green2(`// <- The TypeScript type`)}
61717
61752
  }`
@@ -64293,7 +64328,7 @@ ${config.configFile.features?.componentFields ? `
64293
64328
  """
64294
64329
  @${config.componentFieldDirective} marks an inline fragment as the selection for a component field
64295
64330
  """
64296
- directive @${config.componentFieldDirective}(field: String!, prop: String, export: String, raw: String) on FRAGMENT_DEFINITION | INLINE_FRAGMENT
64331
+ directive @${config.componentFieldDirective}(field: String!, prop: String, export: String, raw: String) on FRAGMENT_DEFINITION | INLINE_FRAGMENT | FIELD_DEFINITION
64297
64332
 
64298
64333
  ` : ""}
64299
64334
 
@@ -64304,7 +64339,7 @@ directive @${config.componentFieldDirective}(field: String!, prop: String, expor
64304
64339
  }
64305
64340
  internalSchema += plugin2.schema({ config });
64306
64341
  }
64307
- const extensions = Object.entries(config.componentFields).map(([parent2, fields]) => {
64342
+ let extensions = Object.entries(config.componentFields).map(([parent2, fields]) => {
64308
64343
  return `
64309
64344
  extend type ${parent2} {
64310
64345
  ${Object.entries(fields).map(([fieldName, field]) => {
@@ -64316,11 +64351,12 @@ directive @${config.componentFieldDirective}(field: String!, prop: String, expor
64316
64351
  return `${arg.name}:${typeName}${arg.required ? "!" : ""}`;
64317
64352
  }).join("\n") + ")";
64318
64353
  }
64319
- return `${fieldName}${argString}: ${config.componentScalar}!`;
64354
+ return `${fieldName}${argString}: ${config.componentScalar}! @componentField(field: "${fieldName}")`;
64320
64355
  }).join("\n")}
64321
64356
  }
64322
64357
  `;
64323
64358
  }).join("\n");
64359
+ extensions += `${Object.keys(config.configFile.features?.runtimeScalars ?? {}).map((scalar) => `scalar ${scalar}`).join("\n")}`;
64324
64360
  config.newSchema = graphql25.print(mergeTypeDefs([internalSchema, config.newSchema]));
64325
64361
  config.schemaString += extensions;
64326
64362
  config.schema = graphql25.buildSchema(
@@ -64515,8 +64551,50 @@ async function componentFields(config, documents) {
64515
64551
  }
64516
64552
  }
64517
64553
 
64518
- // src/codegen/validators/typeCheck.ts
64554
+ // src/codegen/transforms/runtimeScalars.ts
64519
64555
  import * as graphql29 from "graphql";
64556
+ async function addTypename2(config, documents) {
64557
+ for (const doc of documents) {
64558
+ doc.document = graphql29.visit(doc.document, {
64559
+ VariableDefinition(node) {
64560
+ const { type, wrappers } = unwrapType(config, node.type);
64561
+ const runtimeScalar = config.configFile.features?.runtimeScalars?.[type.name];
64562
+ if (runtimeScalar) {
64563
+ return {
64564
+ ...node,
64565
+ type: wrapType({
64566
+ type: config.schema.getType(runtimeScalar.type),
64567
+ wrappers
64568
+ }),
64569
+ directives: [
64570
+ ...node.directives ?? [],
64571
+ {
64572
+ kind: "Directive",
64573
+ name: {
64574
+ kind: "Name",
64575
+ value: config.runtimeScalarDirective
64576
+ },
64577
+ arguments: [
64578
+ {
64579
+ kind: "Argument",
64580
+ name: { kind: "Name", value: "type" },
64581
+ value: {
64582
+ kind: "StringValue",
64583
+ value: type.name
64584
+ }
64585
+ }
64586
+ ]
64587
+ }
64588
+ ]
64589
+ };
64590
+ }
64591
+ }
64592
+ });
64593
+ }
64594
+ }
64595
+
64596
+ // src/codegen/validators/typeCheck.ts
64597
+ import * as graphql30 from "graphql";
64520
64598
  async function typeCheck(config, docs) {
64521
64599
  const errors = [];
64522
64600
  const freeLists = [];
@@ -64524,7 +64602,7 @@ async function typeCheck(config, docs) {
64524
64602
  const listTypes = [];
64525
64603
  const fragments = {};
64526
64604
  for (const { document: parsed, originalString, filename } of docs) {
64527
- graphql29.visit(parsed, {
64605
+ graphql30.visit(parsed, {
64528
64606
  FragmentDefinition(definition) {
64529
64607
  fragments[definition.name.value] = definition;
64530
64608
  },
@@ -64569,14 +64647,14 @@ async function typeCheck(config, docs) {
64569
64647
  );
64570
64648
  return;
64571
64649
  }
64572
- if (graphql29.isListType(rootType) || graphql29.isNonNullType(rootType) && graphql29.isListType(rootType.ofType)) {
64650
+ if (graphql30.isListType(rootType) || graphql30.isNonNullType(rootType) && graphql30.isListType(rootType.ofType)) {
64573
64651
  needsParent = true;
64574
64652
  break;
64575
64653
  }
64576
- if (graphql29.isNonNullType(rootType) && "ofType" in rootType) {
64654
+ if (graphql30.isNonNullType(rootType) && "ofType" in rootType) {
64577
64655
  rootType = rootType.ofType;
64578
64656
  }
64579
- if (graphql29.isScalarType(rootType)) {
64657
+ if (graphql30.isScalarType(rootType)) {
64580
64658
  break;
64581
64659
  }
64582
64660
  rootType = rootType?.getFields()[parent3.name.value]?.type;
@@ -64652,9 +64730,9 @@ async function typeCheck(config, docs) {
64652
64730
  );
64653
64731
  }
64654
64732
  let targetTypes = [type];
64655
- if (graphql29.isUnionType(type)) {
64733
+ if (graphql30.isUnionType(type)) {
64656
64734
  targetTypes = config.schema.getPossibleTypes(type);
64657
- } else if (graphql29.isInterfaceType(type)) {
64735
+ } else if (graphql30.isInterfaceType(type)) {
64658
64736
  try {
64659
64737
  for (const key of config.keyFieldsForType(type.name)) {
64660
64738
  if (!type.getFields()[key]) {
@@ -64690,13 +64768,13 @@ async function typeCheck(config, docs) {
64690
64768
  if (errors.length > 0) {
64691
64769
  throw errors;
64692
64770
  }
64693
- const rules = (filepath) => [...graphql29.specifiedRules].filter(
64771
+ const rules = (filepath) => [...graphql30.specifiedRules].filter(
64694
64772
  (rule) => ![
64695
- graphql29.NoUnusedFragmentsRule,
64696
- graphql29.KnownFragmentNamesRule,
64697
- graphql29.ExecutableDefinitionsRule,
64698
- graphql29.KnownDirectivesRule,
64699
- graphql29.KnownArgumentNamesRule
64773
+ graphql30.NoUnusedFragmentsRule,
64774
+ graphql30.KnownFragmentNamesRule,
64775
+ graphql30.ExecutableDefinitionsRule,
64776
+ graphql30.KnownDirectivesRule,
64777
+ graphql30.KnownArgumentNamesRule
64700
64778
  ].includes(rule)
64701
64779
  ).concat(
64702
64780
  validateLists({
@@ -64717,7 +64795,7 @@ async function typeCheck(config, docs) {
64717
64795
  validateLoadingDirective(config)
64718
64796
  );
64719
64797
  for (const { filename, document: parsed, originalString } of docs) {
64720
- for (const error of graphql29.validate(config.schema, parsed, rules(filename))) {
64798
+ for (const error of graphql30.validate(config.schema, parsed, rules(filename))) {
64721
64799
  errors.push(
64722
64800
  new HoudiniError({
64723
64801
  filepath: filename,
@@ -64746,20 +64824,20 @@ function validateRequiredDirective(config, filepath) {
64746
64824
  if (!node.directives?.some(({ name }) => name.value === config.requiredDirective))
64747
64825
  return;
64748
64826
  const parentType = parentTypeFromAncestors(config.schema, filepath, ancestors);
64749
- if (!graphql29.isObjectType(parentType)) {
64827
+ if (!graphql30.isObjectType(parentType)) {
64750
64828
  ctx.reportError(
64751
- new graphql29.GraphQLError(
64829
+ new graphql30.GraphQLError(
64752
64830
  `@${config.requiredDirective} may only be used on objects, not arguments`
64753
64831
  )
64754
64832
  );
64755
64833
  return;
64756
64834
  }
64757
64835
  const type = parentType.getFields()[node.name.value].type;
64758
- const isServerNullable = !graphql29.isNonNullType(type);
64836
+ const isServerNullable = !graphql30.isNonNullType(type);
64759
64837
  const isAlreadyClientNullable = isClientNullable(node, true);
64760
64838
  if (!isServerNullable && !isAlreadyClientNullable) {
64761
64839
  ctx.reportError(
64762
- new graphql29.GraphQLError(
64840
+ new graphql30.GraphQLError(
64763
64841
  `@${config.requiredDirective} may only be used on nullable fields`
64764
64842
  )
64765
64843
  );
@@ -64781,7 +64859,7 @@ var validateLists = ({
64781
64859
  if (!config.isListFragment(node.name.value)) {
64782
64860
  if (!fragments[node.name.value]) {
64783
64861
  ctx.reportError(
64784
- new graphql29.GraphQLError(
64862
+ new graphql30.GraphQLError(
64785
64863
  "Encountered unknown fragment: " + node.name.value
64786
64864
  )
64787
64865
  );
@@ -64791,7 +64869,7 @@ var validateLists = ({
64791
64869
  const listName = config.listNameFromFragment(node.name.value);
64792
64870
  if (!lists.includes(listName)) {
64793
64871
  ctx.reportError(
64794
- new graphql29.GraphQLError(
64872
+ new graphql30.GraphQLError(
64795
64873
  "Encountered fragment referencing unknown list: " + listName
64796
64874
  )
64797
64875
  );
@@ -64816,7 +64894,7 @@ var validateLists = ({
64816
64894
  );
64817
64895
  if (parentArg) {
64818
64896
  ctx.reportError(
64819
- new graphql29.GraphQLError(
64897
+ new graphql30.GraphQLError(
64820
64898
  `@${config.deprecatedlistDirectiveParentIDArg} should be defined only in it's own directive now`
64821
64899
  )
64822
64900
  );
@@ -64832,7 +64910,7 @@ var validateLists = ({
64832
64910
  return;
64833
64911
  }
64834
64912
  ctx.reportError(
64835
- new graphql29.GraphQLError(
64913
+ new graphql30.GraphQLError(
64836
64914
  `For this list fragment, you need to add or @${config.listParentDirective} or @${config.listAllListsDirective} directive to specify the behavior`
64837
64915
  )
64838
64916
  );
@@ -64842,7 +64920,7 @@ var validateLists = ({
64842
64920
  const directiveName = node.name.value;
64843
64921
  if (directiveName === "connection") {
64844
64922
  ctx.reportError(
64845
- new graphql29.GraphQLError(
64923
+ new graphql30.GraphQLError(
64846
64924
  "@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."
64847
64925
  )
64848
64926
  );
@@ -64851,7 +64929,7 @@ var validateLists = ({
64851
64929
  if (!config.isInternalDirective(node.name.value)) {
64852
64930
  if (!config.schema.getDirective(directiveName)) {
64853
64931
  ctx.reportError(
64854
- new graphql29.GraphQLError(
64932
+ new graphql30.GraphQLError(
64855
64933
  "Encountered unknown directive: " + directiveName
64856
64934
  )
64857
64935
  );
@@ -64860,7 +64938,7 @@ var validateLists = ({
64860
64938
  }
64861
64939
  if (config.isListOperationDirective(directiveName) && !listTypes.includes(config.listNameFromDirective(directiveName))) {
64862
64940
  ctx.reportError(
64863
- new graphql29.GraphQLError(
64941
+ new graphql30.GraphQLError(
64864
64942
  "Encountered directive referencing unknown list: " + directiveName
64865
64943
  )
64866
64944
  );
@@ -64871,7 +64949,7 @@ var validateLists = ({
64871
64949
  };
64872
64950
  function knownArguments(config) {
64873
64951
  return function(ctx) {
64874
- const nativeValidator = graphql29.KnownArgumentNamesRule(ctx);
64952
+ const nativeValidator = graphql30.KnownArgumentNamesRule(ctx);
64875
64953
  return {
64876
64954
  ...nativeValidator,
64877
64955
  Directive(directiveNode) {
@@ -64906,7 +64984,7 @@ function validateFragmentArguments(config, filepath, fragments) {
64906
64984
  for (const arg of node.arguments || []) {
64907
64985
  if (arg.value.kind !== "ObjectValue") {
64908
64986
  ctx.reportError(
64909
- new graphql29.GraphQLError("values in @arguments must be an object")
64987
+ new graphql30.GraphQLError("values in @arguments must be an object")
64910
64988
  );
64911
64989
  return;
64912
64990
  }
@@ -64916,13 +64994,13 @@ function validateFragmentArguments(config, filepath, fragments) {
64916
64994
  );
64917
64995
  if (!typeArg) {
64918
64996
  ctx.reportError(
64919
- new graphql29.GraphQLError("missing type field for @arguments directive")
64997
+ new graphql30.GraphQLError("missing type field for @arguments directive")
64920
64998
  );
64921
64999
  return;
64922
65000
  }
64923
- if (typeArg.value.kind !== graphql29.Kind.STRING) {
65001
+ if (typeArg.value.kind !== graphql30.Kind.STRING) {
64924
65002
  ctx.reportError(
64925
- new graphql29.GraphQLError("type field to @arguments must be a string")
65003
+ new graphql30.GraphQLError("type field to @arguments must be a string")
64926
65004
  );
64927
65005
  return;
64928
65006
  }
@@ -64935,7 +65013,7 @@ function validateFragmentArguments(config, filepath, fragments) {
64935
65013
  );
64936
65014
  if (typeArg.value.value !== defaultValueType) {
64937
65015
  ctx.reportError(
64938
- new graphql29.GraphQLError(
65016
+ new graphql30.GraphQLError(
64939
65017
  `Invalid default value provided for ${arg.name.value}. Expected ${typeArg.value.value}, found ${defaultValueType}`
64940
65018
  )
64941
65019
  );
@@ -64953,7 +65031,7 @@ function validateFragmentArguments(config, filepath, fragments) {
64953
65031
  try {
64954
65032
  args = fragmentArguments(config, filepath, fragments[fragmentName]);
64955
65033
  } catch (e) {
64956
- ctx.reportError(new graphql29.GraphQLError(e.message));
65034
+ ctx.reportError(new graphql30.GraphQLError(e.message));
64957
65035
  return;
64958
65036
  }
64959
65037
  fragmentArguments2[fragmentName] = args;
@@ -64976,7 +65054,7 @@ function validateFragmentArguments(config, filepath, fragments) {
64976
65054
  );
64977
65055
  if (missing.length > 0) {
64978
65056
  ctx.reportError(
64979
- new graphql29.GraphQLError(
65057
+ new graphql30.GraphQLError(
64980
65058
  `The following arguments are missing from the "${fragmentName}" fragment: ` + JSON.stringify(missing)
64981
65059
  )
64982
65060
  );
@@ -64987,7 +65065,7 @@ function validateFragmentArguments(config, filepath, fragments) {
64987
65065
  );
64988
65066
  if (unknown.length > 0) {
64989
65067
  ctx.reportError(
64990
- new graphql29.GraphQLError(
65068
+ new graphql30.GraphQLError(
64991
65069
  "Encountered unknown arguments: " + JSON.stringify(unknown)
64992
65070
  )
64993
65071
  );
@@ -64999,7 +65077,7 @@ function validateFragmentArguments(config, filepath, fragments) {
64999
65077
  for (const [applied, target] of zipped) {
65000
65078
  if (!valueIsType(config, applied.value, target)) {
65001
65079
  ctx.reportError(
65002
- new graphql29.GraphQLError(
65080
+ new graphql30.GraphQLError(
65003
65081
  `Invalid argument type. Expected ${target}, found ${applied.value.kind}`
65004
65082
  )
65005
65083
  );
@@ -65041,7 +65119,7 @@ function valueIsType(config, value, targetType) {
65041
65119
  }
65042
65120
  if (value.kind === "EnumValue" && targetType.kind === "NamedType") {
65043
65121
  const enumType = config.schema.getType(targetType.name.value);
65044
- if (!graphql29.isEnumType(enumType)) {
65122
+ if (!graphql30.isEnumType(enumType)) {
65045
65123
  return false;
65046
65124
  }
65047
65125
  return enumType.getValues().some((enumValue) => enumValue.value === value.value);
@@ -65061,7 +65139,7 @@ function paginateArgs(config, filepath) {
65061
65139
  }
65062
65140
  if (alreadyPaginated) {
65063
65141
  ctx.reportError(
65064
- new graphql29.GraphQLError(
65142
+ new graphql30.GraphQLError(
65065
65143
  `@${config.paginateDirective} can only appear in a document once.`
65066
65144
  )
65067
65145
  );
@@ -65093,7 +65171,7 @@ function paginateArgs(config, filepath) {
65093
65171
  const backwards = appliedArgs.has("last");
65094
65172
  if (!forward && !backwards) {
65095
65173
  ctx.reportError(
65096
- new graphql29.GraphQLError(
65174
+ new graphql30.GraphQLError(
65097
65175
  "A field with cursor-based pagination must have a first or last argument"
65098
65176
  )
65099
65177
  );
@@ -65107,7 +65185,7 @@ function paginateArgs(config, filepath) {
65107
65185
  }
65108
65186
  if (forward && backwards && paginateMode === "Infinite") {
65109
65187
  ctx.reportError(
65110
- new graphql29.GraphQLError(
65188
+ new graphql30.GraphQLError(
65111
65189
  `A field with cursor pagination cannot go forwards an backwards simultaneously`
65112
65190
  )
65113
65191
  );
@@ -65121,7 +65199,7 @@ function paginateArgs(config, filepath) {
65121
65199
  );
65122
65200
  if (!appliedLimitArg) {
65123
65201
  ctx.reportError(
65124
- new graphql29.GraphQLError(
65202
+ new graphql30.GraphQLError(
65125
65203
  "A field with offset-based pagination must have a limit argument"
65126
65204
  )
65127
65205
  );
@@ -65137,20 +65215,20 @@ function noUnusedFragmentArguments(config) {
65137
65215
  const args = /* @__PURE__ */ new Set();
65138
65216
  return {
65139
65217
  enter(node) {
65140
- if (node.kind === graphql29.Kind.FRAGMENT_DEFINITION) {
65218
+ if (node.kind === graphql30.Kind.FRAGMENT_DEFINITION) {
65141
65219
  const definitionArguments = node.directives?.filter((directive) => directive.name.value === config.argumentsDirective).flatMap((directive) => directive.arguments);
65142
65220
  for (const arg of definitionArguments?.map((arg2) => arg2?.name.value) || []) {
65143
65221
  args.add(arg);
65144
65222
  }
65145
- } else if (node.kind === graphql29.Kind.VARIABLE) {
65223
+ } else if (node.kind === graphql30.Kind.VARIABLE) {
65146
65224
  args.delete(node.name.value);
65147
65225
  }
65148
65226
  },
65149
65227
  leave(node) {
65150
- if (node.kind === graphql29.Kind.FRAGMENT_DEFINITION) {
65228
+ if (node.kind === graphql30.Kind.FRAGMENT_DEFINITION) {
65151
65229
  if (args.size > 0) {
65152
65230
  ctx.reportError(
65153
- new graphql29.GraphQLError(
65231
+ new graphql30.GraphQLError(
65154
65232
  "Encountered unused fragment arguments: " + [...args].join(",")
65155
65233
  )
65156
65234
  );
@@ -65186,7 +65264,7 @@ function nodeDirectives(config, directives) {
65186
65264
  if (definition.kind === "OperationDefinition") {
65187
65265
  if (definition.operation !== "query") {
65188
65266
  ctx.reportError(
65189
- new graphql29.GraphQLError(
65267
+ new graphql30.GraphQLError(
65190
65268
  `@${node.name.value} must fall on a fragment or query document`
65191
65269
  )
65192
65270
  );
@@ -65198,7 +65276,7 @@ function nodeDirectives(config, directives) {
65198
65276
  }
65199
65277
  if (!possibleNodes.includes(definitionType)) {
65200
65278
  ctx.reportError(
65201
- new graphql29.GraphQLError(paginateOnNonNodeMessage(node.name.value))
65279
+ new graphql30.GraphQLError(paginateOnNonNodeMessage(node.name.value))
65202
65280
  );
65203
65281
  }
65204
65282
  }
@@ -65217,7 +65295,7 @@ function checkMutationOperation(config) {
65217
65295
  );
65218
65296
  if (append && prepend) {
65219
65297
  ctx.reportError(
65220
- new graphql29.GraphQLError(
65298
+ new graphql30.GraphQLError(
65221
65299
  `You can't apply both @${config.listPrependDirective} and @${config.listAppendDirective} at the same time`
65222
65300
  )
65223
65301
  );
@@ -65231,7 +65309,7 @@ function checkMutationOperation(config) {
65231
65309
  );
65232
65310
  if (parentId && allLists) {
65233
65311
  ctx.reportError(
65234
- new graphql29.GraphQLError(
65312
+ new graphql30.GraphQLError(
65235
65313
  `You can't apply both @${config.listParentDirective} and @${config.listAllListsDirective} at the same time`
65236
65314
  )
65237
65315
  );
@@ -65253,7 +65331,7 @@ function checkMaskDirectives(config) {
65253
65331
  );
65254
65332
  if (maskEnableDirective && maskDisableDirective) {
65255
65333
  ctx.reportError(
65256
- new graphql29.GraphQLError(
65334
+ new graphql30.GraphQLError(
65257
65335
  `You can't apply both @${config.maskEnableDirective} and @${config.maskDisableDirective} at the same time`
65258
65336
  )
65259
65337
  );
@@ -65295,7 +65373,7 @@ function validateLoadingDirective(config) {
65295
65373
  );
65296
65374
  if (!parentLoading && !global2) {
65297
65375
  ctx.reportError(
65298
- new graphql29.GraphQLError(
65376
+ new graphql30.GraphQLError(
65299
65377
  `@${config.loadingDirective} can only be applied on a field or fragment spread at the root of a document or on one whose parent also has @${config.loadingDirective}`
65300
65378
  )
65301
65379
  );
@@ -65317,7 +65395,7 @@ function validateLoadingDirective(config) {
65317
65395
  );
65318
65396
  if (!parentLoading && !global2) {
65319
65397
  ctx.reportError(
65320
- new graphql29.GraphQLError(
65398
+ new graphql30.GraphQLError(
65321
65399
  `@${config.loadingDirective} can only be applied on a field or fragment spread at the root of a document or on one whose parent also has @${config.loadingDirective}`
65322
65400
  )
65323
65401
  );
@@ -65332,7 +65410,7 @@ function getAndVerifyNodeInterface(config) {
65332
65410
  if (!nodeInterface) {
65333
65411
  return null;
65334
65412
  }
65335
- if (!graphql29.isInterfaceType(nodeInterface)) {
65413
+ if (!graphql30.isInterfaceType(nodeInterface)) {
65336
65414
  displayInvalidNodeFieldMessage(config);
65337
65415
  return null;
65338
65416
  }
@@ -65427,11 +65505,11 @@ async function uniqueDocumentNames(config, docs) {
65427
65505
  }
65428
65506
 
65429
65507
  // src/codegen/validators/noIDAlias.ts
65430
- import * as graphql30 from "graphql";
65508
+ import * as graphql31 from "graphql";
65431
65509
  async function noIDAlias(config, docs) {
65432
65510
  const errors = [];
65433
65511
  for (const { filename, document } of docs) {
65434
- graphql30.visit(document, {
65512
+ graphql31.visit(document, {
65435
65513
  Field(node, _, __, ___, ancestors) {
65436
65514
  const fieldType = parentTypeFromAncestors(config.schema, filename, ancestors).name;
65437
65515
  if (config.keyFieldsForType(fieldType).includes(node.alias?.value || "")) {
@@ -65470,11 +65548,11 @@ async function validatePlugins(config, documents) {
65470
65548
  }
65471
65549
 
65472
65550
  // src/codegen/validators/componentFields.ts
65473
- import * as graphql31 from "graphql";
65551
+ import * as graphql32 from "graphql";
65474
65552
  async function componentFields2(config, docs) {
65475
65553
  const errors = [];
65476
65554
  for (const { filename: filepath, document } of docs) {
65477
- graphql31.visit(document, {
65555
+ graphql32.visit(document, {
65478
65556
  FragmentDefinition(node, _, __, ___, ancestors) {
65479
65557
  const componentFieldDirective = node.directives?.find(
65480
65558
  (dir) => dir.name.value === config.componentFieldDirective
@@ -65516,14 +65594,26 @@ async function componentFields2(config, docs) {
65516
65594
  }
65517
65595
  const fieldValue = fieldArg.value?.kind === "StringValue" ? fieldArg.value.value : void 0;
65518
65596
  const propValue = propArg.value?.kind === "StringValue" ? propArg.value.value : void 0;
65597
+ const existingField = fieldValue && config.componentFields[parent2]?.[fieldValue];
65519
65598
  const parentType = config.schema.getType(parent2);
65520
- if (parentType && fieldValue && (graphql31.isObjectType(parentType) && parentType.getFields()[fieldValue] || config.componentFields[parent2]?.[fieldValue])) {
65599
+ let conflict = false;
65600
+ if (existingField && existingField.filepath !== filepath) {
65601
+ conflict = true;
65602
+ } else if (parentType && fieldValue) {
65603
+ const fieldDef = graphql32.isObjectType(parentType) && parentType.getFields()[fieldValue];
65604
+ if (fieldDef && !fieldDef.astNode?.directives?.find(
65605
+ (dir) => dir.name.value === config.componentFieldDirective
65606
+ )) {
65607
+ conflict = true;
65608
+ }
65609
+ }
65610
+ if (conflict) {
65521
65611
  errors.push({
65522
- message: `Duplicate component field definition for ${parent2}.${fieldValue}`,
65612
+ message: `Duplicate component field definition for ${parent2}.${fieldValue}.` + (existingField ? "The conflicting component field was defined in " + existingField.filepath : ""),
65523
65613
  filepath
65524
65614
  });
65525
65615
  }
65526
- if (parentType && graphql31.isAbstractType(parentType)) {
65616
+ if (parentType && graphql32.isAbstractType(parentType)) {
65527
65617
  errors.push({
65528
65618
  message: `Cannot add component field ${parent2}.${fieldValue} because ${parent2} is an abstract type`,
65529
65619
  filepath
@@ -65585,6 +65675,7 @@ async function runPipeline2(config, docs) {
65585
65675
  [
65586
65676
  componentFields2,
65587
65677
  graphqlExtensions,
65678
+ addTypename2,
65588
65679
  ...wrapHook(beforeValidate),
65589
65680
  typeCheck,
65590
65681
  uniqueDocumentNames,
@@ -65986,9 +66077,15 @@ function testConfigFile({ plugins, ...config } = {}) {
65986
66077
  ...plugins
65987
66078
  },
65988
66079
  features: {
65989
- componentFields: true
66080
+ componentFields: true,
66081
+ imperativeCache: true,
66082
+ runtimeScalars: {
66083
+ ViewerIDFromSession: {
66084
+ type: "ID",
66085
+ resolve: ({ session }) => session.token
66086
+ }
66087
+ }
65990
66088
  },
65991
- acceptImperativeInstability: true,
65992
66089
  ...config
65993
66090
  };
65994
66091
  }
@@ -66006,7 +66103,7 @@ function pipelineTest(config, documents, shouldPass, testBody) {
66006
66103
  await runPipeline2(config, docs);
66007
66104
  } catch (e) {
66008
66105
  if (shouldPass) {
66009
- throw "pipeline failed when it should have passed. " + e;
66106
+ throw new Error("pipeline failed when it should have passed. " + e);
66010
66107
  }
66011
66108
  error = e;
66012
66109
  }
@@ -66019,7 +66116,7 @@ function pipelineTest(config, documents, shouldPass, testBody) {
66019
66116
  };
66020
66117
  }
66021
66118
  function mockCollectedDoc(query2, data) {
66022
- const parsed = graphql33.parse(query2);
66119
+ const parsed = graphql34.parse(query2);
66023
66120
  const name = parsed.definitions[0].name.value;
66024
66121
  const operations = parsed.definitions;
66025
66122
  let kind = ArtifactKind.Fragment;