houdini 1.0.0-next.2 → 1.0.0-next.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/build/cmd-cjs/index.js +1417 -1231
  2. package/build/cmd-esm/index.js +1417 -1231
  3. package/build/codegen/generators/artifacts/selection.d.ts +3 -3
  4. package/build/codegen/generators/typescript/documentTypes.d.ts +2 -0
  5. package/build/codegen/generators/typescript/{imperativeCache.d.ts → imperativeTypeDef.d.ts} +1 -1
  6. package/build/codegen/transforms/fragmentVariables.d.ts +1 -0
  7. package/build/codegen-cjs/index.js +1262 -1078
  8. package/build/codegen-esm/index.js +1262 -1078
  9. package/build/lib/config.d.ts +1 -1
  10. package/build/lib/walk.d.ts +4 -1
  11. package/build/lib-cjs/index.js +10 -10
  12. package/build/lib-esm/index.js +10 -10
  13. package/build/runtime/cache/cache.d.ts +3 -3
  14. package/build/runtime/cache/lists.d.ts +1 -0
  15. package/build/runtime/client/documentStore.d.ts +1 -1
  16. package/build/runtime/client/plugins/fetchParams.d.ts +1 -1
  17. package/build/runtime/generated.d.ts +1 -0
  18. package/build/runtime/index.d.ts +1 -1
  19. package/build/runtime/lib/config.d.ts +21 -22
  20. package/build/runtime/lib/scalars.d.ts +2 -2
  21. package/build/runtime/lib/types.d.ts +2 -3
  22. package/build/runtime/public/cache.d.ts +19 -6
  23. package/build/runtime/public/record.d.ts +17 -17
  24. package/build/runtime/public/tests/test.d.ts +43 -0
  25. package/build/runtime/public/types.d.ts +8 -0
  26. package/build/runtime-cjs/cache/cache.d.ts +3 -3
  27. package/build/runtime-cjs/cache/cache.js +30 -15
  28. package/build/runtime-cjs/cache/lists.d.ts +1 -0
  29. package/build/runtime-cjs/cache/lists.js +6 -3
  30. package/build/runtime-cjs/client/documentStore.d.ts +1 -1
  31. package/build/runtime-cjs/client/plugins/fetchParams.d.ts +1 -1
  32. package/build/runtime-cjs/client/plugins/fetchParams.js +6 -1
  33. package/build/runtime-cjs/client/plugins/query.js +0 -1
  34. package/build/runtime-cjs/generated.d.ts +1 -0
  35. package/build/runtime-cjs/index.d.ts +1 -1
  36. package/build/runtime-cjs/lib/config.d.ts +21 -22
  37. package/build/runtime-cjs/lib/scalars.d.ts +2 -2
  38. package/build/runtime-cjs/lib/types.d.ts +2 -3
  39. package/build/runtime-cjs/public/cache.d.ts +19 -6
  40. package/build/runtime-cjs/public/cache.js +29 -32
  41. package/build/runtime-cjs/public/list.js +6 -28
  42. package/build/runtime-cjs/public/record.d.ts +17 -17
  43. package/build/runtime-cjs/public/record.js +22 -188
  44. package/build/runtime-cjs/public/tests/test.d.ts +43 -0
  45. package/build/runtime-cjs/public/tests/test.js +27 -2
  46. package/build/runtime-cjs/public/types.d.ts +8 -0
  47. package/build/runtime-esm/cache/cache.d.ts +3 -3
  48. package/build/runtime-esm/cache/cache.js +30 -15
  49. package/build/runtime-esm/cache/lists.d.ts +1 -0
  50. package/build/runtime-esm/cache/lists.js +6 -3
  51. package/build/runtime-esm/client/documentStore.d.ts +1 -1
  52. package/build/runtime-esm/client/plugins/fetchParams.d.ts +1 -1
  53. package/build/runtime-esm/client/plugins/fetchParams.js +6 -1
  54. package/build/runtime-esm/client/plugins/query.js +0 -1
  55. package/build/runtime-esm/generated.d.ts +1 -0
  56. package/build/runtime-esm/index.d.ts +1 -1
  57. package/build/runtime-esm/lib/config.d.ts +21 -22
  58. package/build/runtime-esm/lib/scalars.d.ts +2 -2
  59. package/build/runtime-esm/lib/types.d.ts +2 -3
  60. package/build/runtime-esm/public/cache.d.ts +19 -6
  61. package/build/runtime-esm/public/cache.js +28 -30
  62. package/build/runtime-esm/public/list.js +6 -28
  63. package/build/runtime-esm/public/record.d.ts +17 -17
  64. package/build/runtime-esm/public/record.js +21 -184
  65. package/build/runtime-esm/public/tests/test.d.ts +43 -0
  66. package/build/runtime-esm/public/tests/test.js +26 -1
  67. package/build/runtime-esm/public/types.d.ts +8 -0
  68. package/build/test-cjs/index.js +1270 -1087
  69. package/build/test-esm/index.js +1270 -1087
  70. package/build/vite-cjs/index.js +1271 -1087
  71. package/build/vite-esm/index.js +1271 -1087
  72. package/package.json +1 -1
@@ -66716,8 +66716,7 @@ var Config = class {
66716
66716
  types: types17 = {},
66717
66717
  logLevel,
66718
66718
  defaultFragmentMasking = "enable",
66719
- schemaPollInterval = 2e3,
66720
- schemaPollHeaders = {},
66719
+ watchSchema,
66721
66720
  projectDir
66722
66721
  } = this.configFile;
