@constructive-io/graphql-codegen 4.47.6 → 4.47.7

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.
@@ -13,6 +13,15 @@ export interface GeneratedInputTypesFile {
13
13
  export declare function collectInputTypeNames(operations: Array<{
14
14
  args: Argument[];
15
15
  }>, tables?: Table[]): Set<string>;
16
+ /**
17
+ * Collect input type names referenced by CRUD entity input fields.
18
+ *
19
+ * When a table's Create/Patch input contains fields that reference non-scalar
20
+ * input types (e.g. `requiredConfigs: [FunctionRequirementInput]`), those
21
+ * types must be generated. The CRUD generator inlines the field types as
22
+ * strings but doesn't track which input types they reference.
23
+ */
24
+ export declare function collectCrudNestedInputTypes(tables: Table[], typeRegistry: TypeRegistry): Set<string>;
16
25
  /**
17
26
  * Collect all payload type names from operation return types
18
27
  */
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.collectInputTypeNames = collectInputTypeNames;
37
+ exports.collectCrudNestedInputTypes = collectCrudNestedInputTypes;
37
38
  exports.collectPayloadTypeNames = collectPayloadTypeNames;
38
39
  exports.generateInputTypesFile = generateInputTypesFile;
39
40
  /**
@@ -1070,6 +1071,45 @@ function collectInputTypeNames(operations, tables) {
1070
1071
  }
1071
1072
  return inputTypes;
1072
1073
  }
1074
+ /**
1075
+ * Collect input type names referenced by CRUD entity input fields.
1076
+ *
1077
+ * When a table's Create/Patch input contains fields that reference non-scalar
1078
+ * input types (e.g. `requiredConfigs: [FunctionRequirementInput]`), those
1079
+ * types must be generated. The CRUD generator inlines the field types as
1080
+ * strings but doesn't track which input types they reference.
1081
+ */
1082
+ function collectCrudNestedInputTypes(tables, typeRegistry) {
1083
+ const nestedTypes = new Set();
1084
+ for (const table of tables) {
1085
+ // Check Create entity input
1086
+ const createInputTypeName = (0, utils_1.getCreateInputTypeName)(table);
1087
+ collectNestedInputTypesFromInput(createInputTypeName, typeRegistry, nestedTypes);
1088
+ // Check Patch entity input
1089
+ const patchTypeName = (0, utils_1.getPatchTypeName)(table);
1090
+ collectNestedInputTypesFromInput(patchTypeName, typeRegistry, nestedTypes);
1091
+ }
1092
+ return nestedTypes;
1093
+ }
1094
+ function collectNestedInputTypesFromInput(inputTypeName, typeRegistry, collected) {
1095
+ const inputType = typeRegistry.get(inputTypeName);
1096
+ if (!inputType || inputType.kind !== 'INPUT_OBJECT' || !inputType.inputFields)
1097
+ return;
1098
+ for (const field of inputType.inputFields) {
1099
+ const baseName = (0, type_resolver_1.getTypeBaseName)(field.type);
1100
+ if (!baseName)
1101
+ continue;
1102
+ if (scalars_1.SCALAR_NAMES.has(baseName))
1103
+ continue;
1104
+ if (collected.has(baseName))
1105
+ continue;
1106
+ const refType = typeRegistry.get(baseName);
1107
+ if (refType?.kind === 'INPUT_OBJECT') {
1108
+ collected.add(baseName);
1109
+ collectNestedInputTypesFromInput(baseName, typeRegistry, collected);
1110
+ }
1111
+ }
1112
+ }
1073
1113
  /**
1074
1114
  * Build a set of exact table CRUD input type names to skip
1075
1115
  * These are generated by generateAllCrudInputTypes, so we don't need to regenerate them
@@ -1411,6 +1451,12 @@ function generateInputTypesFile(typeRegistry, usedInputTypes, tables, usedPayloa
1411
1451
  for (const typeName of fieldArgTypes) {
1412
1452
  mergedUsedInputTypes.add(typeName);
1413
1453
  }
1454
+ // Collect input types nested inside CRUD entity inputs (e.g. FunctionRequirementInput
1455
+ // referenced by Create/Patch fields) that the CRUD generator inlines as type strings
1456
+ const crudNestedTypes = collectCrudNestedInputTypes(tablesList, typeRegistry);
1457
+ for (const typeName of crudNestedTypes) {
1458
+ mergedUsedInputTypes.add(typeName);
1459
+ }
1414
1460
  }
1415
1461
  const tableCrudTypes = tables ? buildTableCrudTypeNames(tables) : undefined;
1416
1462
  // Pass customScalarTypes + enumTypes as already-generated to avoid duplicate declarations
@@ -13,6 +13,15 @@ export interface GeneratedInputTypesFile {
13
13
  export declare function collectInputTypeNames(operations: Array<{
14
14
  args: Argument[];
15
15
  }>, tables?: Table[]): Set<string>;
16
+ /**
17
+ * Collect input type names referenced by CRUD entity input fields.
18
+ *
19
+ * When a table's Create/Patch input contains fields that reference non-scalar
20
+ * input types (e.g. `requiredConfigs: [FunctionRequirementInput]`), those
21
+ * types must be generated. The CRUD generator inlines the field types as
22
+ * strings but doesn't track which input types they reference.
23
+ */
24
+ export declare function collectCrudNestedInputTypes(tables: Table[], typeRegistry: TypeRegistry): Set<string>;
16
25
  /**
17
26
  * Collect all payload type names from operation return types
18
27
  */
@@ -1032,6 +1032,45 @@ export function collectInputTypeNames(operations, tables) {
1032
1032
  }
1033
1033
  return inputTypes;
1034
1034
  }