66723
66722
  if (typeof schema === "string") {
@@ -66750,8 +66749,8 @@ var Config = class {
66750
66749
  this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
66751
66750
  this.defaultFragmentMasking = defaultFragmentMasking;
66752
66751
  this.routesDir = join2(this.projectRoot, "src", "routes");
66753
- this.schemaPollInterval = schemaPollInterval;
66754
- this.schemaPollHeaders = schemaPollHeaders;
66752
+ this.schemaPollInterval = watchSchema?.interval ?? 2e3;
66753
+ this.schemaPollHeaders = watchSchema?.headers ?? {};
66755
66754
  this.rootDir = join2(this.projectRoot, "$houdini");
66756
66755
  if (defaultKeys) {
66757
66756
  this.defaultKeys = defaultKeys;
@@ -66764,11 +66763,12 @@ var Config = class {
66764
66763
  }
66765
66764
  }
66766
66765
  async apiURL() {
66767
- if (!this.configFile.apiUrl) {
66766
+ const apiURL = this.configFile.watchSchema?.url;
66767
+ if (!apiURL) {
66768
66768
  return "";
66769
66769
  }
66770
66770
  const env = await this.getEnv();
66771
- return this.processEnvValues(env, this.configFile.apiUrl);
66771
+ return this.processEnvValues(env, apiURL);
66772
66772
  }
66773
66773
  get include() {
66774
66774
  if (this.configFile.include) {
@@ -66972,8 +66972,8 @@ var Config = class {
66972
66972
  pluginDirectory(name2) {
66973
66973
  return join2(this.pluginRootDirectory, name2);
66974
66974
  }
66975
- get manualLoadDirective() {
66976
- return "manual_load";
66975
+ get loadDirective() {
66976
+ return "load";
66977
66977
  }
66978
66978
  get maskEnableDirective() {
66979
66979
  return "mask_enable";
@@ -67090,7 +67090,7 @@ var Config = class {
67090
67090
  this.withDirective,
67091
67091
  this.paginateDirective,
67092
67092
  this.cacheDirective,
67093
- this.manualLoadDirective,
67093
+ this.loadDirective,
67094
67094
  this.maskEnableDirective,
67095
67095
  this.maskDisableDirective
67096
67096
  ].includes(name2.value) || this.isDeleteDirective(name2.value);
@@ -67675,7 +67675,7 @@ async function find_graphql(config4, parsedScript, walker) {
67675
67675
  return;
67676
67676
  }
67677
67677
  const parsedTag = graphql4.parse(documentString);
67678
- if (walker.where && !walker.where(parsedTag)) {
67678
+ if (walker.where && !walker.where(parsedTag, { node, parent })) {
67679
67679
  return;
67680
67680
  }
67681
67681
  const definition = config4.extractDefinition(parsedTag);
@@ -67716,7 +67716,7 @@ async function find_graphql(config4, parsedScript, walker) {
67716
67716
  }
67717
67717
 
67718
67718
  // src/codegen/generators/artifacts/index.ts
67719
- var graphql13 = __toESM(require_graphql2(), 1);
67719
+ var graphql14 = __toESM(require_graphql2(), 1);
67720
67720
  var recast5 = __toESM(require_main2(), 1);
67721
67721
 
67722
67722
  // src/codegen/utils/commonjs.ts
@@ -67974,159 +67974,534 @@ function murmurHash(str) {
67974
67974
  return s2;
67975
67975
  }
67976
67976
 
67977
- // src/codegen/generators/artifacts/indexFile.ts
67978
- async function writeIndexFile(config4, docs) {
67979
- const docsToGenerate = docs.filter((doc) => doc.generateArtifact).sort((a, b) => a.name.localeCompare(b.name));
67980
- let body = config4.module === "esm" ? docsToGenerate.reduce(
67981
- (content, doc) => content + `
67982
- export { default as ${doc.name}} from './${doc.name}'`,
67983
- ""
67984
- ) : docsToGenerate.reduce(
67985
- (content, doc) => content + `
67986
- ${exportDefaultFrom(`./${doc.name}`, doc.name)}`,
67987
- cjsIndexFilePreamble
67988
- );
67989
- await fs_exports.writeFile(path_exports.join(config4.artifactDirectory, "index.js"), body);
67990
- }
67991
-
67992
- // src/codegen/generators/artifacts/inputs.ts
67977
+ // src/codegen/transforms/fragmentVariables.ts
67993
67978
  var graphql5 = __toESM(require_graphql2(), 1);
67994
- var recast3 = __toESM(require_main2(), 1);
67995
- var AST3 = recast3.types.builders;
67996
- function inputObject(config4, inputs) {
67997
- const visitedTypes = /* @__PURE__ */ new Set();
67998
- const inputObj = {
67999
- fields: inputs.reduce((fields, input) => {
68000
- const { type } = unwrapType(config4, input.type);
68001
- return {
68002
- ...fields,
68003
- [input.variable.name.value]: type.name
68004
- };
68005
- }, {}),
68006
- types: {}
68007
- };
68008
- for (const input of inputs) {
68009
- walkInputs(config4, visitedTypes, inputObj, input.type);
68010
- }
68011
- return inputObj;
68012
- }
68013
- function walkInputs(config4, visitedTypes, inputObj, rootType) {
68014
- const { type } = unwrapType(config4, rootType);
68015
- if (visitedTypes.has(type.name)) {
68016
- return;
68017
- }
68018
- if (graphql5.isEnumType(type) || graphql5.isScalarType(type)) {
68019
- return;
68020
- }
68021
- if (graphql5.isUnionType(type)) {
68022
- return;
68023
- }
68024
- visitedTypes.add(type.name);
68025
- inputObj.types[type.name] = Object.values(type.getFields()).reduce(
68026
- (typeFields, field) => {
68027
- const { type: fieldType } = unwrapType(config4, field.type);
68028
- walkInputs(config4, visitedTypes, inputObj, fieldType);
68029
- return {
68030
- ...typeFields,
68031
- [field.name]: fieldType.toString()
68032
- };
68033
- },
68034
- {}
68035
- );
68036
- }
68037
67979
 
68038
- // src/codegen/generators/artifacts/operations.ts
68039
- var graphql7 = __toESM(require_graphql2(), 1);
68040
-
68041
- // src/codegen/generators/artifacts/utils.ts
68042
- var graphql6 = __toESM(require_graphql2(), 1);
68043
- var recast4 = __toESM(require_main2(), 1);
68044
- var AST4 = recast4.types.builders;
68045
- function serializeValue(value) {
68046
- if (Array.isArray(value)) {
68047
- return AST4.arrayExpression(value.map(serializeValue));
67980
+ // src/codegen/transforms/composeQueries.ts
67981
+ var import_graphql30 = __toESM(require_graphql2(), 1);
67982
+ async function includeFragmentDefinitions(config4, documents) {
67983
+ const fragments = collectFragments(config4, documents);
67984
+ for (const [index, { name: name2, document, filename }] of documents.entries()) {
67985
+ const operation = document.definitions.find(
67986
+ ({ kind }) => kind === import_graphql30.Kind.OPERATION_DEFINITION
67987
+ );
67988
+ if (!operation) {
67989
+ continue;
67990
+ }
67991
+ const allFragments = flattenFragments(
67992
+ filename,
67993
+ { requiredFragments: findRequiredFragments(operation.selectionSet) },
67994
+ fragments
67995
+ );
67996
+ documents[index].document = {
67997
+ ...document,
67998
+ definitions: [
67999
+ operation,
68000
+ ...allFragments.map((fragmentName) => fragments[fragmentName].definition)
68001
+ ]
68002
+ };
68048
68003
  }
68049
- if (typeof value === "object" && value !== null) {
68050
- return AST4.objectExpression(
68051
- Object.entries(value).filter(([, value2]) => typeof value2 !== "undefined").map(
68052
- ([key, value2]) => AST4.objectProperty(AST4.stringLiteral(key), serializeValue(value2))
68053
- )
68004
+ }
68005
+ function collectFragments(config4, docs) {
68006
+ return docs.reduce((acc, doc) => {
68007
+ const definitions = doc.document.definitions.reduce(
68008
+ (prev, definition) => definition.kind !== "FragmentDefinition" ? prev : {
68009
+ ...prev,
68010
+ [definition.name.value]: {
68011
+ definition,
68012
+ requiredFragments: findRequiredFragments(definition.selectionSet),
68013
+ document: doc
68014
+ }
68015
+ },
68016
+ {}
68054
68017
  );
68018
+ return {
68019
+ ...acc,
68020
+ ...definitions
68021
+ };
68022
+ }, {});
68023
+ }
68024
+ function findRequiredFragments(selectionSet) {
68025
+ if (selectionSet.selections.length === 0) {
68026
+ return [];
68055
68027
  }
68056
- if (typeof value === "string") {
68057
- if (value.indexOf("\n") !== -1) {
68058
- return AST4.templateLiteral(
68059
- [AST4.templateElement({ raw: value, cooked: value }, true)],
68060
- []
68061
- );
68028
+ const referencedFragments = [];
68029
+ for (const selection2 of selectionSet.selections) {
68030
+ if (selection2.kind === import_graphql30.Kind.FRAGMENT_SPREAD) {
68031
+ referencedFragments.push(selection2.name.value);
68032
+ } else if (selection2.selectionSet) {
68033
+ referencedFragments.push(...findRequiredFragments(selection2.selectionSet));
68062
68034
  }
68063
- return AST4.stringLiteral(value);
68064
68035
  }
68065
- return AST4.literal(value);
68036
+ return referencedFragments;
68066
68037
  }
68067
- function deepMerge(filepath, ...targets) {
68068
- if (typeof targets[0] !== "object") {
68069
- const matches = targets.filter((val) => val !== targets[0]).length === 0;
68070
- if (!matches) {
68071
- throw new HoudiniError({ filepath, message: "could not merge: " + targets });
68038
+ function flattenFragments(filepath, operation, fragments) {
68039
+ const frags = /* @__PURE__ */ new Set();
68040
+ const remaining = [...operation.requiredFragments];
68041
+ while (remaining.length > 0) {
68042
+ const nextFragment = remaining.shift();
68043
+ if (!nextFragment) {
68044
+ continue;
68072
68045
  }
68073
- return targets[0];
68074
- }
68075
- if (Array.isArray(targets[0])) {
68076
- return targets[0].concat(...targets.slice(1));
68077
- }
68078
- const fields = {};
68079
- for (const target of targets) {
68080
- for (const [key, value] of Object.entries(target)) {
68081
- if (!fields[key]) {
68082
- fields[key] = [];
68083
- }
68084
- fields[key].push(value);
68046
+ if (!frags.has(nextFragment)) {
68047
+ frags.add(nextFragment);
68048
+ } else {
68049
+ continue;
68050
+ }
68051
+ const targetFragment = fragments[nextFragment];
68052
+ if (!targetFragment) {
68053
+ throw new HoudiniError({
68054
+ filepath,
68055
+ message: "compose: could not find definition for fragment " + nextFragment
68056
+ });
68085
68057
  }
68058
+ remaining.push(...targetFragment.requiredFragments);
68086
68059
  }
68087
- return Object.fromEntries(
68088
- Object.entries(fields).map(([key, value]) => [key, deepMerge(filepath, ...value)])
68089
- );
68060
+ return [...frags];
68090
68061
  }
68091
- function convertValue(config4, val) {
68092
- let value;
68093
- let kind;
68094
- if (val.kind === graphql6.Kind.INT) {
68095
- value = parseInt(val.value, 10);
68096
- kind = "Int";
68097
- } else if (val.kind === graphql6.Kind.FLOAT) {
68098
- value = parseFloat(val.value);
68099
- kind = "Float";
68100
- } else if (val.kind === graphql6.Kind.BOOLEAN) {
68101
- value = val.value;
68102
- kind = "Boolean";
68103
- } else if (val.kind === graphql6.Kind.VARIABLE) {
68104
- value = val.name.value;
68105
- kind = "Variable";
68106
- } else if (val.kind === graphql6.Kind.STRING) {
68107
- value = val.value;
68108
- kind = "String";
68062
+
68063
+ // src/codegen/transforms/fragmentVariables.ts
68064
+ var GraphqlKinds2 = graphql5.Kind;
68065
+ async function fragmentVariables(config4, documents) {
68066
+ const fragments = collectFragments(config4, documents);
68067
+ const generatedFragments = {};
68068
+ const visitedFragments = /* @__PURE__ */ new Set();
68069
+ for (const doc2 of documents) {
68070
+ const operation = doc2.document.definitions.find(
68071
+ ({ kind }) => kind === GraphqlKinds2.OPERATION_DEFINITION
68072
+ );
68073
+ if (!operation) {
68074
+ continue;
68075
+ }
68076
+ doc2.document = inlineFragmentArgs({
68077
+ config: config4,
68078
+ filepath: doc2.filename,
68079
+ fragmentDefinitions: fragments,
68080
+ document: doc2.document,
68081
+ generatedFragments,
68082
+ visitedFragments,
68083
+ scope: null
68084
+ });
68109
68085
  }
68110
- return { kind, value };
68086
+ const doc = {
68087
+ kind: graphql5.Kind.DOCUMENT,
68088
+ definitions: Object.values(generatedFragments)
68089
+ };
68090
+ documents.push({
68091
+ name: "generated::fragmentVariables",
68092
+ kind: "HoudiniFragment" /* Fragment */,
68093
+ document: doc,
68094
+ originalDocument: doc,
68095
+ generateStore: false,
68096
+ generateArtifact: false,
68097
+ filename: "generated::fragmentVariables",
68098
+ originalString: ""
68099
+ });
68111
68100
  }
68112
-
68113
- // src/codegen/generators/artifacts/operations.ts
68114
- function operationsByPath(config4, filepath, definition, filterTypes) {
68115
- if (!definition) {
68116
- return {};
68101
+ function inlineFragmentArgs({
68102
+ config: config4,
68103
+ filepath,
68104
+ fragmentDefinitions,
68105
+ document,
68106
+ generatedFragments,
68107
+ visitedFragments,
68108
+ scope,
68109
+ newName
68110
+ }) {
68111
+ if (!scope) {
68112
+ scope = operationScope(
68113
+ document.definitions.find(
68114
+ ({ kind }) => kind === GraphqlKinds2.OPERATION_DEFINITION
68115
+ )
68116
+ );
68117
68117
  }
68118
- const pathOperations = {};
68119
- graphql7.visit(definition, {
68120
- FragmentSpread(node, _, __, ___, ancestors) {
68121
- if (!config4.isListFragment(node.name.value)) {
68122
- return;
68123
- }
68124
- const path2 = ancestorKey(ancestors);
68125
- if (!pathOperations[path2]) {
68126
- pathOperations[path2] = [];
68127
- }
68128
- pathOperations[path2].push(
68129
- operationObject({
68118
+ const definitionArgs = fragmentArguments(
68119
+ config4,
68120
+ filepath,
68121
+ document
68122
+ ).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
68123
+ const result = graphql5.visit(document, {
68124
+ FragmentSpread(node) {
68125
+ const { definition } = fragmentDefinitions[node.name.value];
68126
+ let { args, hash } = collectWithArguments(config4, filepath, node, scope);
68127
+ const newFragmentName = `${node.name.value}${hash}`;
68128
+ if (!visitedFragments.has(newFragmentName)) {
68129
+ visitedFragments.add(newFragmentName);
68130
+ const defaultArguments = collectDefaultArgumentValues(config4, filepath, definition);
68131
+ if (args) {
68132
+ for (const [field, value] of Object.entries(defaultArguments || {})) {
68133
+ if (!args[field]) {
68134
+ args[field] = value;
68135
+ }
68136
+ }
68137
+ generatedFragments[newFragmentName] = inlineFragmentArgs({
68138
+ config: config4,
68139
+ filepath,
68140
+ fragmentDefinitions,
68141
+ document: fragmentDefinitions[node.name.value].definition,
68142
+ generatedFragments,
68143
+ visitedFragments,
68144
+ scope: args,
68145
+ newName: newFragmentName
68146
+ });
68147
+ } else {
68148
+ const doc = fragmentDefinitions[node.name.value].document;
68149
+ const definitionIndex = doc.document.definitions.findIndex(
68150
+ (definition2) => definition2.kind === "FragmentDefinition" && definition2.name.value === node.name.value
68151
+ );
68152
+ const localDefinitions = [...doc.document.definitions];
68153
+ localDefinitions.splice(definitionIndex, 1);
68154
+ localDefinitions.push(
68155
+ inlineFragmentArgs({
68156
+ config: config4,
68157
+ filepath,
68158
+ fragmentDefinitions,
68159
+ document: fragmentDefinitions[node.name.value].definition,
68160
+ generatedFragments,
68161
+ visitedFragments,
68162
+ scope: defaultArguments,
68163
+ newName: ""
68164
+ })
68165
+ );
68166
+ doc.document = {
68167
+ ...doc.document,
68168
+ definitions: localDefinitions
68169
+ };
68170
+ }
68171
+ if (node.name.value !== newFragmentName) {
68172
+ return {
68173
+ ...node,
68174
+ name: {
68175
+ kind: "Name",
68176
+ value: newFragmentName
68177
+ }
68178
+ };
68179
+ }
68180
+ }
68181
+ },
68182
+ Argument(node) {
68183
+ const value = node.value;
68184
+ if (value.kind !== "Variable") {
68185
+ return;
68186
+ }
68187
+ if (!scope) {
68188
+ throw new HoudiniError({
68189
+ filepath,
68190
+ message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
68191
+ });
68192
+ }
68193
+ const newValue = scope[value.name.value];
68194
+ if (newValue) {
68195
+ return {
68196
+ ...node,
68197
+ value: newValue
68198
+ };
68199
+ }
68200
+ if (definitionArgs[value.name.value] && definitionArgs[value.name.value].required) {
68201
+ throw new HoudiniError({
68202
+ filepath,
68203
+ message: "Missing value for required arg: " + value.name.value
68204
+ });
68205
+ }
68206
+ return null;
68207
+ }
68208
+ });
68209
+ if (newName) {
68210
+ result.name = {
68211
+ kind: graphql5.Kind.NAME,
68212
+ value: newName
68213
+ };
68214
+ }
68215
+ return result;
68216
+ }
68217
+ function withArguments(config4, node) {
68218
+ const withDirectives = node.directives?.filter(
68219
+ (directive) => directive.name.value === config4.withDirective
68220
+ );
68221
+ if (!withDirectives || withDirectives.length === 0) {
68222
+ return [];
68223
+ }
68224
+ return withDirectives.flatMap((directive) => directive.arguments || []);
68225
+ }
68226
+ function fragmentArguments(config4, filepath, definition) {
68227
+ const directives = definition.directives?.filter(
68228
+ (directive) => directive.name.value === config4.argumentsDirective
68229
+ );
68230
+ if (!directives || directives.length === 0) {
68231
+ return [];
68232
+ }
68233
+ return directives.flatMap(
68234
+ (directive) => directive.arguments?.flatMap((arg) => {
68235
+ if (arg.value.kind !== "ObjectValue") {
68236
+ throw new HoudiniError({
68237
+ filepath,
68238
+ message: "values of @argument must be objects"
68239
+ });
68240
+ }
68241
+ const typeArg = arg.value.fields?.find((arg2) => arg2.name.value === "type")?.value;
68242
+ if (!typeArg || typeArg.kind !== "StringValue") {
68243
+ return [];
68244
+ }
68245
+ let type = typeArg.value;
68246
+ let name2 = arg.name.value;
68247
+ let required = false;
68248
+ let defaultValue = arg.value.fields?.find((arg2) => arg2.name.value === "default")?.value || null;
68249
+ if (type[type.length - 1] === "!") {
68250
+ type = type.slice(0, -1);
68251
+ required = true;
68252
+ defaultValue = null;
68253
+ }
68254
+ return [
68255
+ {
68256
+ name: name2,
68257
+ type,
68258
+ required,
68259
+ defaultValue
68260
+ }
68261
+ ];
68262
+ }) || []
68263
+ );
68264
+ }
68265
+ function collectDefaultArgumentValues(config4, filepath, definition) {
68266
+ let result = {};
68267
+ for (const { name: name2, required, defaultValue } of fragmentArguments(
68268
+ config4,
68269
+ filepath,
68270
+ definition
68271
+ )) {
68272
+ if (required || !defaultValue) {
68273
+ continue;
68274
+ }
68275
+ result[name2] = defaultValue;
68276
+ }
68277
+ return result;
68278
+ }
68279
+ function collectWithArguments(config4, filepath, node, scope = {}) {
68280
+ const withArgs = withArguments(config4, node);
68281
+ if (withArgs.length === 0) {
68282
+ return { args: null, hash: "" };
68283
+ }
68284
+ let args = {};
68285
+ for (const arg of withArgs) {
68286
+ let value = arg.value;
68287
+ if (value.kind === GraphqlKinds2.VARIABLE) {
68288
+ if (!scope || !scope[value.name.value]) {
68289
+ throw new HoudiniError({
68290
+ filepath,
68291
+ message: "Encountered undefined variable: " + value.name.value
68292
+ });
68293
+ }
68294
+ value = scope[value.name.value];
68295
+ }
68296
+ args[arg.name.value] = {
68297
+ ...value,
68298
+ loc: void 0
68299
+ };
68300
+ }
68301
+ return {
68302
+ args,
68303
+ hash: "_" + murmurHash(JSON.stringify(args))
68304
+ };
68305
+ }
68306
+ function operationScope(operation) {
68307
+ return operation.variableDefinitions?.reduce(
68308
+ (scope, definition) => ({
68309
+ ...scope,
68310
+ [definition.variable.name.value]: {
68311
+ kind: "Variable",
68312
+ name: {
68313
+ kind: "Name",
68314
+ value: definition.variable.name.value
68315
+ }
68316
+ }
68317
+ }),
68318
+ {}
68319
+ ) || {};
68320
+ }
68321
+ function fragmentArgumentsDefinitions(config4, filepath, definition) {
68322
+ const args = fragmentArguments(config4, filepath, definition);
68323
+ if (args.length === 0) {
68324
+ return [];
68325
+ }
68326
+ return args.map((arg) => {
68327
+ const innerType = {
68328
+ kind: "NamedType",
68329
+ name: {
68330
+ kind: "Name",
68331
+ value: arg.type
68332
+ }
68333
+ };
68334
+ return {
68335
+ kind: "VariableDefinition",
68336
+ type: arg.required ? innerType : {
68337
+ kind: "NonNullType",
68338
+ type: innerType
68339
+ },
68340
+ variable: {
68341
+ kind: "Variable",
68342
+ name: {
68343
+ kind: "Name",
68344
+ value: arg.name
68345
+ }
68346
+ },
68347
+ defaultValue: arg.defaultValue ?? void 0
68348
+ };
68349
+ });
68350
+ }
68351
+
68352
+ // src/codegen/generators/artifacts/indexFile.ts
68353
+ async function writeIndexFile(config4, docs) {
68354
+ const docsToGenerate = docs.filter((doc) => doc.generateArtifact).sort((a, b) => a.name.localeCompare(b.name));
68355
+ let body = config4.module === "esm" ? docsToGenerate.reduce(
68356
+ (content, doc) => content + `
68357
+ export { default as ${doc.name}} from './${doc.name}'`,
68358
+ ""
68359
+ ) : docsToGenerate.reduce(
68360
+ (content, doc) => content + `
68361
+ ${exportDefaultFrom(`./${doc.name}`, doc.name)}`,
68362
+ cjsIndexFilePreamble
68363
+ );
68364
+ await fs_exports.writeFile(path_exports.join(config4.artifactDirectory, "index.js"), body);
68365
+ }
68366
+
68367
+ // src/codegen/generators/artifacts/inputs.ts
68368
+ var graphql6 = __toESM(require_graphql2(), 1);
68369
+ var recast3 = __toESM(require_main2(), 1);
68370
+ var AST3 = recast3.types.builders;
68371
+ function inputObject(config4, inputs) {
68372
+ const visitedTypes = /* @__PURE__ */ new Set();
68373
+ const inputObj = {
68374
+ fields: inputs.reduce((fields, input) => {
68375
+ const { type } = unwrapType(config4, input.type);
68376
+ return {
68377
+ ...fields,
68378
+ [input.variable.name.value]: type.name
68379
+ };
68380
+ }, {}),
68381
+ types: {}
68382
+ };
68383
+ for (const input of inputs) {
68384
+ walkInputs(config4, visitedTypes, inputObj, input.type);
68385
+ }
68386
+ return inputObj;
68387
+ }
68388
+ function walkInputs(config4, visitedTypes, inputObj, rootType) {
68389
+ const { type } = unwrapType(config4, rootType);
68390
+ if (visitedTypes.has(type.name)) {
68391
+ return;
68392
+ }
68393
+ if (graphql6.isEnumType(type) || graphql6.isScalarType(type)) {
68394
+ return;
68395
+ }
68396
+ if (graphql6.isUnionType(type)) {
68397
+ return;
68398
+ }
68399
+ visitedTypes.add(type.name);
68400
+ inputObj.types[type.name] = Object.values(type.getFields()).reduce(
68401
+ (typeFields, field) => {
68402
+ const { type: fieldType } = unwrapType(config4, field.type);
68403
+ walkInputs(config4, visitedTypes, inputObj, fieldType);
68404
+ return {
68405
+ ...typeFields,
68406
+ [field.name]: fieldType.toString()
68407
+ };
68408
+ },
68409
+ {}
68410
+ );
68411
+ }
68412
+
68413
+ // src/codegen/generators/artifacts/operations.ts
68414
+ var graphql8 = __toESM(require_graphql2(), 1);
68415
+
68416
+ // src/codegen/generators/artifacts/utils.ts
68417
+ var graphql7 = __toESM(require_graphql2(), 1);
68418
+ var recast4 = __toESM(require_main2(), 1);
68419
+ var AST4 = recast4.types.builders;
68420
+ function serializeValue(value) {
68421
+ if (Array.isArray(value)) {
68422
+ return AST4.arrayExpression(value.map(serializeValue));
68423
+ }
68424
+ if (typeof value === "object" && value !== null) {
68425
+ return AST4.objectExpression(
68426
+ Object.entries(value).filter(([, value2]) => typeof value2 !== "undefined").map(
68427
+ ([key, value2]) => AST4.objectProperty(AST4.stringLiteral(key), serializeValue(value2))
68428
+ )
68429
+ );
68430
+ }
68431
+ if (typeof value === "string") {
68432
+ if (value.indexOf("\n") !== -1) {
68433
+ return AST4.templateLiteral(
68434
+ [AST4.templateElement({ raw: value, cooked: value }, true)],
68435
+ []
68436
+ );
68437
+ }
68438
+ return AST4.stringLiteral(value);
68439
+ }
68440
+ return AST4.literal(value);
68441
+ }
68442
+ function deepMerge(filepath, ...targets) {
68443
+ if (typeof targets[0] !== "object") {
68444
+ const matches = targets.filter((val) => val !== targets[0]).length === 0;
68445
+ if (!matches) {
68446
+ throw new HoudiniError({ filepath, message: "could not merge: " + targets });
68447
+ }
68448
+ return targets[0];
68449
+ }
68450
+ if (Array.isArray(targets[0])) {
68451
+ return targets[0].concat(...targets.slice(1));
68452
+ }
68453
+ const fields = {};
68454
+ for (const target of targets) {
68455
+ for (const [key, value] of Object.entries(target)) {
68456
+ if (!fields[key]) {
68457
+ fields[key] = [];
68458
+ }
68459
+ fields[key].push(value);
68460
+ }
68461
+ }
68462
+ return Object.fromEntries(
68463
+ Object.entries(fields).map(([key, value]) => [key, deepMerge(filepath, ...value)])
68464
+ );
68465
+ }
68466
+ function convertValue(config4, val) {
68467
+ let value;
68468
+ let kind;
68469
+ if (val.kind === graphql7.Kind.INT) {
68470
+ value = parseInt(val.value, 10);
68471
+ kind = "Int";
68472
+ } else if (val.kind === graphql7.Kind.FLOAT) {
68473
+ value = parseFloat(val.value);
68474
+ kind = "Float";
68475
+ } else if (val.kind === graphql7.Kind.BOOLEAN) {
68476
+ value = val.value;
68477
+ kind = "Boolean";
68478
+ } else if (val.kind === graphql7.Kind.VARIABLE) {
68479
+ value = val.name.value;
68480
+ kind = "Variable";
68481
+ } else if (val.kind === graphql7.Kind.STRING) {
68482
+ value = val.value;
68483
+ kind = "String";
68484
+ }
68485
+ return { kind, value };
68486
+ }
68487
+
68488
+ // src/codegen/generators/artifacts/operations.ts
68489
+ function operationsByPath(config4, filepath, definition, filterTypes) {
68490
+ if (!definition) {
68491
+ return {};
68492
+ }
68493
+ const pathOperations = {};
68494
+ graphql8.visit(definition, {
68495
+ FragmentSpread(node, _, __, ___, ancestors) {
68496
+ if (!config4.isListFragment(node.name.value)) {
68497
+ return;
68498
+ }
68499
+ const path2 = ancestorKey(ancestors);
68500
+ if (!pathOperations[path2]) {
68501
+ pathOperations[path2] = [];
68502
+ }
68503
+ pathOperations[path2].push(
68504
+ operationObject({
68130
68505
  config: config4,
68131
68506
  filepath,
68132
68507
  listName: config4.listNameFromFragment(node.name.value),
@@ -68275,7 +68650,7 @@ function ancestorKey(ancestors) {
68275
68650
  }
68276
68651
 
68277
68652
  // src/codegen/generators/artifacts/selection.ts
68278
- var graphql12 = __toESM(require_graphql2(), 1);
68653
+ var graphql13 = __toESM(require_graphql2(), 1);
68279
68654
 
68280
68655
  // ../../node_modules/.pnpm/@kitql+helper@0.5.0/node_modules/@kitql/helper/index.mjs
68281
68656
  var config2 = {
@@ -68321,16 +68696,16 @@ async function sleep2(ms) {
68321
68696
  }
68322
68697
 
68323
68698
  // src/codegen/transforms/list.ts
68324
- var graphql10 = __toESM(require_graphql2(), 1);
68699
+ var graphql11 = __toESM(require_graphql2(), 1);
68325
68700
 
68326
68701
  // src/codegen/utils/objectIdentificationSelection.ts
68327
- var graphql8 = __toESM(require_graphql2(), 1);
68702
+ var graphql9 = __toESM(require_graphql2(), 1);
68328
68703
  var objectIdentificationSelection = (config4, type) => {
68329
68704
  return config4.keyFieldsForType(type.name).map((key) => {
68330
68705
  return {
68331
- kind: graphql8.Kind.FIELD,
68706
+ kind: graphql9.Kind.FIELD,
68332
68707
  name: {
68333
- kind: graphql8.Kind.NAME,
68708
+ kind: graphql9.Kind.NAME,
68334
68709
  value: key
68335
68710
  }
68336
68711
  };
@@ -68338,7 +68713,7 @@ var objectIdentificationSelection = (config4, type) => {
68338
68713
  };
68339
68714
 
68340
68715
  // src/codegen/transforms/paginate.ts
68341
- var graphql9 = __toESM(require_graphql2(), 1);
68716
+ var graphql10 = __toESM(require_graphql2(), 1);
68342
68717
  async function paginate(config4, documents) {
68343
68718
  const newDocs = [];
68344
68719
  for (const doc of documents) {
@@ -68371,7 +68746,7 @@ async function paginate(config4, documents) {
68371
68746
  };
68372
68747
  let cursorType = "String";
68373
68748
  let paginationPath = [];
68374
- doc.document = graphql9.visit(doc.document, {
68749
+ doc.document = graphql10.visit(doc.document, {
68375
68750
  Field(node, _, __, ___, ancestors) {
68376
68751
  const paginateDirective = node.directives?.find(
68377
68752
  (directive) => directive.name.value === config4.paginateDirective
@@ -68382,23 +68757,22 @@ async function paginate(config4, documents) {
68382
68757
  paginated = true;
68383
68758
  const fieldTypeFields = parentTypeFromAncestors(config4.schema, doc.filename, ancestors).getFields()[node.name.value];
68384
68759
  const args = new Set(fieldTypeFields.args.map((arg) => arg.name));
68385
- const passedArgs = new Set(node.arguments?.map((arg) => arg.name.value));
68386
- const specifiedForwards = passedArgs.has("first");
68387
- const specifiedBackwards = passedArgs.has("last");
68388
68760
  cursorType = fieldTypeFields.args?.find((arg) => ["before", "after"].includes(arg.name))?.type?.name || "String";
68389
68761
  flags.after.type = cursorType;
68390
68762
  flags.before.type = cursorType;
68391
- const forwardPagination = !specifiedBackwards && args.has("first") && args.has("after");
68392
- const backwardsPagination = !specifiedForwards && args.has("last") && args.has("before");
68393
- const offsetPagination = !forwardPagination && !backwardsPagination && args.has("offset") && args.has("limit");
68394
- flags.first.enabled = forwardPagination;
68395
- flags.after.enabled = forwardPagination;
68396
- flags.last.enabled = backwardsPagination;
68397
- flags.before.enabled = backwardsPagination;
68763
+ const passedArgs = new Set(node.arguments?.map((arg) => arg.name.value));
68764
+ const forwards = args.has("first") && args.has("after");
68765
+ const backwards = args.has("last") && args.has("after");
68766
+ const cursorPagination = passedArgs.has("last") || passedArgs.has("first");
68767
+ const offsetPagination = !cursorPagination && args.has("offset") && args.has("limit");
68768
+ flags.first.enabled = forwards;
68769
+ flags.after.enabled = forwards;
68770
+ flags.last.enabled = backwards;
68771
+ flags.before.enabled = backwards;
68398
68772
  flags.offset.enabled = offsetPagination;
68399
68773
  flags.limit.enabled = offsetPagination;
68400
68774
  paginationPath = ancestors.filter(
68401
- (ancestor) => !Array.isArray(ancestor) && ancestor.kind === graphql9.Kind.FIELD
68775
+ (ancestor) => !Array.isArray(ancestor) && ancestor.kind === graphql10.Kind.FIELD
68402
68776
  ).concat(node).map((field) => field.alias?.value || field.name.value);
68403
68777
  return {
68404
68778
  ...node,
@@ -68414,12 +68788,8 @@ async function paginate(config4, documents) {
68414
68788
  let fragmentName = "";
68415
68789
  let refetchQueryName = "";
68416
68790
  let nodeQuery = false;
68417
- let refetchUpdate = "append" /* append */;
68418
- if (flags.last.enabled) {
68419
- refetchUpdate = "prepend" /* prepend */;
68420
- }
68421
68791
  let fragment = "";
68422
- doc.document = graphql9.visit(doc.document, {
68792
+ doc.document = graphql10.visit(doc.document, {
68423
68793
  OperationDefinition(node) {
68424
68794
  if (node.operation !== "query") {
68425
68795
  throw new HoudiniError({
@@ -68473,9 +68843,9 @@ async function paginate(config4, documents) {
68473
68843
  directives: [
68474
68844
  ...node.directives || [],
68475
68845
  {
68476
- kind: graphql9.Kind.DIRECTIVE,
68846
+ kind: graphql10.Kind.DIRECTIVE,
68477
68847
  name: {
68478
- kind: graphql9.Kind.NAME,
68848
+ kind: graphql10.Kind.NAME,
68479
68849
  value: config4.argumentsDirective
68480
68850
  }
68481
68851
  }
@@ -68512,42 +68882,40 @@ async function paginate(config4, documents) {
68512
68882
  targetType = fragment;
68513
68883
  }
68514
68884
  }
68885
+ const pageSize = flags.first.defaultValue ?? flags.last.defaultValue ?? flags.limit.defaultValue;
68886
+ const start = flags.after.defaultValue ?? flags.before.defaultValue ?? flags.offset.defaultValue;
68887
+ let direction = "forward";
68888
+ if (flags.before.enabled && flags.after.enabled) {
68889
+ direction = "both";
68890
+ } else if (flags.before.enabled) {
68891
+ direction = "backward";
68892
+ }
68515
68893
  doc.refetch = {
68516
- update: refetchUpdate,
68517
68894
  path: paginationPath,
68518
68895
  method: flags.first.enabled || flags.last.enabled ? "cursor" : "offset",
68519
- pageSize: 0,
68896
+ pageSize,
68520
68897
  embedded: nodeQuery,
68521
68898
  targetType,
68522
68899
  paginated: true,
68523
- direction: flags.last.enabled ? "backwards" : "forward"
68524
- };
68525
- if (flags.first.enabled) {
68526
- doc.refetch.pageSize = flags.first.defaultValue;
68527
- doc.refetch.start = flags.after.defaultValue;
68528
- } else if (flags.last.enabled) {
68529
- doc.refetch.pageSize = flags.last.defaultValue;
68530
- doc.refetch.start = flags.before.defaultValue;
68531
- } else if (flags.limit.enabled) {
68532
- doc.refetch.pageSize = flags.limit.defaultValue;
68533
- doc.refetch.start = flags.offset.defaultValue;
68534
- }
68900
+ direction,
68901
+ start
68902
+ };
68535
68903
  if (!fragment) {
68536
68904
  continue;
68537
68905
  }
68538
68906
  const paginationArgs = Object.entries(flags).filter(([_, { enabled }]) => enabled).map(([key, value]) => ({ name: key, ...value }));
68539
68907
  const fragmentSpreadSelection = [
68540
68908
  {
68541
- kind: graphql9.Kind.FRAGMENT_SPREAD,
68909
+ kind: graphql10.Kind.FRAGMENT_SPREAD,
68542
68910
  name: {
68543
- kind: graphql9.Kind.NAME,
68911
+ kind: graphql10.Kind.NAME,
68544
68912
  value: fragmentName
68545
68913
  },
68546
68914
  directives: [
68547
68915
  {
68548
- kind: graphql9.Kind.DIRECTIVE,
68916
+ kind: graphql10.Kind.DIRECTIVE,
68549
68917
  name: {
68550
- kind: graphql9.Kind.NAME,
68918
+ kind: graphql10.Kind.NAME,
68551
68919
  value: config4.withDirective
68552
68920
  },
68553
68921
  ["arguments"]: paginationArgs.map(
@@ -68575,29 +68943,29 @@ async function paginate(config4, documents) {
68575
68943
  });
68576
68944
  const typeConfig = config4.typeConfig?.[fragment];
68577
68945
  const queryDoc = {
68578
- kind: graphql9.Kind.DOCUMENT,
68946
+ kind: graphql10.Kind.DOCUMENT,
68579
68947
  definitions: [
68580
68948
  {
68581
- kind: graphql9.Kind.OPERATION_DEFINITION,
68949
+ kind: graphql10.Kind.OPERATION_DEFINITION,
68582
68950
  name: {
68583
- kind: graphql9.Kind.NAME,
68951
+ kind: graphql10.Kind.NAME,
68584
68952
  value: refetchQueryName
68585
68953
  },
68586
68954
  operation: "query",
68587
68955
  variableDefinitions: paginationArgs.map(
68588
68956
  (arg) => ({
68589
- kind: graphql9.Kind.VARIABLE_DEFINITION,
68957
+ kind: graphql10.Kind.VARIABLE_DEFINITION,
68590
68958
  type: {
68591
- kind: graphql9.Kind.NAMED_TYPE,
68959
+ kind: graphql10.Kind.NAMED_TYPE,
68592
68960
  name: {
68593
- kind: graphql9.Kind.NAME,
68961
+ kind: graphql10.Kind.NAME,
68594
68962
  value: arg.type
68595
68963
  }
68596
68964
  },
68597
68965
  variable: {
68598
- kind: graphql9.Kind.VARIABLE,
68966
+ kind: graphql10.Kind.VARIABLE,
68599
68967
  name: {
68600
- kind: graphql9.Kind.NAME,
68968
+ kind: graphql10.Kind.NAME,
68601
68969
  value: arg.name
68602
68970
  }
68603
68971
  },
@@ -68609,12 +68977,12 @@ async function paginate(config4, documents) {
68609
68977
  ).concat(
68610
68978
  !nodeQuery ? [] : keys.map(
68611
68979
  (key) => ({
68612
- kind: graphql9.Kind.VARIABLE_DEFINITION,
68980
+ kind: graphql10.Kind.VARIABLE_DEFINITION,
68613
68981
  type: key.type,
68614
68982
  variable: {
68615
- kind: graphql9.Kind.VARIABLE,
68983
+ kind: graphql10.Kind.VARIABLE,
68616
68984
  name: {
68617
- kind: graphql9.Kind.NAME,
68985
+ kind: graphql10.Kind.NAME,
68618
68986
  value: key.name
68619
68987
  }
68620
68988
  }
@@ -68622,42 +68990,42 @@ async function paginate(config4, documents) {
68622
68990
  )
68623
68991
  ),
68624
68992
  selectionSet: {
68625
- kind: graphql9.Kind.SELECTION_SET,
68993
+ kind: graphql10.Kind.SELECTION_SET,
68626
68994
  selections: !nodeQuery ? fragmentSpreadSelection : [
68627
68995
  {
68628
- kind: graphql9.Kind.FIELD,
68996
+ kind: graphql10.Kind.FIELD,
68629
68997
  name: {
68630
- kind: graphql9.Kind.NAME,
68998
+ kind: graphql10.Kind.NAME,
68631
68999
  value: typeConfig?.resolve?.queryField || "node"
68632
69000
  },
68633
69001
  ["arguments"]: keys.map((key) => ({
68634
- kind: graphql9.Kind.ARGUMENT,
69002
+ kind: graphql10.Kind.ARGUMENT,
68635
69003
  name: {
68636
- kind: graphql9.Kind.NAME,
69004
+ kind: graphql10.Kind.NAME,
68637
69005
  value: key.name
68638
69006
  },
68639
69007
  value: {
68640
- kind: graphql9.Kind.VARIABLE,
69008
+ kind: graphql10.Kind.VARIABLE,
68641
69009
  name: {
68642
- kind: graphql9.Kind.NAME,
69010
+ kind: graphql10.Kind.NAME,
68643
69011
  value: key.name
68644
69012
  }
68645
69013
  }
68646
69014
  })),
68647
69015
  selectionSet: {
68648
- kind: graphql9.Kind.SELECTION_SET,
69016
+ kind: graphql10.Kind.SELECTION_SET,
68649
69017
  selections: [
68650
69018
  {
68651
- kind: graphql9.Kind.FIELD,
69019
+ kind: graphql10.Kind.FIELD,
68652
69020
  name: {
68653
- kind: graphql9.Kind.NAME,
69021
+ kind: graphql10.Kind.NAME,
68654
69022
  value: "__typename"
68655
69023
  }
68656
69024
  },
68657
69025
  ...(typeConfig?.keys || ["id"]).map((key) => ({
68658
- kind: graphql9.Kind.FIELD,
69026
+ kind: graphql10.Kind.FIELD,
68659
69027
  name: {
68660
- kind: graphql9.Kind.NAME,
69028
+ kind: graphql10.Kind.NAME,
68661
69029
  value: key
68662
69030
  }
68663
69031
  })),
@@ -68707,27 +69075,21 @@ function replaceArgumentsWithVariables(args, flags) {
68707
69075
  if (flags[name2].defaultValue || !spec.enabled || seenArgs[name2]) {
68708
69076
  continue;
68709
69077
  }
68710
- if (["first", "after"].includes(name2) && flags["before"].enabled) {
68711
- continue;
68712
- }
68713
- if (["last", "before"].includes(name2) && flags["first"].enabled) {
68714
- continue;
68715
- }
68716
69078
  newArgs.push(variableAsArgument(name2));
68717
69079
  }
68718
69080
  return newArgs;
68719
69081
  }
68720
69082
  function variableAsArgument(name2, variable) {
68721
69083
  return {
68722
- kind: graphql9.Kind.ARGUMENT,
69084
+ kind: graphql10.Kind.ARGUMENT,
68723
69085
  name: {
68724
- kind: graphql9.Kind.NAME,
69086
+ kind: graphql10.Kind.NAME,
68725
69087
  value: name2
68726
69088
  },
68727
69089
  value: {
68728
- kind: graphql9.Kind.VARIABLE,
69090
+ kind: graphql10.Kind.VARIABLE,
68729
69091
  name: {
68730
- kind: graphql9.Kind.NAME,
69092
+ kind: graphql10.Kind.NAME,
68731
69093
  value: variable ?? name2
68732
69094
  }
68733
69095
  }
@@ -68735,18 +69097,18 @@ function variableAsArgument(name2, variable) {
68735
69097
  }
68736
69098
  function staticVariableDefinition(name2, type, defaultValue, variableName) {
68737
69099
  return {
68738
- kind: graphql9.Kind.VARIABLE_DEFINITION,
69100
+ kind: graphql10.Kind.VARIABLE_DEFINITION,
68739
69101
  type: {
68740
- kind: graphql9.Kind.NAMED_TYPE,
69102
+ kind: graphql10.Kind.NAMED_TYPE,
68741
69103
  name: {
68742
- kind: graphql9.Kind.NAME,
69104
+ kind: graphql10.Kind.NAME,
68743
69105
  value: type
68744
69106
  }
68745
69107
  },
68746
69108
  variable: {
68747
- kind: graphql9.Kind.VARIABLE,
69109
+ kind: graphql10.Kind.VARIABLE,
68748
69110
  name: {
68749
- kind: graphql9.Kind.NAME,
69111
+ kind: graphql10.Kind.NAME,
68750
69112
  value: variableName ?? name2
68751
69113
  }
68752
69114
  },
@@ -68758,9 +69120,9 @@ function staticVariableDefinition(name2, type, defaultValue, variableName) {
68758
69120
  }
68759
69121
  function argumentNode(name2, value) {
68760
69122
  return {
68761
- kind: graphql9.Kind.ARGUMENT,
69123
+ kind: graphql10.Kind.ARGUMENT,
68762
69124
  name: {
68763
- kind: graphql9.Kind.NAME,
69125
+ kind: graphql10.Kind.NAME,
68764
69126
  value: name2
68765
69127
  },
68766
69128
  value: objectNode(value)
@@ -68768,16 +69130,16 @@ function argumentNode(name2, value) {
68768
69130
  }
68769
69131
  function objectNode([type, defaultValue]) {
68770
69132
  const node = {
68771
- kind: graphql9.Kind.OBJECT,
69133
+ kind: graphql10.Kind.OBJECT,
68772
69134
  fields: [
68773
69135
  {
68774
- kind: graphql9.Kind.OBJECT_FIELD,
69136
+ kind: graphql10.Kind.OBJECT_FIELD,
68775
69137
  name: {
68776
- kind: graphql9.Kind.NAME,
69138
+ kind: graphql10.Kind.NAME,
68777
69139
  value: "type"
68778
69140
  },
68779
69141
  value: {
68780
- kind: graphql9.Kind.STRING,
69142
+ kind: graphql10.Kind.STRING,
68781
69143
  value: type
68782
69144
  }
68783
69145
  }
@@ -68785,8 +69147,8 @@ function objectNode([type, defaultValue]) {
68785
69147
  };
68786
69148
  if (defaultValue) {
68787
69149
  node.fields.push({
68788
- kind: graphql9.Kind.OBJECT_FIELD,
68789
- name: { kind: graphql9.Kind.NAME, value: "default" },
69150
+ kind: graphql10.Kind.OBJECT_FIELD,
69151
+ name: { kind: graphql10.Kind.NAME, value: "default" },
68790
69152
  value: {
68791
69153
  kind: typeof defaultValue === "number" ? "IntValue" : "StringValue",
68792
69154
  value: defaultValue.toString()
@@ -68797,34 +69159,34 @@ function objectNode([type, defaultValue]) {
68797
69159
  }
68798
69160
  var pageInfoSelection = [
68799
69161
  {
68800
- kind: graphql9.Kind.FIELD,
69162
+ kind: graphql10.Kind.FIELD,
68801
69163
  name: {
68802
- kind: graphql9.Kind.NAME,
69164
+ kind: graphql10.Kind.NAME,
68803
69165
  value: "edges"
68804
69166
  },
68805
69167
  selectionSet: {
68806
- kind: graphql9.Kind.SELECTION_SET,
69168
+ kind: graphql10.Kind.SELECTION_SET,
68807
69169
  selections: [
68808
69170
  {
68809
- kind: graphql9.Kind.FIELD,
69171
+ kind: graphql10.Kind.FIELD,
68810
69172
  name: {
68811
- kind: graphql9.Kind.NAME,
69173
+ kind: graphql10.Kind.NAME,
68812
69174
  value: "cursor"
68813
69175
  }
68814
69176
  },
68815
69177
  {
68816
- kind: graphql9.Kind.FIELD,
69178
+ kind: graphql10.Kind.FIELD,
68817
69179
  name: {
68818
- kind: graphql9.Kind.NAME,
69180
+ kind: graphql10.Kind.NAME,
68819
69181
  value: "node"
68820
69182
  },
68821
69183
  selectionSet: {
68822
- kind: graphql9.Kind.SELECTION_SET,
69184
+ kind: graphql10.Kind.SELECTION_SET,
68823
69185
  selections: [
68824
69186
  {
68825
- kind: graphql9.Kind.FIELD,
69187
+ kind: graphql10.Kind.FIELD,
68826
69188
  name: {
68827
- kind: graphql9.Kind.NAME,
69189
+ kind: graphql10.Kind.NAME,
68828
69190
  value: "__typename"
68829
69191
  }
68830
69192
  }
@@ -68835,39 +69197,39 @@ var pageInfoSelection = [
68835
69197
  }
68836
69198
  },
68837
69199
  {
68838
- kind: graphql9.Kind.FIELD,
69200
+ kind: graphql10.Kind.FIELD,
68839
69201
  name: {
68840
- kind: graphql9.Kind.NAME,
69202
+ kind: graphql10.Kind.NAME,
68841
69203
  value: "pageInfo"
68842
69204
  },
68843
69205
  selectionSet: {
68844
- kind: graphql9.Kind.SELECTION_SET,
69206
+ kind: graphql10.Kind.SELECTION_SET,
68845
69207
  selections: [
68846
69208
  {
68847
- kind: graphql9.Kind.FIELD,
69209
+ kind: graphql10.Kind.FIELD,
68848
69210
  name: {
68849
- kind: graphql9.Kind.NAME,
69211
+ kind: graphql10.Kind.NAME,
68850
69212
  value: "hasPreviousPage"
68851
69213
  }
68852
69214
  },
68853
69215
  {
68854
- kind: graphql9.Kind.FIELD,
69216
+ kind: graphql10.Kind.FIELD,
68855
69217
  name: {
68856
- kind: graphql9.Kind.NAME,
69218
+ kind: graphql10.Kind.NAME,
68857
69219
  value: "hasNextPage"
68858
69220
  }
68859
69221
  },
68860
69222
  {
68861
- kind: graphql9.Kind.FIELD,
69223
+ kind: graphql10.Kind.FIELD,
68862
69224
  name: {
68863
- kind: graphql9.Kind.NAME,
69225
+ kind: graphql10.Kind.NAME,
68864
69226
  value: "startCursor"
68865
69227
  }
68866
69228
  },
68867
69229
  {
68868
- kind: graphql9.Kind.FIELD,
69230
+ kind: graphql10.Kind.FIELD,
68869
69231
  name: {
68870
- kind: graphql9.Kind.NAME,
69232
+ kind: graphql10.Kind.NAME,
68871
69233
  value: "endCursor"
68872
69234
  }
68873
69235
  }
@@ -68881,15 +69243,15 @@ async function addListFragments(config4, documents) {
68881
69243
  const lists = {};
68882
69244
  const errors = [];
68883
69245
  for (const doc of documents) {
68884
- doc.document = graphql10.visit(doc.document, {
69246
+ doc.document = graphql11.visit(doc.document, {
68885
69247
  Directive(node, key, parent, path2, ancestors) {
68886
69248
  if ([config4.listDirective, config4.paginateDirective].includes(node.name.value)) {
68887
69249
  const nameArg = node.arguments?.find((arg) => arg.name.value === "name");
68888
69250
  let error = {
68889
- ...new graphql10.GraphQLError(
69251
+ ...new graphql11.GraphQLError(
68890
69252
  "",
68891
69253
  node,
68892
- new graphql10.Source(""),
69254
+ new graphql11.Source(""),
68893
69255
  node.loc ? [node.loc.start, node.loc.end] : null,
68894
69256
  path2
68895
69257
  ),
@@ -68941,7 +69303,7 @@ async function addListFragments(config4, documents) {
68941
69303
  {
68942
69304
  kind: "Argument",
68943
69305
  name: {
68944
- kind: graphql10.Kind.NAME,
69306
+ kind: graphql11.Kind.NAME,
68945
69307
  value: "connection"
68946
69308
  },
68947
69309
  value: {
@@ -68991,7 +69353,7 @@ async function addListFragments(config4, documents) {
68991
69353
  const validDeletes = [
68992
69354
  ...new Set(
68993
69355
  Object.values(lists).map(({ type }) => {
68994
- if (!(type instanceof graphql10.GraphQLObjectType)) {
69356
+ if (!(type instanceof graphql11.GraphQLObjectType)) {
68995
69357
  return "";
68996
69358
  }
68997
69359
  if (config4.keyFieldsForType(type.name).length !== 1) {
@@ -69005,7 +69367,7 @@ async function addListFragments(config4, documents) {
69005
69367
  return;
69006
69368
  }
69007
69369
  const generatedDoc = {
69008
- kind: graphql10.Kind.DOCUMENT,
69370
+ kind: graphql11.Kind.DOCUMENT,
69009
69371
  definitions: Object.entries(lists).flatMap(
69010
69372
  ([name2, { selection: selection2, type }]) => {
69011
69373
  const schemaType = config4.schema.getType(type.name);
@@ -69013,7 +69375,7 @@ async function addListFragments(config4, documents) {
69013
69375
  throw new HoudiniError({ message: "Lists must have a selection" });
69014
69376
  }
69015
69377
  const fragmentSelection = {
69016
- kind: graphql10.Kind.SELECTION_SET,
69378
+ kind: graphql11.Kind.SELECTION_SET,
69017
69379
  selections: [...selection2.selections]
69018
69380
  };
69019
69381
  if (schemaType && fragmentSelection && !fragmentSelection?.selections.find(
@@ -69028,14 +69390,14 @@ async function addListFragments(config4, documents) {
69028
69390
  {
69029
69391
  name: {
69030
69392
  value: config4.listInsertFragment(name2),
69031
- kind: graphql10.Kind.NAME
69393
+ kind: graphql11.Kind.NAME
69032
69394
  },
69033
- kind: graphql10.Kind.FRAGMENT_DEFINITION,
69395
+ kind: graphql11.Kind.FRAGMENT_DEFINITION,
69034
69396
  selectionSet: fragmentSelection,
69035
69397
  typeCondition: {
69036
- kind: graphql10.Kind.NAMED_TYPE,
69398
+ kind: graphql11.Kind.NAMED_TYPE,
69037
69399
  name: {
69038
- kind: graphql10.Kind.NAME,
69400
+ kind: graphql11.Kind.NAME,
69039
69401
  value: type.name
69040
69402
  }
69041
69403
  }
@@ -69043,32 +69405,32 @@ async function addListFragments(config4, documents) {
69043
69405
  {
69044
69406
  name: {
69045
69407
  value: config4.listToggleFragment(name2),
69046
- kind: graphql10.Kind.NAME
69408
+ kind: graphql11.Kind.NAME
69047
69409
  },
69048
- kind: graphql10.Kind.FRAGMENT_DEFINITION,
69410
+ kind: graphql11.Kind.FRAGMENT_DEFINITION,
69049
69411
  selectionSet: fragmentSelection,
69050
69412
  typeCondition: {
69051
- kind: graphql10.Kind.NAMED_TYPE,
69413
+ kind: graphql11.Kind.NAMED_TYPE,
69052
69414
  name: {
69053
- kind: graphql10.Kind.NAME,
69415
+ kind: graphql11.Kind.NAME,
69054
69416
  value: type.name
69055
69417
  }
69056
69418
  }
69057
69419
  },
69058
69420
  {
69059
- kind: graphql10.Kind.FRAGMENT_DEFINITION,
69421
+ kind: graphql11.Kind.FRAGMENT_DEFINITION,
69060
69422
  name: {
69061
69423
  value: config4.listRemoveFragment(name2),
69062
- kind: graphql10.Kind.NAME
69424
+ kind: graphql11.Kind.NAME
69063
69425
  },
69064
69426
  selectionSet: {
69065
- kind: graphql10.Kind.SELECTION_SET,
69427
+ kind: graphql11.Kind.SELECTION_SET,
69066
69428
  selections: [...objectIdentificationSelection(config4, type)]
69067
69429
  },
69068
69430
  typeCondition: {
69069
- kind: graphql10.Kind.NAMED_TYPE,
69431
+ kind: graphql11.Kind.NAMED_TYPE,
69070
69432
  name: {
69071
- kind: graphql10.Kind.NAME,
69433
+ kind: graphql11.Kind.NAME,
69072
69434
  value: type.name
69073
69435
  }
69074
69436
  }
@@ -69077,14 +69439,14 @@ async function addListFragments(config4, documents) {
69077
69439
  }
69078
69440
  ).concat(
69079
69441
  ...validDeletes.map((typeName) => ({
69080
- kind: graphql10.Kind.DIRECTIVE_DEFINITION,
69442
+ kind: graphql11.Kind.DIRECTIVE_DEFINITION,
69081
69443
  name: {
69082
- kind: graphql10.Kind.NAME,
69444
+ kind: graphql11.Kind.NAME,
69083
69445
  value: config4.listDeleteDirective(typeName)
69084
69446
  },
69085
69447
  locations: [
69086
69448
  {
69087
- kind: graphql10.Kind.NAME,
69449
+ kind: graphql11.Kind.NAME,
69088
69450
  value: "FIELD"
69089
69451
  }
69090
69452
  ],
@@ -69092,8 +69454,8 @@ async function addListFragments(config4, documents) {
69092
69454
  }))
69093
69455
  )
69094
69456
  };
69095
- config4.newSchema += "\n" + generatedDoc.definitions.filter((c) => c.kind !== "FragmentDefinition").map(graphql10.print).join("\n\n");
69096
- config4.newDocuments += "\n" + generatedDoc.definitions.filter((c) => c.kind === "FragmentDefinition").map(graphql10.print).join("\n\n");
69457
+ config4.newSchema += "\n" + generatedDoc.definitions.filter((c) => c.kind !== "FragmentDefinition").map(graphql11.print).join("\n\n");
69458
+ config4.newDocuments += "\n" + generatedDoc.definitions.filter((c) => c.kind === "FragmentDefinition").map(graphql11.print).join("\n\n");
69097
69459
  documents.push({
69098
69460
  name: "generated::lists",
69099
69461
  kind: "HoudiniFragment" /* Fragment */,
@@ -69178,11 +69540,11 @@ var nodeNotDefinedMessage = (config4) => `Looks like you are trying to use the $
69178
69540
  For more information, visit this link: ${siteURL}/guides/pagination`;
69179
69541
 
69180
69542
  // src/codegen/generators/artifacts/fieldKey.ts
69181
- var graphql11 = __toESM(require_graphql2(), 1);
69543
+ var graphql12 = __toESM(require_graphql2(), 1);
69182
69544
  function fieldKey(config4, field) {
69183
69545
  const attributeName = field.alias?.value || field.name.value;
69184
- const printed = graphql11.print(field);
69185
- const secondParse = graphql11.parse(`{${printed}}`).definitions[0].selectionSet.selections[0];
69546
+ const printed = graphql12.print(field);
69547
+ const secondParse = graphql12.parse(`{${printed}}`).definitions[0].selectionSet.selections[0];
69186
69548
  const paginated = !!field.directives?.find(
69187
69549
  (directive) => directive.name.value === config4.paginateDirective
69188
69550
  );
@@ -69220,7 +69582,7 @@ function selection({
69220
69582
  path: path2 = [],
69221
69583
  includeFragments,
69222
69584
  document,
69223
- markEdges
69585
+ inConnection
69224
69586
  }) {
69225
69587
  let object = {};
69226
69588
  const typeMap = {};
@@ -69277,8 +69639,8 @@ function selection({
69277
69639
  const typeConditionName = field.typeCondition.name.value;
69278
69640
  const typeCondition = config4.schema.getType(typeConditionName);
69279
69641
  const possibleTypes = [];
69280
- if (!graphql12.isAbstractType(typeCondition)) {
69281
- } else if (graphql12.isAbstractType(parentType)) {
69642
+ if (!graphql13.isAbstractType(typeCondition)) {
69643
+ } else if (graphql13.isAbstractType(parentType)) {
69282
69644
  const possibleParentTypes = config4.schema.getPossibleTypes(parentType).map((type) => type.name);
69283
69645
  for (const possible of config4.schema.getPossibleTypes(typeCondition)) {
69284
69646
  if (possibleParentTypes.includes(possible.name)) {
@@ -69326,7 +69688,7 @@ function selection({
69326
69688
  } else {
69327
69689
  let typeRef = type.getFields()[field.name.value].type;
69328
69690
  fieldType = getRootType(typeRef);
69329
- nullable = !graphql12.isNonNullType(typeRef);
69691
+ nullable = !graphql13.isNonNullType(typeRef);
69330
69692
  }
69331
69693
  const typeName = fieldType.toString();
69332
69694
  const pathSoFar = path2.concat(attributeName);
@@ -69362,14 +69724,23 @@ function selection({
69362
69724
  (directive) => directive.name.value === config4.paginateDirective
69363
69725
  );
69364
69726
  if (paginated && document.refetch && document.refetch.method === "offset") {
69365
- fieldObj.update = document.refetch.update;
69727
+ fieldObj.updates = ["append" /* append */];
69366
69728
  }
69367
- if (attributeName === "edges" && markEdges && document.refetch) {
69368
- fieldObj.update = document.refetch.update;
69369
- markEdges = "";
69729
+ let continueConnection = inConnection;
69730
+ if ([
69731
+ "edges",
69732
+ "endCursor",
69733
+ "startCursor",
69734
+ "hasNextPage",
69735
+ "hasPreviousPage"
69736
+ ].includes(attributeName) && inConnection && document.refetch) {
69737
+ fieldObj.updates = ["append" /* append */, "prepend" /* prepend */];
69738
+ }
69739
+ if (attributeName === "node" && inConnection) {
69740
+ continueConnection = false;
69370
69741
  }
69371
69742
  if (field.selectionSet) {
69372
- const edgesMark = paginated && document.refetch?.method === "cursor" ? document.refetch.update : markEdges;
69743
+ const connectionState = paginated && document.refetch?.method === "cursor" || continueConnection;
69373
69744
  fieldObj.selection = selection({
69374
69745
  config: config4,
69375
69746
  filepath,
@@ -69379,7 +69750,7 @@ function selection({
69379
69750
  path: pathSoFar,
69380
69751
  includeFragments,
69381
69752
  document,
69382
- markEdges: edgesMark
69753
+ inConnection: connectionState
69383
69754
  });
69384
69755
  }
69385
69756
  if (field.arguments?.length && fieldObj.list) {
@@ -69391,7 +69762,7 @@ function selection({
69391
69762
  {}
69392
69763
  );
69393
69764
  }
69394
- if (graphql12.isInterfaceType(fieldType) || graphql12.isUnionType(fieldType)) {
69765
+ if (graphql13.isInterfaceType(fieldType) || graphql13.isUnionType(fieldType)) {
69395
69766
  fieldObj.abstract = true;
69396
69767
  }
69397
69768
  object.fields = {
@@ -69448,7 +69819,7 @@ function artifactGenerator(stats) {
69448
69819
  return async function(config4, docs) {
69449
69820
  const filterTypes = {};
69450
69821
  for (const doc of docs) {
69451
- graphql13.visit(doc.document, {
69822
+ graphql14.visit(doc.document, {
69452
69823
  Directive(node, _, __, ___, ancestors) {
69453
69824
  if (node.name.value !== config4.listDirective) {
69454
69825
  return;
@@ -69507,7 +69878,7 @@ function artifactGenerator(stats) {
69507
69878
  return;
69508
69879
  }
69509
69880
  const usedVariableNames = /* @__PURE__ */ new Set();
69510
- let documentWithoutInternalDirectives = graphql13.visit(document, {
69881
+ let documentWithoutInternalDirectives = graphql14.visit(document, {
69511
69882
  Directive(node) {
69512
69883
  if (config4.isInternalDirective(node)) {
69513
69884
  return null;
@@ -69520,7 +69891,7 @@ function artifactGenerator(stats) {
69520
69891
  }
69521
69892
  }
69522
69893
  });
69523
- let documentWithoutExtraVariables = graphql13.visit(
69894
+ let documentWithoutExtraVariables = graphql14.visit(
69524
69895
  documentWithoutInternalDirectives,
69525
69896
  {
69526
69897
  VariableDefinition(variableDefinitionNode) {
@@ -69531,13 +69902,13 @@ function artifactGenerator(stats) {
69531
69902
  }
69532
69903
  }
69533
69904
  );
69534
- let rawString = graphql13.print(documentWithoutExtraVariables);
69905
+ let rawString = graphql14.print(documentWithoutExtraVariables);
69535
69906
  let docKind = doc.kind;
69536
69907
  const operations = document.definitions.filter(
69537
- ({ kind }) => kind === graphql13.Kind.OPERATION_DEFINITION
69908
+ ({ kind }) => kind === graphql14.Kind.OPERATION_DEFINITION
69538
69909
  );
69539
69910
  const fragments = document.definitions.filter(
69540
- ({ kind }) => kind === graphql13.Kind.FRAGMENT_DEFINITION
69911
+ ({ kind }) => kind === graphql14.Kind.FRAGMENT_DEFINITION
69541
69912
  );
69542
69913
  let rootType = "";
69543
69914
  let selectionSet;
@@ -69570,7 +69941,13 @@ function artifactGenerator(stats) {
69570
69941
  rootType = matchingFragment.typeCondition.name.value;
69571
69942
  selectionSet = matchingFragment.selectionSet;
69572
69943
  }
69573
- const inputs = operations[0]?.variableDefinitions;
69944
+ let inputs = operations[0]?.variableDefinitions;
69945
+ let directive = fragments[0]?.directives?.find(
69946
+ (directive2) => directive2.name.value === config4.argumentsDirective
69947
+ );
69948
+ if (docKind === "HoudiniFragment" /* Fragment */ && directive) {
69949
+ inputs = fragmentArgumentsDefinitions(config4, doc.filename, fragments[0]);
69950
+ }
69574
69951
  const mergedSelection = flattenSelections({
69575
69952
  config: config4,
69576
69953
  filepath: doc.filename,
@@ -69631,7 +70008,7 @@ function artifactGenerator(stats) {
69631
70008
  }
69632
70009
  if (docKind === "HoudiniQuery") {
69633
70010
  const cacheDirective = operations[0].directives?.find(
69634
- (directive) => directive.name.value === config4.cacheDirective
70011
+ (directive2) => directive2.name.value === config4.cacheDirective
69635
70012
  );
69636
70013
  if (cacheDirective) {
69637
70014
  const args = cacheDirective.arguments?.reduce(
@@ -69847,19 +70224,19 @@ async function generatePluginRuntime(config4, plugin) {
69847
70224
  );
69848
70225
  }
69849
70226
 
69850
- // src/codegen/generators/typescript/index.ts
69851
- var recast12 = __toESM(require_main2(), 1);
70227
+ // src/codegen/generators/typescript/documentTypes.ts
70228
+ var recast11 = __toESM(require_main2(), 1);
69852
70229
 
69853
70230
  // src/codegen/generators/typescript/addReferencedInputTypes.ts
69854
- var graphql16 = __toESM(require_graphql2(), 1);
70231
+ var graphql17 = __toESM(require_graphql2(), 1);
69855
70232
  var recast9 = __toESM(require_main2(), 1);
69856
70233
 
69857
70234
  // src/codegen/generators/typescript/typeReference.ts
69858
- var graphql15 = __toESM(require_graphql2(), 1);
70235
+ var graphql16 = __toESM(require_graphql2(), 1);
69859
70236
  var recast8 = __toESM(require_main2(), 1);
69860
70237
 
69861
70238
  // src/codegen/generators/typescript/types.ts
69862
- var graphql14 = __toESM(require_graphql2(), 1);
70239
+ var graphql15 = __toESM(require_graphql2(), 1);
69863
70240
  var recast7 = __toESM(require_main2(), 1);
69864
70241
  var AST7 = recast7.types.builders;
69865
70242
  function readonlyProperty(prop, enable = true) {
@@ -69890,336 +70267,89 @@ function scalarPropertyValue(config4, missingScalars, target) {
69890
70267
  return AST7.tsBooleanKeyword();
69891
70268
  }
69892
70269
  case "ID": {
69893
- return AST7.tsStringKeyword();
69894
- }
69895
- default: {
69896
- if (graphql14.isNonNullType(target) && "ofType" in target) {
69897
- return scalarPropertyValue(
69898
- config4,
69899
- missingScalars,
69900
- target.ofType
69901
- );
69902
- }
69903
- if (config4.scalars?.[target.name]) {
69904
- return AST7.tsTypeReference(AST7.identifier(config4.scalars?.[target.name].type));
69905
- }
69906
- missingScalars.add(target.name);
69907
- return AST7.tsAnyKeyword();
69908
- }
69909
- }
69910
- }
69911
-
69912
- // src/codegen/generators/typescript/typeReference.ts
69913
- var AST8 = recast8.types.builders;
69914
- function tsTypeReference(config4, missingScalars, definition) {
69915
- const { type, wrappers } = unwrapType(config4, definition.type);
69916
- let result;
69917
- if (graphql15.isScalarType(type)) {
69918
- result = scalarPropertyValue(config4, missingScalars, type);
69919
- } else {
69920
- result = AST8.tsTypeReference(AST8.identifier(type.name));
69921
- }
69922
- for (const toWrap of wrappers) {
69923
- if (toWrap === "NonNull" /* NonNull */) {
69924
- continue;
69925
- } else if (toWrap === "Nullable" /* Nullable */) {
69926
- result = nullableField(result, true);
69927
- } else if (toWrap === "List" /* List */) {
69928
- result = AST8.tsArrayType(AST8.tsParenthesizedType(result));
69929
- }
69930
- }
69931
- return result;
69932
- }
69933
-
69934
- // src/codegen/generators/typescript/addReferencedInputTypes.ts
69935
- var AST9 = recast9.types.builders;
69936
- function addReferencedInputTypes(config4, filepath, body, visitedTypes, missingScalars, rootType) {
69937
- const { type } = unwrapType(config4, rootType);
69938
- if (graphql16.isScalarType(type)) {
69939
- return;
69940
- }
69941
- if (visitedTypes.has(type.name)) {
69942
- return;
69943
- }
69944
- if (graphql16.isUnionType(type)) {
69945
- throw new HoudiniError({ filepath, message: "Input Unions are not supported yet. Sorry!" });
69946
- }
69947
- visitedTypes.add(type.name);
69948
- if (graphql16.isEnumType(type)) {
69949
- ensureImports({
69950
- config: config4,
69951
- body,
69952
- import: [type.name],
69953
- sourceModule: "$houdini/graphql/enums",
69954
- importKind: "type"
69955
- });
69956
- return;
69957
- }
69958
- const members = [];
69959
- for (const field of Object.values(type.getFields())) {
69960
- addReferencedInputTypes(config4, filepath, body, visitedTypes, missingScalars, field.type);
69961
- members.push(
69962
- AST9.tsPropertySignature(
69963
- AST9.identifier(field.name),
69964
- AST9.tsTypeAnnotation(tsTypeReference(config4, missingScalars, field)),
69965
- graphql16.isNullableType(field.type)
69966
- )
69967
- );
69968
- }
69969
- body.push(AST9.tsTypeAliasDeclaration(AST9.identifier(type.name), AST9.tsTypeLiteral(members)));
69970
- }
69971
-
69972
- // src/codegen/generators/typescript/imperativeCache.ts
69973
- var graphql17 = __toESM(require_graphql2(), 1);
69974
- var recast10 = __toESM(require_main2(), 1);
69975
- var AST10 = recast10.types.builders;
69976
- async function imperativeCacheTypef(config4, docs) {
69977
- const target = path_exports.join(config4.runtimeDirectory, "generated.d.ts");
69978
- const body = [];
69979
- const declaration = AST10.tsTypeAliasDeclaration(
69980
- AST10.identifier(CacheTypeDefName),
69981
- AST10.tsTypeLiteral([
69982
- AST10.tsPropertySignature(
69983
- AST10.identifier("types"),
69984
- AST10.tsTypeAnnotation(typeDefinitions(config4, body))
69985
- ),
69986
- AST10.tsPropertySignature(
69987
- AST10.identifier("lists"),
69988
- AST10.tsTypeAnnotation(listDefinitions(config4, docs))
69989
- )
69990
- ])
69991
- );
69992
- declaration.declare = true;
69993
- const importRecord = AST10.importDeclaration(
69994
- [AST10.importSpecifier(AST10.identifier("Record"))],
69995
- AST10.stringLiteral("./public/record")
69996
- );
69997
- importRecord.importKind = "type";
69998
- await fs_exports.writeFile(
69999
- target,
70000
- recast10.prettyPrint(
70001
- AST10.program([importRecord, ...body, AST10.exportNamedDeclaration(declaration)])
70002
- ).code
70003
- );
70004
- }
70005
- function typeDefinitions(config4, body) {
70006
- const operationTypes = [config4.schema.getMutationType(), config4.schema.getSubscriptionType()].filter(Boolean).map((type) => type?.name);
70007
- const visitedTypes = /* @__PURE__ */ new Set();
70008
- const types17 = Object.values(config4.schema.getTypeMap()).filter(
70009
- (type) => !graphql17.isAbstractType(type) && !graphql17.isScalarType(type) && !graphql17.isEnumType(type) && !graphql17.isInputObjectType(type) && !type.name.startsWith("__") && !operationTypes.includes(type.name)
70010
- );
70011
- return AST10.tsTypeLiteral(
70012
- types17.map((type) => {
70013
- let typeName = type.name;
70014
- if (config4.schema.getQueryType() && config4.schema.getQueryType()?.name === type.name) {
70015
- typeName = "__ROOT__";
70016
- }
70017
- let idFields = AST10.tsNeverKeyword();
70018
- const keys = keyFieldsForType(config4.configFile, type.name);
70019
- if (graphql17.isObjectType(type) && keys.length > 0 && keys.every((key) => type.getFields()[key])) {
70020
- idFields = AST10.tsTypeLiteral(
70021
- keys.map((key) => {
70022
- const fieldType = type.getFields()[key];
70023
- const unwrapped = unwrapType(config4, fieldType.type);
70024
- return AST10.tsPropertySignature(
70025
- AST10.identifier(key),
70026
- AST10.tsTypeAnnotation(
70027
- scalarPropertyValue(config4, /* @__PURE__ */ new Set(), unwrapped.type)
70028
- )
70029
- );
70030
- })
70031
- );
70032
- } else if (typeName === "__ROOT__") {
70033
- idFields = AST10.tsTypeLiteral([]);
70034
- }
70035
- let fields = AST10.tsTypeLiteral([]);
70036
- if (graphql17.isObjectType(type)) {
70037
- fields = AST10.tsTypeLiteral(
70038
- Object.entries(type.getFields()).map(
70039
- ([key, fieldType]) => {
70040
- const unwrapped = unwrapType(config4, fieldType.type);
70041
- let typeOptions = AST10.tsUnionType([]);
70042
- if (graphql17.isScalarType(unwrapped.type)) {
70043
- typeOptions.types.push(
70044
- scalarPropertyValue(config4, /* @__PURE__ */ new Set(), unwrapped.type)
70045
- );
70046
- } else if (graphql17.isEnumType(unwrapped.type)) {
70047
- typeOptions.types.push(
70048
- AST10.tsTypeReference(AST10.identifier(unwrapped.type.name))
70049
- );
70050
- } else if (!graphql17.isAbstractType(unwrapped.type)) {
70051
- typeOptions.types.push(record(unwrapped.type.name));
70052
- } else {
70053
- typeOptions.types.push(
70054
- ...config4.schema.getPossibleTypes(unwrapped.type).map((type2) => record(type2.name))
70055
- );
70056
- }
70057
- for (const wrapper of unwrapped.wrappers) {
70058
- if (wrapper === "Nullable" /* Nullable */) {
70059
- typeOptions = AST10.tsParenthesizedType(
70060
- AST10.tsUnionType([typeOptions, AST10.tsNullKeyword()])
70061
- );
70062
- } else if (wrapper === "List" /* List */) {
70063
- typeOptions = AST10.tsArrayType(
70064
- AST10.tsParenthesizedType(typeOptions)
70065
- );
70066
- }
70067
- }
70068
- if (typeOptions.type === "TSParenthesizedType") {
70069
- typeOptions = typeOptions.typeAnnotation;
70070
- }
70071
- let args = AST10.tsNeverKeyword();
70072
- if (fieldType.args?.length > 0) {
70073
- args = AST10.tsTypeLiteral(
70074
- fieldType.args.map((arg) => {
70075
- addReferencedInputTypes(
70076
- config4,
70077
- "",
70078
- body,
70079
- visitedTypes,
70080
- /* @__PURE__ */ new Set(),
70081
- arg.type
70082
- );
70083
- const prop = AST10.tsPropertySignature(
70084
- AST10.identifier(arg.name),
70085
- AST10.tsTypeAnnotation(
70086
- tsTypeReference(config4, /* @__PURE__ */ new Set(), arg)
70087
- )
70088
- );
70089
- const unwrapped2 = unwrapType(config4, arg.type);
70090
- prop.optional = unwrapped2.wrappers[unwrapped2.wrappers.length - 1] === "Nullable" /* Nullable */;
70091
- return prop;
70092
- })
70093
- );
70094
- }
70095
- return AST10.tsPropertySignature(
70096
- AST10.identifier(key),
70097
- AST10.tsTypeAnnotation(
70098
- AST10.tsTypeLiteral([
70099
- AST10.tsPropertySignature(
70100
- AST10.identifier("type"),
70101
- AST10.tsTypeAnnotation(typeOptions)
70102
- ),
70103
- AST10.tsPropertySignature(
70104
- AST10.identifier("args"),
70105
- AST10.tsTypeAnnotation(args)
70106
- )
70107
- ])
70108
- )
70109
- );
70110
- }
70111
- )
70270
+ return AST7.tsStringKeyword();
70271
+ }
70272
+ default: {
70273
+ if (graphql15.isNonNullType(target) && "ofType" in target) {
70274
+ return scalarPropertyValue(
70275
+ config4,
70276
+ missingScalars,
70277
+ target.ofType
70112
70278
  );
70113
70279
  }
70114
- return AST10.tsPropertySignature(
70115
- AST10.identifier(typeName),
70116
- AST10.tsTypeAnnotation(
70117
- AST10.tsTypeLiteral([
70118
- AST10.tsPropertySignature(
70119
- AST10.identifier("idFields"),
70120
- AST10.tsTypeAnnotation(idFields)
70121
- ),
70122
- AST10.tsPropertySignature(
70123
- AST10.identifier("fields"),
70124
- AST10.tsTypeAnnotation(fields)
70125
- )
70126
- ])
70127
- )
70128
- );
70129
- })
70130
- );
70131
- }
70132
- function listDefinitions(config4, docs) {
70133
- const lists = [];
70134
- const visitedLists = /* @__PURE__ */ new Set();
70135
- for (const doc of docs) {
70136
- graphql17.visit(doc.document, {
70137
- Directive(node, key, parent, path2, ancestors) {
70138
- if (![config4.listDirective, config4.paginateDirective].includes(node.name.value)) {
70139
- return;
70140
- }
70141
- const nameArg = node.arguments?.find((arg) => arg.name.value === "name");
70142
- const nameValue = nameArg?.value?.value || "";
70143
- if (!nameValue || visitedLists.has(nameValue)) {
70144
- return;
70145
- }
70146
- visitedLists.add(nameValue);
70147
- const parentType = parentTypeFromAncestors(
70148
- config4.schema,
70149
- doc.filename,
70150
- ancestors.slice(0, -1)
70151
- );
70152
- const targetField = ancestors[ancestors.length - 1];
70153
- const targetFieldDefinition = parentType.getFields()[targetField.name.value];
70154
- const { type: listType } = unwrapType(config4, targetFieldDefinition.type);
70155
- const possibleTypes = [];
70156
- if (graphql17.isAbstractType(listType)) {
70157
- possibleTypes.push(
70158
- ...config4.schema.getPossibleTypes(listType).map((possible) => possible.name)
70159
- );
70160
- } else {
70161
- possibleTypes.push(listType.name);
70162
- }
70163
- lists.push(
70164
- AST10.tsPropertySignature(
70165
- AST10.identifier(nameValue),
70166
- AST10.tsTypeAnnotation(
70167
- AST10.tsTypeLiteral([
70168
- AST10.tsPropertySignature(
70169
- AST10.identifier("types"),
70170
- AST10.tsTypeAnnotation(
70171
- AST10.tsUnionType(
70172
- possibleTypes.map(
70173
- (possible) => AST10.tsLiteralType(AST10.stringLiteral(possible))
70174
- )
70175
- )
70176
- )
70177
- ),
70178
- AST10.tsPropertySignature(
70179
- AST10.identifier("filters"),
70180
- AST10.tsTypeAnnotation(
70181
- targetFieldDefinition.args.length === 0 ? AST10.tsNeverKeyword() : AST10.tsTypeLiteral(
70182
- targetFieldDefinition.args.map((arg) => {
70183
- const argDef = AST10.tsPropertySignature(
70184
- AST10.identifier(arg.name),
70185
- AST10.tsTypeAnnotation(
70186
- tsTypeReference(
70187
- config4,
70188
- /* @__PURE__ */ new Set(),
70189
- arg
70190
- )
70191
- )
70192
- );
70193
- argDef.optional = true;
70194
- return argDef;
70195
- })
70196
- )
70197
- )
70198
- )
70199
- ])
70200
- )
70201
- )
70202
- );
70280
+ if (config4.scalars?.[target.name]) {
70281
+ return AST7.tsTypeReference(AST7.identifier(config4.scalars?.[target.name].type));
70203
70282
  }
70204
- });
70283
+ missingScalars.add(target.name);
70284
+ return AST7.tsAnyKeyword();
70285
+ }
70205
70286
  }
70206
- return AST10.tsTypeLiteral(lists);
70207
70287
  }
70208
- var CacheTypeDefName = "CacheTypeDef";
70209
- function record(name2) {
70210
- return AST10.tsTypeReference(
70211
- AST10.identifier("Record"),
70212
- AST10.tsTypeParameterInstantiation([
70213
- AST10.tsTypeReference(AST10.identifier(CacheTypeDefName)),
70214
- AST10.tsLiteralType(AST10.stringLiteral(name2))
70215
- ])
70216
- );
70288
+
70289
+ // src/codegen/generators/typescript/typeReference.ts
70290
+ var AST8 = recast8.types.builders;
70291
+ function tsTypeReference(config4, missingScalars, definition) {
70292
+ const { type, wrappers } = unwrapType(config4, definition.type);
70293
+ let result;
70294
+ if (graphql16.isScalarType(type)) {
70295
+ result = scalarPropertyValue(config4, missingScalars, type);
70296
+ } else {
70297
+ result = AST8.tsTypeReference(AST8.identifier(type.name));
70298
+ }
70299
+ for (const toWrap of wrappers) {
70300
+ if (toWrap === "NonNull" /* NonNull */) {
70301
+ continue;
70302
+ } else if (toWrap === "Nullable" /* Nullable */) {
70303
+ result = nullableField(result, true);
70304
+ } else if (toWrap === "List" /* List */) {
70305
+ result = AST8.tsArrayType(AST8.tsParenthesizedType(result));
70306
+ }
70307
+ }
70308
+ return result;
70309
+ }
70310
+
70311
+ // src/codegen/generators/typescript/addReferencedInputTypes.ts
70312
+ var AST9 = recast9.types.builders;
70313
+ function addReferencedInputTypes(config4, filepath, body, visitedTypes, missingScalars, rootType) {
70314
+ const { type } = unwrapType(config4, rootType);
70315
+ if (graphql17.isScalarType(type)) {
70316
+ return;
70317
+ }
70318
+ if (visitedTypes.has(type.name)) {
70319
+ return;
70320
+ }
70321
+ if (graphql17.isUnionType(type)) {
70322
+ throw new HoudiniError({ filepath, message: "Input Unions are not supported yet. Sorry!" });
70323
+ }
70324
+ visitedTypes.add(type.name);
70325
+ if (graphql17.isEnumType(type)) {
70326
+ ensureImports({
70327
+ config: config4,
70328
+ body,
70329
+ import: [type.name],
70330
+ sourceModule: "$houdini/graphql/enums",
70331
+ importKind: "type"
70332
+ });
70333
+ return;
70334
+ }
70335
+ const members = [];
70336
+ for (const field of Object.values(type.getFields())) {
70337
+ addReferencedInputTypes(config4, filepath, body, visitedTypes, missingScalars, field.type);
70338
+ members.push(
70339
+ AST9.tsPropertySignature(
70340
+ AST9.identifier(field.name),
70341
+ AST9.tsTypeAnnotation(tsTypeReference(config4, missingScalars, field)),
70342
+ graphql17.isNullableType(field.type)
70343
+ )
70344
+ );
70345
+ }
70346
+ body.push(AST9.tsTypeAliasDeclaration(AST9.identifier(type.name), AST9.tsTypeLiteral(members)));
70217
70347
  }
70218
70348
 
70219
70349
  // src/codegen/generators/typescript/inlineType.ts
70220
70350
  var graphql18 = __toESM(require_graphql2(), 1);
70221
- var recast11 = __toESM(require_main2(), 1);
70222
- var AST11 = recast11.types.builders;
70351
+ var recast10 = __toESM(require_main2(), 1);
70352
+ var AST10 = recast10.types.builders;
70223
70353
  var fragmentKey = "$fragments";
70224
70354
  function inlineType({
70225
70355
  config: config4,
@@ -70248,7 +70378,7 @@ function inlineType({
70248
70378
  });
70249
70379
  visitedTypes.add(type.name);
70250
70380
  }
70251
- result = AST11.tsTypeReference(AST11.identifier(type.name));
70381
+ result = AST10.tsTypeReference(AST10.identifier(type.name));
70252
70382
  } else if (selections) {
70253
70383
  const rootObj = type;
70254
70384
  const inlineFragments = {};
@@ -70299,7 +70429,7 @@ function inlineType({
70299
70429
  selectedFields.push(selection2);
70300
70430
  }
70301
70431
  }
70302
- result = AST11.tsTypeLiteral([
70432
+ result = AST10.tsTypeLiteral([
70303
70433
  ...(selectedFields || []).filter(
70304
70434
  (field) => field.kind === "Field"
70305
70435
  ).map((selection2) => {
@@ -70319,9 +70449,9 @@ function inlineType({
70319
70449
  allOptional
70320
70450
  });
70321
70451
  const prop = readonlyProperty(
70322
- AST11.tsPropertySignature(
70323
- AST11.identifier(attributeName),
70324
- AST11.tsTypeAnnotation(attributeType)
70452
+ AST10.tsPropertySignature(
70453
+ AST10.identifier(attributeName),
70454
+ AST10.tsTypeAnnotation(attributeType)
70325
70455
  ),
70326
70456
  allowReadonly
70327
70457
  );
@@ -70335,15 +70465,15 @@ function inlineType({
70335
70465
  if (includeFragments && fragmentSpreads && fragmentSpreads.length) {
70336
70466
  result.members.push(
70337
70467
  readonlyProperty(
70338
- AST11.tsPropertySignature(
70339
- AST11.identifier(fragmentKey),
70340
- AST11.tsTypeAnnotation(
70341
- AST11.tsTypeLiteral(
70468
+ AST10.tsPropertySignature(
70469
+ AST10.identifier(fragmentKey),
70470
+ AST10.tsTypeAnnotation(
70471
+ AST10.tsTypeLiteral(
70342
70472
  (fragmentSpreads || []).map(
70343
- (fragmentSpread) => AST11.tsPropertySignature(
70344
- AST11.identifier(fragmentSpread.name.value),
70345
- AST11.tsTypeAnnotation(
70346
- AST11.tsLiteralType(AST11.booleanLiteral(true))
70473
+ (fragmentSpread) => AST10.tsPropertySignature(
70474
+ AST10.identifier(fragmentSpread.name.value),
70475
+ AST10.tsTypeAnnotation(
70476
+ AST10.tsLiteralType(AST10.booleanLiteral(true))
70347
70477
  )
70348
70478
  )
70349
70479
  )
@@ -70389,9 +70519,9 @@ function inlineType({
70389
70519
  }
70390
70520
  objectType.members.push(
70391
70521
  readonlyProperty(
70392
- AST11.tsPropertySignature(
70393
- AST11.identifier("__typename"),
70394
- AST11.tsTypeAnnotation(AST11.tsLiteralType(AST11.stringLiteral(typeName)))
70522
+ AST10.tsPropertySignature(
70523
+ AST10.identifier("__typename"),
70524
+ AST10.tsTypeAnnotation(AST10.tsLiteralType(AST10.stringLiteral(typeName)))
70395
70525
  ),
70396
70526
  allowReadonly
70397
70527
  )
@@ -70402,8 +70532,8 @@ function inlineType({
70402
70532
  if (Object.keys(inlineFragmentSelections).length > 0) {
70403
70533
  let selectionTypes = Object.entries(inlineFragmentSelections).map(
70404
70534
  ([typeName, { type: type2, tsType }]) => {
70405
- return AST11.tsParenthesizedType(
70406
- AST11.tsIntersectionType(
70535
+ return AST10.tsParenthesizedType(
70536
+ AST10.tsIntersectionType(
70407
70537
  [tsType].flatMap((type3) => {
70408
70538
  if (type3.type === "TSUnionType") {
70409
70539
  return type3.types.filter(
@@ -70416,9 +70546,9 @@ function inlineType({
70416
70546
  );
70417
70547
  }
70418
70548
  );
70419
- result = AST11.tsIntersectionType([
70549
+ result = AST10.tsIntersectionType([
70420
70550
  result,
70421
- AST11.tsParenthesizedType(AST11.tsUnionType(selectionTypes))
70551
+ AST10.tsParenthesizedType(AST10.tsUnionType(selectionTypes))
70422
70552
  ]);
70423
70553
  }
70424
70554
  } else {
@@ -70430,7 +70560,7 @@ function inlineType({
70430
70560
  } else if (toWrap === "NonNull" /* NonNull */) {
70431
70561
  continue;
70432
70562
  } else if (toWrap === "List" /* List */) {
70433
- result = AST11.tsArrayType(AST11.tsParenthesizedType(result));
70563
+ result = AST10.tsArrayType(AST10.tsParenthesizedType(result));
70434
70564
  }
70435
70565
  }
70436
70566
  return result;
@@ -70474,9 +70604,9 @@ function selectionTypeInfo(schema, filepath, rootType, selection2) {
70474
70604
  return { field, type: selectionType };
70475
70605
  }
70476
70606
 
70477
- // src/codegen/generators/typescript/index.ts
70478
- var AST12 = recast12.types.builders;
70479
- async function typescriptGenerator(config4, docs) {
70607
+ // src/codegen/generators/typescript/documentTypes.ts
70608
+ var AST11 = recast11.types.builders;
70609
+ async function generateDocumentTypes(config4, docs) {
70480
70610
  const typePaths = [];
70481
70611
  const fragmentDefinitions = {};
70482
70612
  for (const document of docs) {
@@ -70493,7 +70623,7 @@ async function typescriptGenerator(config4, docs) {
70493
70623
  return;
70494
70624
  }
70495
70625
  const typeDefPath = config4.artifactTypePath(originalDocument);
70496
- const program = AST12.program([]);
70626
+ const program = AST11.program([]);
70497
70627
  const visitedTypes = /* @__PURE__ */ new Set();
70498
70628
  let definition = originalDocument.definitions.find(
70499
70629
  (def) => (def.kind === "OperationDefinition" || def.kind === "FragmentDefinition") && def.name?.value === name2
@@ -70526,21 +70656,21 @@ async function typescriptGenerator(config4, docs) {
70526
70656
  missingScalars
70527
70657
  );
70528
70658
  }
70529
- await fs_exports.writeFile(typeDefPath, recast12.print(program).code);
70659
+ await fs_exports.writeFile(typeDefPath, recast11.print(program).code);
70530
70660
  typePaths.push(typeDefPath);
70531
70661
  })
70532
70662
  );
70533
- const typeIndex = AST12.program(
70663
+ const typeIndex = AST11.program(
70534
70664
  typePaths.sort((a, b) => a.localeCompare(b)).map((typePath) => {
70535
- return AST12.exportAllDeclaration(
70536
- AST12.literal(
70665
+ return AST11.exportAllDeclaration(
70666
+ AST11.literal(
70537
70667
  "./" + path_exports.relative(path_exports.resolve(config4.typeIndexPath, ".."), typePath).replace(/\.[^/.]+\.[^/.]+$/, "")
70538
70668
  ),
70539
70669
  null
70540
70670
  );
70541
70671
  }).concat([
70542
- AST12.exportAllDeclaration(AST12.literal("./runtime"), null),
70543
- AST12.exportAllDeclaration(AST12.literal("./graphql"), null)
70672
+ AST11.exportAllDeclaration(AST11.literal("./runtime"), null),
70673
+ AST11.exportAllDeclaration(AST11.literal("./graphql"), null)
70544
70674
  ])
70545
70675
  );
70546
70676
  const export_default_as = ({ module, as }) => `
@@ -70549,7 +70679,7 @@ export { default as ${as} } from "${module}"
70549
70679
  const export_star_from = ({ module }) => `
70550
70680
  export * from "${module}"
70551
70681
  `;
70552
- let indexContent = recast12.print(typeIndex).code;
70682
+ let indexContent = recast11.print(typeIndex).code;
70553
70683
  for (const plugin of config4.plugins) {
70554
70684
  if (!plugin.index_file) {
70555
70685
  continue;
@@ -70570,7 +70700,6 @@ export * from "${module}"
70570
70700
  }
70571
70701
  }
70572
70702
  await fs_exports.writeFile(config4.typeIndexPath, indexContent);
70573
- await imperativeCacheTypef(config4, docs);
70574
70703
  if (missingScalars.size > 0) {
70575
70704
  console.warn(`\u26A0\uFE0F Missing definitions for the following scalars: ${[...missingScalars].join(
70576
70705
  ", "
@@ -70612,23 +70741,23 @@ async function generateOperationTypeDefs(config4, filepath, body, definition, se
70612
70741
  const optimisticTypeName = `${definition.name.value}$optimistic`;
70613
70742
  const hasInputs = definition.variableDefinitions && definition.variableDefinitions.length > 0;
70614
70743
  body.push(
70615
- AST12.exportNamedDeclaration(
70616
- AST12.tsTypeAliasDeclaration(
70617
- AST12.identifier(definition.name.value),
70618
- AST12.tsTypeLiteral([
70744
+ AST11.exportNamedDeclaration(
70745
+ AST11.tsTypeAliasDeclaration(
70746
+ AST11.identifier(definition.name.value),
70747
+ AST11.tsTypeLiteral([
70619
70748
  readonlyProperty(
70620
- AST12.tsPropertySignature(
70621
- AST12.stringLiteral("input"),
70622
- AST12.tsTypeAnnotation(AST12.tsTypeReference(AST12.identifier(inputTypeName)))
70749
+ AST11.tsPropertySignature(
70750
+ AST11.stringLiteral("input"),
70751
+ AST11.tsTypeAnnotation(AST11.tsTypeReference(AST11.identifier(inputTypeName)))
70623
70752
  )
70624
70753
  ),
70625
70754
  readonlyProperty(
70626
- AST12.tsPropertySignature(
70627
- AST12.stringLiteral("result"),
70628
- AST12.tsTypeAnnotation(
70629
- definition.operation === "mutation" ? AST12.tsTypeReference(AST12.identifier(shapeTypeName)) : AST12.tsUnionType([
70630
- AST12.tsTypeReference(AST12.identifier(shapeTypeName)),
70631
- AST12.tsUndefinedKeyword()
70755
+ AST11.tsPropertySignature(
70756
+ AST11.stringLiteral("result"),
70757
+ AST11.tsTypeAnnotation(
70758
+ definition.operation === "mutation" ? AST11.tsTypeReference(AST11.identifier(shapeTypeName)) : AST11.tsUnionType([
70759
+ AST11.tsTypeReference(AST11.identifier(shapeTypeName)),
70760
+ AST11.tsUndefinedKeyword()
70632
70761
  ])
70633
70762
  )
70634
70763
  )
@@ -70636,9 +70765,9 @@ async function generateOperationTypeDefs(config4, filepath, body, definition, se
70636
70765
  ])
70637
70766
  )
70638
70767
  ),
70639
- AST12.exportNamedDeclaration(
70640
- AST12.tsTypeAliasDeclaration(
70641
- AST12.identifier(shapeTypeName),
70768
+ AST11.exportNamedDeclaration(
70769
+ AST11.tsTypeAliasDeclaration(
70770
+ AST11.identifier(shapeTypeName),
70642
70771
  inlineType({
70643
70772
  config: config4,
70644
70773
  filepath,
@@ -70666,15 +70795,15 @@ async function generateOperationTypeDefs(config4, filepath, body, definition, se
70666
70795
  );
70667
70796
  }
70668
70797
  body.push(
70669
- AST12.exportNamedDeclaration(
70670
- AST12.tsTypeAliasDeclaration(
70671
- AST12.identifier(inputTypeName),
70672
- AST12.tsTypeLiteral(
70798
+ AST11.exportNamedDeclaration(
70799
+ AST11.tsTypeAliasDeclaration(
70800
+ AST11.identifier(inputTypeName),
70801
+ AST11.tsTypeLiteral(
70673
70802
  (definition.variableDefinitions || []).map(
70674
70803
  (definition2) => {
70675
- return AST12.tsPropertySignature(
70676
- AST12.identifier(definition2.variable.name.value),
70677
- AST12.tsTypeAnnotation(
70804
+ return AST11.tsPropertySignature(
70805
+ AST11.identifier(definition2.variable.name.value),
70806
+ AST11.tsTypeAnnotation(
70678
70807
  tsTypeReference(config4, missingScalars, definition2)
70679
70808
  ),
70680
70809
  definition2.type.kind !== "NonNullType"
@@ -70687,16 +70816,16 @@ async function generateOperationTypeDefs(config4, filepath, body, definition, se
70687
70816
  );
70688
70817
  } else {
70689
70818
  body.push(
70690
- AST12.exportNamedDeclaration(
70691
- AST12.tsTypeAliasDeclaration(AST12.identifier(inputTypeName), AST12.tsNullKeyword())
70819
+ AST11.exportNamedDeclaration(
70820
+ AST11.tsTypeAliasDeclaration(AST11.identifier(inputTypeName), AST11.tsNullKeyword())
70692
70821
  )
70693
70822
  );
70694
70823
  }
70695
70824
  if (definition.operation === "mutation") {
70696
70825
  body.push(
70697
- AST12.exportNamedDeclaration(
70698
- AST12.tsTypeAliasDeclaration(
70699
- AST12.identifier(optimisticTypeName),
70826
+ AST11.exportNamedDeclaration(
70827
+ AST11.tsTypeAliasDeclaration(
70828
+ AST11.identifier(optimisticTypeName),
70700
70829
  inlineType({
70701
70830
  config: config4,
70702
70831
  filepath,
@@ -70722,65 +70851,463 @@ async function generateFragmentTypeDefs(config4, filepath, body, selections, def
70722
70851
  }
70723
70852
  const propTypeName = definition.name.value;
70724
70853
  const shapeTypeName = `${definition.name.value}$data`;
70854
+ const inputTypeName = `${definition.name.value}$input`;
70725
70855
  const type = config4.schema.getType(definition.typeCondition.name.value);
70726
70856
  if (!type) {
70727
70857
  throw new Error("Should not get here");
70728
70858
  }
70859
+ let extraExports = [];
70860
+ let directive = definition.directives?.find(
70861
+ (directive2) => directive2.name.value === config4.argumentsDirective
70862
+ );
70863
+ if (directive) {
70864
+ extraExports.push(
70865
+ AST11.exportNamedDeclaration(
70866
+ AST11.tsTypeAliasDeclaration(
70867
+ AST11.identifier(inputTypeName),
70868
+ AST11.tsTypeLiteral(
70869
+ (fragmentArgumentsDefinitions(config4, filepath, definition) || []).map(
70870
+ (definition2) => {
70871
+ return AST11.tsPropertySignature(
70872
+ AST11.identifier(definition2.variable.name.value),
70873
+ AST11.tsTypeAnnotation(
70874
+ tsTypeReference(config4, missingScalars, definition2)
70875
+ ),
70876
+ definition2.type.kind !== "NonNullType"
70877
+ );
70878
+ }
70879
+ )
70880
+ )
70881
+ )
70882
+ )
70883
+ );
70884
+ }
70729
70885
  body.push(
70730
- AST12.exportNamedDeclaration(
70731
- AST12.tsTypeAliasDeclaration(
70732
- AST12.identifier(propTypeName),
70733
- AST12.tsTypeLiteral([
70886
+ ...extraExports,
70887
+ AST11.exportNamedDeclaration(
70888
+ AST11.tsTypeAliasDeclaration(
70889
+ AST11.identifier(propTypeName),
70890
+ AST11.tsTypeLiteral([
70734
70891
  readonlyProperty(
70735
- AST12.tsPropertySignature(
70736
- AST12.stringLiteral("shape"),
70737
- AST12.tsTypeAnnotation(
70738
- AST12.tsTypeReference(AST12.identifier(shapeTypeName))
70892
+ AST11.tsPropertySignature(
70893
+ AST11.stringLiteral("shape"),
70894
+ AST11.tsTypeAnnotation(
70895
+ AST11.tsTypeReference(AST11.identifier(shapeTypeName))
70739
70896
  ),
70740
70897
  true
70741
70898
  )
70742
70899
  ),
70743
70900
  readonlyProperty(
70744
- AST12.tsPropertySignature(
70745
- AST12.stringLiteral(fragmentKey),
70901
+ AST11.tsPropertySignature(
70902
+ AST11.stringLiteral(fragmentKey),
70903
+ AST11.tsTypeAnnotation(
70904
+ AST11.tsTypeLiteral([
70905
+ AST11.tsPropertySignature(
70906
+ AST11.stringLiteral(propTypeName),
70907
+ AST11.tsTypeAnnotation(
70908
+ AST11.tsLiteralType(AST11.booleanLiteral(true))
70909
+ )
70910
+ )
70911
+ ])
70912
+ )
70913
+ )
70914
+ )
70915
+ ])
70916
+ )
70917
+ ),
70918
+ AST11.exportNamedDeclaration(
70919
+ AST11.tsTypeAliasDeclaration(
70920
+ AST11.identifier(shapeTypeName),
70921
+ inlineType({
70922
+ config: config4,
70923
+ filepath,
70924
+ rootType: type,
70925
+ selections,
70926
+ root: true,
70927
+ allowReadonly: true,
70928
+ body,
70929
+ visitedTypes,
70930
+ missingScalars,
70931
+ includeFragments: true
70932
+ })
70933
+ )
70934
+ )
70935
+ );
70936
+ }
70937
+ }
70938
+
70939
+ // src/codegen/generators/typescript/imperativeTypeDef.ts
70940
+ var graphql19 = __toESM(require_graphql2(), 1);
70941
+ var recast12 = __toESM(require_main2(), 1);
70942
+ var AST12 = recast12.types.builders;
70943
+ async function imperativeCacheTypef(config4, docs) {
70944
+ const returnType = (doc) => config4.plugins.find((plugin) => plugin.graphql_tag_return)?.graphql_tag_return?.({
70945
+ config: config4,
70946
+ doc,
70947
+ ensure_import({ identifier, module }) {
70948
+ ensureImports({
70949
+ config: config4,
70950
+ body,
70951
+ sourceModule: module,
70952
+ import: [identifier]
70953
+ });
70954
+ }
70955
+ }) ?? "any";
70956
+ const target = path_exports.join(config4.runtimeDirectory, "generated.d.ts");
70957
+ const body = [];
70958
+ const declaration = AST12.tsTypeAliasDeclaration(
70959
+ AST12.identifier(CacheTypeDefName),
70960
+ AST12.tsTypeLiteral([
70961
+ AST12.tsPropertySignature(
70962
+ AST12.identifier("types"),
70963
+ AST12.tsTypeAnnotation(typeDefinitions(config4, body, docs, returnType))
70964
+ ),
70965
+ AST12.tsPropertySignature(
70966
+ AST12.identifier("lists"),
70967
+ AST12.tsTypeAnnotation(listDefinitions(config4, docs))
70968
+ ),
70969
+ AST12.tsPropertySignature(
70970
+ AST12.identifier("queries"),
70971
+ AST12.tsTypeAnnotation(queryDefinitions(config4, body, docs, returnType))
70972
+ )
70973
+ ])
70974
+ );
70975
+ declaration.declare = true;
70976
+ const importRecord = AST12.importDeclaration(
70977
+ [AST12.importSpecifier(AST12.identifier("Record"))],
70978
+ AST12.stringLiteral("./public/record")
70979
+ );
70980
+ importRecord.importKind = "type";
70981
+ await fs_exports.writeFile(
70982
+ target,
70983
+ recast12.prettyPrint(
70984
+ AST12.program([importRecord, ...body, AST12.exportNamedDeclaration(declaration)])
70985
+ ).code
70986
+ );
70987
+ }
70988
+ function typeDefinitions(config4, body, docs, returnType) {
70989
+ const operationTypes = [config4.schema.getMutationType(), config4.schema.getSubscriptionType()].filter(Boolean).map((type) => type?.name);
70990
+ const visitedTypes = /* @__PURE__ */ new Set();
70991
+ const types17 = Object.values(config4.schema.getTypeMap()).filter(
70992
+ (type) => !graphql19.isAbstractType(type) && !graphql19.isScalarType(type) && !graphql19.isEnumType(type) && !graphql19.isInputObjectType(type) && !type.name.startsWith("__") && !operationTypes.includes(type.name)
70993
+ );
70994
+ const fragmentMap = fragmentListMap(
70995
+ config4,
70996
+ types17.map((type) => type.name),
70997
+ body,
70998
+ docs,
70999
+ returnType
71000
+ );
71001
+ return AST12.tsTypeLiteral(
71002
+ types17.map((type) => {
71003
+ let typeName = type.name;
71004
+ if (config4.schema.getQueryType() && config4.schema.getQueryType()?.name === type.name) {
71005
+ typeName = "__ROOT__";
71006
+ }
71007
+ let idFields = AST12.tsNeverKeyword();
71008
+ const keys = keyFieldsForType(config4.configFile, type.name);
71009
+ if (graphql19.isObjectType(type) && keys.length > 0 && keys.every((key) => type.getFields()[key])) {
71010
+ idFields = AST12.tsTypeLiteral(
71011
+ keys.map((key) => {
71012
+ const fieldType = type.getFields()[key];
71013
+ const unwrapped = unwrapType(config4, fieldType.type);
71014
+ return AST12.tsPropertySignature(
71015
+ AST12.identifier(key),
71016
+ AST12.tsTypeAnnotation(
71017
+ scalarPropertyValue(config4, /* @__PURE__ */ new Set(), unwrapped.type)
71018
+ )
71019
+ );
71020
+ })
71021
+ );
71022
+ } else if (typeName === "__ROOT__") {
71023
+ idFields = AST12.tsTypeLiteral([]);
71024
+ }
71025
+ let fields = AST12.tsTypeLiteral([]);
71026
+ if (graphql19.isObjectType(type)) {
71027
+ fields = AST12.tsTypeLiteral(
71028
+ Object.entries(type.getFields()).map(
71029
+ ([key, fieldType]) => {
71030
+ const unwrapped = unwrapType(config4, fieldType.type);
71031
+ let typeOptions = AST12.tsUnionType([]);
71032
+ if (graphql19.isScalarType(unwrapped.type)) {
71033
+ typeOptions.types.push(
71034
+ scalarPropertyValue(config4, /* @__PURE__ */ new Set(), unwrapped.type)
71035
+ );
71036
+ } else if (graphql19.isEnumType(unwrapped.type)) {
71037
+ typeOptions.types.push(
71038
+ AST12.tsTypeReference(AST12.identifier(unwrapped.type.name))
71039
+ );
71040
+ } else if (!graphql19.isAbstractType(unwrapped.type)) {
71041
+ typeOptions.types.push(record(unwrapped.type.name));
71042
+ } else {
71043
+ typeOptions.types.push(
71044
+ ...config4.schema.getPossibleTypes(unwrapped.type).map((type2) => record(type2.name))
71045
+ );
71046
+ }
71047
+ for (const wrapper of unwrapped.wrappers) {
71048
+ if (wrapper === "Nullable" /* Nullable */) {
71049
+ typeOptions = AST12.tsParenthesizedType(
71050
+ AST12.tsUnionType([typeOptions, AST12.tsNullKeyword()])
71051
+ );
71052
+ } else if (wrapper === "List" /* List */) {
71053
+ typeOptions = AST12.tsArrayType(
71054
+ AST12.tsParenthesizedType(typeOptions)
71055
+ );
71056
+ }
71057
+ }
71058
+ if (typeOptions.type === "TSParenthesizedType") {
71059
+ typeOptions = typeOptions.typeAnnotation;
71060
+ }
71061
+ let args = AST12.tsNeverKeyword();
71062
+ if (fieldType.args?.length > 0) {
71063
+ args = AST12.tsTypeLiteral(
71064
+ fieldType.args.map((arg) => {
71065
+ addReferencedInputTypes(
71066
+ config4,
71067
+ "",
71068
+ body,
71069
+ visitedTypes,
71070
+ /* @__PURE__ */ new Set(),
71071
+ arg.type
71072
+ );
71073
+ const prop = AST12.tsPropertySignature(
71074
+ AST12.identifier(arg.name),
71075
+ AST12.tsTypeAnnotation(
71076
+ tsTypeReference(config4, /* @__PURE__ */ new Set(), arg)
71077
+ )
71078
+ );
71079
+ const unwrapped2 = unwrapType(config4, arg.type);
71080
+ prop.optional = unwrapped2.wrappers[unwrapped2.wrappers.length - 1] === "Nullable" /* Nullable */;
71081
+ return prop;
71082
+ })
71083
+ );
71084
+ }
71085
+ return AST12.tsPropertySignature(
71086
+ AST12.identifier(key),
70746
71087
  AST12.tsTypeAnnotation(
70747
71088
  AST12.tsTypeLiteral([
70748
71089
  AST12.tsPropertySignature(
70749
- AST12.stringLiteral(propTypeName),
70750
- AST12.tsTypeAnnotation(
70751
- AST12.tsLiteralType(AST12.booleanLiteral(true))
70752
- )
71090
+ AST12.identifier("type"),
71091
+ AST12.tsTypeAnnotation(typeOptions)
71092
+ ),
71093
+ AST12.tsPropertySignature(
71094
+ AST12.identifier("args"),
71095
+ AST12.tsTypeAnnotation(args)
70753
71096
  )
70754
71097
  ])
70755
71098
  )
70756
- )
71099
+ );
71100
+ }
71101
+ )
71102
+ );
71103
+ }
71104
+ return AST12.tsPropertySignature(
71105
+ AST12.identifier(typeName),
71106
+ AST12.tsTypeAnnotation(
71107
+ AST12.tsTypeLiteral([
71108
+ AST12.tsPropertySignature(
71109
+ AST12.identifier("idFields"),
71110
+ AST12.tsTypeAnnotation(idFields)
71111
+ ),
71112
+ AST12.tsPropertySignature(
71113
+ AST12.identifier("fields"),
71114
+ AST12.tsTypeAnnotation(fields)
71115
+ ),
71116
+ AST12.tsPropertySignature(
71117
+ AST12.identifier("fragments"),
71118
+ AST12.tsTypeAnnotation(fragmentMap[typeName] ?? AST12.tsTupleType([]))
70757
71119
  )
70758
71120
  ])
70759
71121
  )
71122
+ );
71123
+ })
71124
+ );
71125
+ }
71126
+ function listDefinitions(config4, docs) {
71127
+ const lists = [];
71128
+ const visitedLists = /* @__PURE__ */ new Set();
71129
+ for (const doc of docs) {
71130
+ graphql19.visit(doc.document, {
71131
+ Directive(node, key, parent, path2, ancestors) {
71132
+ if (![config4.listDirective, config4.paginateDirective].includes(node.name.value)) {
71133
+ return;
71134
+ }
71135
+ const nameArg = node.arguments?.find((arg) => arg.name.value === "name");
71136
+ const nameValue = nameArg?.value?.value || "";
71137
+ if (!nameValue || visitedLists.has(nameValue)) {
71138
+ return;
71139
+ }
71140
+ visitedLists.add(nameValue);
71141
+ const parentType = parentTypeFromAncestors(
71142
+ config4.schema,
71143
+ doc.filename,
71144
+ ancestors.slice(0, -1)
71145
+ );
71146
+ const targetField = ancestors[ancestors.length - 1];
71147
+ const targetFieldDefinition = parentType.getFields()[targetField.name.value];
71148
+ const { type: listType } = unwrapType(config4, targetFieldDefinition.type);
71149
+ const possibleTypes = [];
71150
+ if (graphql19.isAbstractType(listType)) {
71151
+ possibleTypes.push(
71152
+ ...config4.schema.getPossibleTypes(listType).map((possible) => possible.name)
71153
+ );
71154
+ } else {
71155
+ possibleTypes.push(listType.name);
71156
+ }
71157
+ lists.push(
71158
+ AST12.tsPropertySignature(
71159
+ AST12.identifier(nameValue),
71160
+ AST12.tsTypeAnnotation(
71161
+ AST12.tsTypeLiteral([
71162
+ AST12.tsPropertySignature(
71163
+ AST12.identifier("types"),
71164
+ AST12.tsTypeAnnotation(
71165
+ AST12.tsUnionType(
71166
+ possibleTypes.map(
71167
+ (possible) => AST12.tsLiteralType(AST12.stringLiteral(possible))
71168
+ )
71169
+ )
71170
+ )
71171
+ ),
71172
+ AST12.tsPropertySignature(
71173
+ AST12.identifier("filters"),
71174
+ AST12.tsTypeAnnotation(
71175
+ targetFieldDefinition.args.length === 0 ? AST12.tsNeverKeyword() : AST12.tsTypeLiteral(
71176
+ targetFieldDefinition.args.map((arg) => {
71177
+ const argDef = AST12.tsPropertySignature(
71178
+ AST12.identifier(arg.name),
71179
+ AST12.tsTypeAnnotation(
71180
+ tsTypeReference(
71181
+ config4,
71182
+ /* @__PURE__ */ new Set(),
71183
+ arg
71184
+ )
71185
+ )
71186
+ );
71187
+ argDef.optional = true;
71188
+ return argDef;
71189
+ })
71190
+ )
71191
+ )
71192
+ )
71193
+ ])
71194
+ )
71195
+ )
71196
+ );
71197
+ }
71198
+ });
71199
+ }
71200
+ return AST12.tsTypeLiteral(lists);
71201
+ }
71202
+ function queryDefinitions(config4, body, docs, returnType) {
71203
+ return AST12.tsTupleType(
71204
+ docs.reduce((prev, doc) => {
71205
+ if (doc.kind !== "HoudiniQuery" /* Query */ || !doc.generateStore) {
71206
+ return prev;
71207
+ }
71208
+ const definition = doc.document.definitions.find(
71209
+ (def) => def.kind === "OperationDefinition" && def.operation === "query"
71210
+ );
71211
+ if (!definition) {
71212
+ return prev;
71213
+ }
71214
+ const runtimeType = returnType(doc);
71215
+ const [shapeType, inputType] = ensureImports({
71216
+ config: config4,
71217
+ body,
71218
+ sourceModule: path_exports.relative(
71219
+ config4.runtimeDirectory,
71220
+ config4.artifactImportPath(doc.name)
71221
+ ),
71222
+ import: [`${doc.name}$result`, `${doc.name}$input`]
71223
+ });
71224
+ return prev.concat(
71225
+ AST12.tsTupleType([
71226
+ AST12.tsTypeReference(AST12.identifier(runtimeType)),
71227
+ AST12.tsTypeReference(AST12.identifier(shapeType)),
71228
+ AST12.tsTypeReference(AST12.identifier(inputType))
71229
+ ])
71230
+ );
71231
+ }, [])
71232
+ );
71233
+ }
71234
+ function fragmentListMap(config4, concreteTypes, body, docs, return_type) {
71235
+ return docs.reduce((prev, doc) => {
71236
+ if (doc.kind !== "HoudiniFragment" /* Fragment */) {
71237
+ return prev;
71238
+ }
71239
+ const definition = doc.document.definitions.find(
71240
+ (def) => def.kind === "FragmentDefinition" && def.name.value === doc.name
71241
+ );
71242
+ if (!definition || !concreteTypes.includes(definition.typeCondition.name.value)) {
71243
+ return prev;
71244
+ }
71245
+ const typeName = definition.typeCondition.name.value;
71246
+ const previousValue = prev[typeName]?.elementTypes ?? [];
71247
+ const tagResult = return_type(doc);
71248
+ const [shapeType] = ensureImports({
71249
+ config: config4,
71250
+ body,
71251
+ sourceModule: path_exports.relative(
71252
+ config4.runtimeDirectory,
71253
+ config4.artifactImportPath(doc.name)
70760
71254
  ),
70761
- AST12.exportNamedDeclaration(
70762
- AST12.tsTypeAliasDeclaration(
70763
- AST12.identifier(shapeTypeName),
70764
- inlineType({
71255
+ import: [`${definition.name.value}$data`]
71256
+ });
71257
+ let inputType = AST12.tsNeverKeyword();
71258
+ let directive = definition.directives?.find(
71259
+ (directive2) => directive2.name.value === config4.argumentsDirective
71260
+ );
71261
+ if (directive) {
71262
+ inputType = AST12.tsTypeReference(
71263
+ AST12.identifier(
71264
+ ensureImports({
70765
71265
  config: config4,
70766
- filepath,
70767
- rootType: type,
70768
- selections,
70769
- root: true,
70770
- allowReadonly: true,
70771
71266
  body,
70772
- visitedTypes,
70773
- missingScalars,
70774
- includeFragments: true
70775
- })
71267
+ sourceModule: path_exports.relative(
71268
+ config4.runtimeDirectory,
71269
+ config4.artifactImportPath(doc.name)
71270
+ ),
71271
+ import: [`${definition.name.value}$input`]
71272
+ })[0]
71273
+ )
71274
+ );
71275
+ }
71276
+ return {
71277
+ ...prev,
71278
+ [typeName]: AST12.tsTupleType(
71279
+ previousValue.concat(
71280
+ AST12.tsTupleType([
71281
+ AST12.tsTypeReference(AST12.identifier(tagResult)),
71282
+ AST12.tsTypeReference(AST12.identifier(shapeType)),
71283
+ inputType
71284
+ ])
70776
71285
  )
70777
71286
  )
70778
- );
70779
- }
71287
+ };
71288
+ }, {});
71289
+ }
71290
+ var CacheTypeDefName = "CacheTypeDef";
71291
+ function record(name2) {
71292
+ return AST12.tsTypeReference(
71293
+ AST12.identifier("Record"),
71294
+ AST12.tsTypeParameterInstantiation([
71295
+ AST12.tsTypeReference(AST12.identifier(CacheTypeDefName)),
71296
+ AST12.tsLiteralType(AST12.stringLiteral(name2))
71297
+ ])
71298
+ );
71299
+ }
71300
+
71301
+ // src/codegen/generators/typescript/index.ts
71302
+ async function typescriptGenerator(config4, docs) {
71303
+ await Promise.all([
71304
+ generateDocumentTypes(config4, docs),
71305
+ imperativeCacheTypef(config4, docs)
71306
+ ]);
70780
71307
  }
70781
71308
 
70782
71309
  // src/codegen/generators/persistedQueries/index.ts
70783
- var graphql19 = __toESM(require_graphql2(), 1);
71310
+ var graphql20 = __toESM(require_graphql2(), 1);
70784
71311
  async function persistOutputGenerator(config4, docs) {
70785
71312
  if (typeof config4.persistedQueryPath !== "string" || config4.persistedQueryPath.length === 0)
70786
71313
  return;
@@ -70792,8 +71319,8 @@ async function persistOutputGenerator(config4, docs) {
70792
71319
  if (!generateArtifact) {
70793
71320
  return acc;
70794
71321
  }
70795
- let rawString = graphql19.print(
70796
- graphql19.visit(document, {
71322
+ let rawString = graphql20.print(
71323
+ graphql20.visit(document, {
70797
71324
  Directive(node) {
70798
71325
  if (config4.isInternalDirective(node)) {
70799
71326
  return null;
@@ -70802,7 +71329,7 @@ async function persistOutputGenerator(config4, docs) {
70802
71329
  })
70803
71330
  );
70804
71331
  const operations = document.definitions.filter(
70805
- ({ kind }) => kind === graphql19.Kind.OPERATION_DEFINITION
71332
+ ({ kind }) => kind === graphql20.Kind.OPERATION_DEFINITION
70806
71333
  );
70807
71334
  if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
70808
71335
  acc[hashDocument(rawString)] = rawString;
@@ -70815,11 +71342,11 @@ async function persistOutputGenerator(config4, docs) {
70815
71342
  }
70816
71343
 
70817
71344
  // src/codegen/generators/definitions/enums.ts
70818
- var graphql20 = __toESM(require_graphql2(), 1);
71345
+ var graphql21 = __toESM(require_graphql2(), 1);
70819
71346
  var recast13 = __toESM(require_main2(), 1);
70820
71347
  var AST13 = recast13.types.builders;
70821
71348
  async function definitionsGenerator(config4) {
70822
- const enums = graphql20.parse(graphql20.printSchema(config4.schema)).definitions.filter(
71349
+ const enums = graphql21.parse(graphql21.printSchema(config4.schema)).definitions.filter(
70823
71350
  (definition) => definition.kind === "EnumTypeDefinition"
70824
71351
  ).filter((def) => !config4.isInternalEnum(def));
70825
71352
  const runtimeDefinitions = recast13.print(
@@ -70909,91 +71436,8 @@ async function writeIndexFile2(config4, docs) {
70909
71436
  await fs_exports.writeFile(path_exports.join(config4.rootDir, "index.js"), body);
70910
71437
  }
70911
71438
 
70912
- // src/codegen/transforms/composeQueries.ts
70913
- var import_graphql30 = __toESM(require_graphql2(), 1);
70914
- async function includeFragmentDefinitions(config4, documents) {
70915
- const fragments = collectFragments(config4, documents);
70916
- for (const [index, { name: name2, document, filename }] of documents.entries()) {
70917
- const operation = document.definitions.find(
70918
- ({ kind }) => kind === import_graphql30.Kind.OPERATION_DEFINITION
70919
- );
70920
- if (!operation) {
70921
- continue;
70922
- }
70923
- const allFragments = flattenFragments(
70924
- filename,
70925
- { requiredFragments: findRequiredFragments(operation.selectionSet) },
70926
- fragments
70927
- );
70928
- documents[index].document = {
70929
- ...document,
70930
- definitions: [
70931
- operation,
70932
- ...allFragments.map((fragmentName) => fragments[fragmentName].definition)
70933
- ]
70934
- };
70935
- }
70936
- }
70937
- function collectFragments(config4, docs) {
70938
- return docs.reduce((acc, doc) => {
70939
- const definitions = doc.document.definitions.reduce(
70940
- (prev, definition) => definition.kind !== "FragmentDefinition" ? prev : {
70941
- ...prev,
70942
- [definition.name.value]: {
70943
- definition,
70944
- requiredFragments: findRequiredFragments(definition.selectionSet),
70945
- document: doc
70946
- }
70947
- },
70948
- {}
70949
- );
70950
- return {
70951
- ...acc,
70952
- ...definitions
70953
- };
70954
- }, {});
70955
- }
70956
- function findRequiredFragments(selectionSet) {
70957
- if (selectionSet.selections.length === 0) {
70958
- return [];
70959
- }
70960
- const referencedFragments = [];
70961
- for (const selection2 of selectionSet.selections) {
70962
- if (selection2.kind === import_graphql30.Kind.FRAGMENT_SPREAD) {
70963
- referencedFragments.push(selection2.name.value);
70964
- } else if (selection2.selectionSet) {
70965
- referencedFragments.push(...findRequiredFragments(selection2.selectionSet));
70966
- }
70967
- }
70968
- return referencedFragments;
70969
- }
70970
- function flattenFragments(filepath, operation, fragments) {
70971
- const frags = /* @__PURE__ */ new Set();
70972
- const remaining = [...operation.requiredFragments];
70973
- while (remaining.length > 0) {
70974
- const nextFragment = remaining.shift();
70975
- if (!nextFragment) {
70976
- continue;
70977
- }
70978
- if (!frags.has(nextFragment)) {
70979
- frags.add(nextFragment);
70980
- } else {
70981
- continue;
70982
- }
70983
- const targetFragment = fragments[nextFragment];
70984
- if (!targetFragment) {
70985
- throw new HoudiniError({
70986
- filepath,
70987
- message: "compose: could not find definition for fragment " + nextFragment
70988
- });
70989
- }
70990
- remaining.push(...targetFragment.requiredFragments);
70991
- }
70992
- return [...frags];
70993
- }
70994
-
70995
71439
  // src/codegen/transforms/schema.ts
70996
- var graphql21 = __toESM(require_graphql2(), 1);
71440
+ var graphql22 = __toESM(require_graphql2(), 1);
70997
71441
  async function graphqlExtensions(config4, documents) {
70998
71442
  const internalSchema = `
70999
71443
  enum CachePolicy {
@@ -71057,9 +71501,9 @@ directive @${config4.argumentsDirective} on FRAGMENT_DEFINITION
71057
71501
  directive @${config4.cacheDirective}(${config4.cachePolicyArg}: CachePolicy, ${config4.cachePartialArg}: Boolean) on QUERY
71058
71502
 
71059
71503
  """
71060
- @${config4.manualLoadDirective} is used to disable automatic fetch (no load, no auto fetch in component), you will have to do it manually.
71504
+ @${config4.loadDirective} is used to disable automatic fetch (no load, no auto fetch in component), you will have to do it manually.
71061
71505
  """
71062
- directive @${config4.manualLoadDirective} on QUERY
71506
+ directive @${config4.loadDirective} on QUERY
71063
71507
 
71064
71508
  """
71065
71509
  @${config4.maskEnableDirective} to enable masking on fragment (overwriting the global conf)
@@ -71071,19 +71515,19 @@ directive @${config4.maskEnableDirective} on FRAGMENT_SPREAD
71071
71515
  """
71072
71516
  directive @${config4.maskDisableDirective} on FRAGMENT_SPREAD
71073
71517
  `;
71074
- let currentSchema = graphql21.printSchema(config4.schema);
71518
+ let currentSchema = graphql22.printSchema(config4.schema);
71075
71519
  if (!currentSchema.includes(`directive @${config4.listDirective}`)) {
71076
71520
  currentSchema += internalSchema;
71077
71521
  }
71078
71522
  config4.newSchema += internalSchema;
71079
- config4.schema = graphql21.buildSchema(currentSchema);
71523
+ config4.schema = graphql22.buildSchema(currentSchema);
71080
71524
  }
71081
71525
 
71082
71526
  // src/codegen/transforms/typename.ts
71083
- var graphql22 = __toESM(require_graphql2(), 1);
71527
+ var graphql23 = __toESM(require_graphql2(), 1);
71084
71528
  async function addTypename(config4, documents) {
71085
71529
  for (const doc of documents) {
71086
- doc.document = graphql22.visit(doc.document, {
71530
+ doc.document = graphql23.visit(doc.document, {
71087
71531
  Field(node, key, parent, path2, ancestors) {
71088
71532
  if (!node.selectionSet) {
71089
71533
  return;
@@ -71095,7 +71539,7 @@ async function addTypename(config4, documents) {
71095
71539
  );
71096
71540
  const field = type.getFields()[node.name.value];
71097
71541
  const fieldType = unwrapType(config4, field.type).type;
71098
- if (graphql22.isInterfaceType(fieldType) || graphql22.isUnionType(fieldType)) {
71542
+ if (graphql23.isInterfaceType(fieldType) || graphql23.isUnionType(fieldType)) {
71099
71543
  return {
71100
71544
  ...node,
71101
71545
  selectionSet: {
@@ -71103,9 +71547,9 @@ async function addTypename(config4, documents) {
71103
71547
  selections: [
71104
71548
  ...node.selectionSet.selections,
71105
71549
  {
71106
- kind: graphql22.Kind.FIELD,
71550
+ kind: graphql23.Kind.FIELD,
71107
71551
  name: {
71108
- kind: graphql22.Kind.NAME,
71552
+ kind: graphql23.Kind.NAME,
71109
71553
  value: "__typename"
71110
71554
  }
71111
71555
  }
@@ -71119,10 +71563,10 @@ async function addTypename(config4, documents) {
71119
71563
  }
71120
71564
 
71121
71565
  // src/codegen/transforms/addID.ts
71122
- var graphql23 = __toESM(require_graphql2(), 1);
71566
+ var graphql24 = __toESM(require_graphql2(), 1);
71123
71567
  async function addID(config4, documents) {
71124
71568
  for (const doc of documents) {
71125
- doc.document = graphql23.visit(doc.document, {
71569
+ doc.document = graphql24.visit(doc.document, {
71126
71570
  Field(node, key, parent, path2, ancestors) {
71127
71571
  if (!node.selectionSet) {
71128
71572
  return;
@@ -71135,7 +71579,7 @@ async function addID(config4, documents) {
71135
71579
  const field = type.getFields()[node.name.value];
71136
71580
  const fieldType = unwrapType(config4, field.type).type;
71137
71581
  if (node.selectionSet?.selections.length > 0) {
71138
- if (!graphql23.isObjectType(fieldType) && !graphql23.isInterfaceType(fieldType)) {
71582
+ if (!graphql24.isObjectType(fieldType) && !graphql24.isInterfaceType(fieldType)) {
71139
71583
  return;
71140
71584
  }
71141
71585
  const keyFields = config4.keyFieldsForType(fieldType.name);
@@ -71150,9 +71594,9 @@ async function addID(config4, documents) {
71150
71594
  continue;
71151
71595
  }
71152
71596
  selections.push({
71153
- kind: graphql23.Kind.FIELD,
71597
+ kind: graphql24.Kind.FIELD,
71154
71598
  name: {
71155
- kind: graphql23.Kind.NAME,
71599
+ kind: graphql24.Kind.NAME,
71156
71600
  value: keyField
71157
71601
  }
71158
71602
  });
@@ -71170,266 +71614,6 @@ async function addID(config4, documents) {
71170
71614
  }
71171
71615
  }
71172
71616
 
71173
- // src/codegen/transforms/fragmentVariables.ts
71174
- var graphql24 = __toESM(require_graphql2(), 1);
71175
- var GraphqlKinds2 = graphql24.Kind;
71176
- async function fragmentVariables(config4, documents) {
71177
- const fragments = collectFragments(config4, documents);
71178
- const generatedFragments = {};
71179
- const visitedFragments = /* @__PURE__ */ new Set();
71180
- for (const doc2 of documents) {
71181
- const operation = doc2.document.definitions.find(
71182
- ({ kind }) => kind === GraphqlKinds2.OPERATION_DEFINITION
71183
- );
71184
- if (!operation) {
71185
- continue;
71186
- }
71187
- doc2.document = inlineFragmentArgs({
71188
- config: config4,
71189
- filepath: doc2.filename,
71190
- fragmentDefinitions: fragments,
71191
- document: doc2.document,
71192
- generatedFragments,
71193
- visitedFragments,
71194
- scope: null
71195
- });
71196
- }
71197
- const doc = {
71198
- kind: graphql24.Kind.DOCUMENT,
71199
- definitions: Object.values(generatedFragments)
71200
- };
71201
- documents.push({
71202
- name: "generated::fragmentVariables",
71203
- kind: "HoudiniFragment" /* Fragment */,
71204
- document: doc,
71205
- originalDocument: doc,
71206
- generateStore: false,
71207
- generateArtifact: false,
71208
- filename: "generated::fragmentVariables",
71209
- originalString: ""
71210
- });
71211
- }
71212
- function inlineFragmentArgs({
71213
- config: config4,
71214
- filepath,
71215
- fragmentDefinitions,
71216
- document,
71217
- generatedFragments,
71218
- visitedFragments,
71219
- scope,
71220
- newName
71221
- }) {
71222
- if (!scope) {
71223
- scope = operationScope(
71224
- document.definitions.find(
71225
- ({ kind }) => kind === GraphqlKinds2.OPERATION_DEFINITION
71226
- )
71227
- );
71228
- }
71229
- const definitionArgs = fragmentArguments(
71230
- config4,
71231
- filepath,
71232
- document
71233
- ).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
71234
- const result = graphql24.visit(document, {
71235
- FragmentSpread(node) {
71236
- const { definition } = fragmentDefinitions[node.name.value];
71237
- let { args, hash } = collectWithArguments(config4, filepath, node, scope);
71238
- const newFragmentName = `${node.name.value}${hash}`;
71239
- if (!visitedFragments.has(newFragmentName)) {
71240
- visitedFragments.add(newFragmentName);
71241
- const defaultArguments = collectDefaultArgumentValues(config4, filepath, definition);
71242
- if (args) {
71243
- for (const [field, value] of Object.entries(defaultArguments || {})) {
71244
- if (!args[field]) {
71245
- args[field] = value;
71246
- }
71247
- }
71248
- generatedFragments[newFragmentName] = inlineFragmentArgs({
71249
- config: config4,
71250
- filepath,
71251
- fragmentDefinitions,
71252
- document: fragmentDefinitions[node.name.value].definition,
71253
- generatedFragments,
71254
- visitedFragments,
71255
- scope: args,
71256
- newName: newFragmentName
71257
- });
71258
- } else {
71259
- const doc = fragmentDefinitions[node.name.value].document;
71260
- const definitionIndex = doc.document.definitions.findIndex(
71261
- (definition2) => definition2.kind === "FragmentDefinition" && definition2.name.value === node.name.value
71262
- );
71263
- const localDefinitions = [...doc.document.definitions];
71264
- localDefinitions.splice(definitionIndex, 1);
71265
- localDefinitions.push(
71266
- inlineFragmentArgs({
71267
- config: config4,
71268
- filepath,
71269
- fragmentDefinitions,
71270
- document: fragmentDefinitions[node.name.value].definition,
71271
- generatedFragments,
71272
- visitedFragments,
71273
- scope: defaultArguments,
71274
- newName: ""
71275
- })
71276
- );
71277
- doc.document = {
71278
- ...doc.document,
71279
- definitions: localDefinitions
71280
- };
71281
- }
71282
- if (node.name.value !== newFragmentName) {
71283
- return {
71284
- ...node,
71285
- name: {
71286
- kind: "Name",
71287
- value: newFragmentName
71288
- }
71289
- };
71290
- }
71291
- }
71292
- },
71293
- Argument(node) {
71294
- const value = node.value;
71295
- if (value.kind !== "Variable") {
71296
- return;
71297
- }
71298
- if (!scope) {
71299
- throw new HoudiniError({
71300
- filepath,
71301
- message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
71302
- });
71303
- }
71304
- const newValue = scope[value.name.value];
71305
- if (newValue) {
71306
- return {
71307
- ...node,
71308
- value: newValue
71309
- };
71310
- }
71311
- if (definitionArgs[value.name.value] && definitionArgs[value.name.value].required) {
71312
- throw new HoudiniError({
71313
- filepath,
71314
- message: "Missing value for required arg: " + value.name.value
71315
- });
71316
- }
71317
- return null;
71318
- }
71319
- });
71320
- if (newName) {
71321
- result.name = {
71322
- kind: graphql24.Kind.NAME,
71323
- value: newName
71324
- };
71325
- }
71326
- return result;
71327
- }
71328
- function withArguments(config4, node) {
71329
- const withDirectives = node.directives?.filter(
71330
- (directive) => directive.name.value === config4.withDirective
71331
- );
71332
- if (!withDirectives || withDirectives.length === 0) {
71333
- return [];
71334
- }
71335
- return withDirectives.flatMap((directive) => directive.arguments || []);
71336
- }
71337
- function fragmentArguments(config4, filepath, definition) {
71338
- const directives = definition.directives?.filter(
71339
- (directive) => directive.name.value === config4.argumentsDirective
71340
- );
71341
- if (!directives || directives.length === 0) {
71342
- return [];
71343
- }
71344
- return directives.flatMap(
71345
- (directive) => directive.arguments?.flatMap((arg) => {
71346
- if (arg.value.kind !== "ObjectValue") {
71347
- throw new HoudiniError({
71348
- filepath,
71349
- message: "values of @argument must be objects"
71350
- });
71351
- }
71352
- const typeArg = arg.value.fields?.find((arg2) => arg2.name.value === "type")?.value;
71353
- if (!typeArg || typeArg.kind !== "StringValue") {
71354
- return [];
71355
- }
71356
- let type = typeArg.value;
71357
- let name2 = arg.name.value;
71358
- let required = false;
71359
- let defaultValue = arg.value.fields?.find((arg2) => arg2.name.value === "default")?.value || null;
71360
- if (type[type.length - 1] === "!") {
71361
- type = type.slice(0, -1);
71362
- required = true;
71363
- defaultValue = null;
71364
- }
71365
- return [
71366
- {
71367
- name: name2,
71368
- type,
71369
- required,
71370
- defaultValue
71371
- }
71372
- ];
71373
- }) || []
71374
- );
71375
- }
71376
- function collectDefaultArgumentValues(config4, filepath, definition) {
71377
- let result = {};
71378
- for (const { name: name2, required, defaultValue } of fragmentArguments(
71379
- config4,
71380
- filepath,
71381
- definition
71382
- )) {
71383
- if (required || !defaultValue) {
71384
- continue;
71385
- }
71386
- result[name2] = defaultValue;
71387
- }
71388
- return result;
71389
- }
71390
- function collectWithArguments(config4, filepath, node, scope = {}) {
71391
- const withArgs = withArguments(config4, node);
71392
- if (withArgs.length === 0) {
71393
- return { args: null, hash: "" };
71394
- }
71395
- let args = {};
71396
- for (const arg of withArgs) {
71397
- let value = arg.value;
71398
- if (value.kind === GraphqlKinds2.VARIABLE) {
71399
- if (!scope || !scope[value.name.value]) {
71400
- throw new HoudiniError({
71401
- filepath,
71402
- message: "Encountered undefined variable: " + value.name.value
71403
- });
71404
- }
71405
- value = scope[value.name.value];
71406
- }
71407
- args[arg.name.value] = {
71408
- ...value,
71409
- loc: void 0
71410
- };
71411
- }
71412
- return {
71413
- args,
71414
- hash: "_" + murmurHash(JSON.stringify(args))
71415
- };
71416
- }
71417
- function operationScope(operation) {
71418
- return operation.variableDefinitions?.reduce(
71419
- (scope, definition) => ({
71420
- ...scope,
71421
- [definition.variable.name.value]: {
71422
- kind: "Variable",
71423
- name: {
71424
- kind: "Name",
71425
- value: definition.variable.name.value
71426
- }
71427
- }
71428
- }),
71429
- {}
71430
- ) || {};
71431
- }
71432
-
71433
71617
  // src/codegen/validators/typeCheck.ts
71434
71618
  var graphql25 = __toESM(require_graphql2(), 1);
71435
71619
  async function typeCheck(config4, docs) {