1035
+ /**
1036
+ * Collect input type names referenced by CRUD entity input fields.
1037
+ *
1038
+ * When a table's Create/Patch input contains fields that reference non-scalar
1039
+ * input types (e.g. `requiredConfigs: [FunctionRequirementInput]`), those
1040
+ * types must be generated. The CRUD generator inlines the field types as
1041
+ * strings but doesn't track which input types they reference.
1042
+ */
1043
+ export function collectCrudNestedInputTypes(tables, typeRegistry) {
1044
+ const nestedTypes = new Set();
1045
+ for (const table of tables) {
1046
+ // Check Create entity input
1047
+ const createInputTypeName = getCreateInputTypeName(table);
1048
+ collectNestedInputTypesFromInput(createInputTypeName, typeRegistry, nestedTypes);
1049
+ // Check Patch entity input
1050
+ const patchTypeName = getPatchTypeName(table);
1051
+ collectNestedInputTypesFromInput(patchTypeName, typeRegistry, nestedTypes);
1052
+ }
1053
+ return nestedTypes;
1054
+ }
1055
+ function collectNestedInputTypesFromInput(inputTypeName, typeRegistry, collected) {
1056
+ const inputType = typeRegistry.get(inputTypeName);
1057
+ if (!inputType || inputType.kind !== 'INPUT_OBJECT' || !inputType.inputFields)
1058
+ return;
1059
+ for (const field of inputType.inputFields) {
1060
+ const baseName = getTypeBaseName(field.type);
1061
+ if (!baseName)
1062
+ continue;
1063
+ if (SCALAR_NAMES.has(baseName))
1064
+ continue;
1065
+ if (collected.has(baseName))
1066
+ continue;
1067
+ const refType = typeRegistry.get(baseName);
1068
+ if (refType?.kind === 'INPUT_OBJECT') {
1069
+ collected.add(baseName);
1070
+ collectNestedInputTypesFromInput(baseName, typeRegistry, collected);
1071
+ }
1072
+ }
1073
+ }
1035
1074
  /**
1036
1075
  * Build a set of exact table CRUD input type names to skip
1037
1076
  * These are generated by generateAllCrudInputTypes, so we don't need to regenerate them
@@ -1373,6 +1412,12 @@ export function generateInputTypesFile(typeRegistry, usedInputTypes, tables, use
1373
1412
  for (const typeName of fieldArgTypes) {
1374
1413
  mergedUsedInputTypes.add(typeName);
1375
1414
  }
1415
+ // Collect input types nested inside CRUD entity inputs (e.g. FunctionRequirementInput
1416
+ // referenced by Create/Patch fields) that the CRUD generator inlines as type strings
1417
+ const crudNestedTypes = collectCrudNestedInputTypes(tablesList, typeRegistry);
1418
+ for (const typeName of crudNestedTypes) {
1419
+ mergedUsedInputTypes.add(typeName);
1420
+ }
1376
1421
  }
1377
1422
  const tableCrudTypes = tables ? buildTableCrudTypeNames(tables) : undefined;
1378
1423
  // Pass customScalarTypes + enumTypes as already-generated to avoid duplicate declarations
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructive-io/graphql-codegen",
3
- "version": "4.47.6",
3
+ "version": "4.47.7",
4
4
  "description": "GraphQL SDK generator for Constructive databases with React Query hooks",
5
5
  "keywords": [
6
6
  "graphql",
@@ -100,5 +100,5 @@
100
100
  "tsx": "^4.21.0",
101
101
  "typescript": "^5.9.3"
102
102
  },
103
- "gitHead": "659c7776183c8dc497e640c384e8d1af45965065"
103
+ "gitHead": "fc478f167f31f765228a8a4301a29941e5f3b2fe"
104
104
  }