fraiseql 2.1.5 → 2.2.0
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.
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +11 -5
- package/dist/index.mjs +11 -5
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -719,11 +719,14 @@ function generateCrudOperations(typeName, fields, crud, sqlSource, cascade) {
|
|
|
719
719
|
);
|
|
720
720
|
}
|
|
721
721
|
if (ops.has("create")) {
|
|
722
|
-
const
|
|
722
|
+
const inputName = `Create${typeName}Input`;
|
|
723
|
+
const writableFields = fields.filter((f) => !f.computed);
|
|
724
|
+
const inputFields = writableFields.map((f) => ({
|
|
723
725
|
name: f.name,
|
|
724
726
|
type: f.type,
|
|
725
727
|
nullable: f.nullable
|
|
726
728
|
}));
|
|
729
|
+
SchemaRegistry.registerInputType(inputName, inputFields, `Input for creating a new ${typeName}.`);
|
|
727
730
|
const config2 = {
|
|
728
731
|
sql_source: `fn_create_${snake}`,
|
|
729
732
|
operation: "INSERT"
|
|
@@ -734,16 +737,19 @@ function generateCrudOperations(typeName, fields, crud, sqlSource, cascade) {
|
|
|
734
737
|
typeName,
|
|
735
738
|
false,
|
|
736
739
|
false,
|
|
737
|
-
|
|
740
|
+
[{ name: "input", type: inputName, nullable: false }],
|
|
738
741
|
`Create a new ${typeName}.`,
|
|
739
742
|
config2
|
|
740
743
|
);
|
|
741
744
|
}
|
|
742
745
|
if (ops.has("update")) {
|
|
743
|
-
const
|
|
746
|
+
const inputName = `Update${typeName}Input`;
|
|
747
|
+
const writableFields = fields.slice(1).filter((f) => !f.computed);
|
|
748
|
+
const inputFields = [
|
|
744
749
|
{ name: pkField.name, type: pkField.type, nullable: false },
|
|
745
|
-
...
|
|
750
|
+
...writableFields.map((f) => ({ name: f.name, type: f.type, nullable: true }))
|
|
746
751
|
];
|
|
752
|
+
SchemaRegistry.registerInputType(inputName, inputFields, `Input for updating an existing ${typeName}.`);
|
|
747
753
|
const config2 = {
|
|
748
754
|
sql_source: `fn_update_${snake}`,
|
|
749
755
|
operation: "UPDATE"
|
|
@@ -754,7 +760,7 @@ function generateCrudOperations(typeName, fields, crud, sqlSource, cascade) {
|
|
|
754
760
|
typeName,
|
|
755
761
|
false,
|
|
756
762
|
true,
|
|
757
|
-
|
|
763
|
+
[{ name: "input", type: inputName, nullable: false }],
|
|
758
764
|
`Update an existing ${typeName}.`,
|
|
759
765
|
config2
|
|
760
766
|
);
|
package/dist/index.mjs
CHANGED
|
@@ -640,11 +640,14 @@ function generateCrudOperations(typeName, fields, crud, sqlSource, cascade) {
|
|
|
640
640
|
);
|
|
641
641
|
}
|
|
642
642
|
if (ops.has("create")) {
|
|
643
|
-
const
|
|
643
|
+
const inputName = `Create${typeName}Input`;
|
|
644
|
+
const writableFields = fields.filter((f) => !f.computed);
|
|
645
|
+
const inputFields = writableFields.map((f) => ({
|
|
644
646
|
name: f.name,
|
|
645
647
|
type: f.type,
|
|
646
648
|
nullable: f.nullable
|
|
647
649
|
}));
|
|
650
|
+
SchemaRegistry.registerInputType(inputName, inputFields, `Input for creating a new ${typeName}.`);
|
|
648
651
|
const config2 = {
|
|
649
652
|
sql_source: `fn_create_${snake}`,
|
|
650
653
|
operation: "INSERT"
|
|
@@ -655,16 +658,19 @@ function generateCrudOperations(typeName, fields, crud, sqlSource, cascade) {
|
|
|
655
658
|
typeName,
|
|
656
659
|
false,
|
|
657
660
|
false,
|
|
658
|
-
|
|
661
|
+
[{ name: "input", type: inputName, nullable: false }],
|
|
659
662
|
`Create a new ${typeName}.`,
|
|
660
663
|
config2
|
|
661
664
|
);
|
|
662
665
|
}
|
|
663
666
|
if (ops.has("update")) {
|
|
664
|
-
const
|
|
667
|
+
const inputName = `Update${typeName}Input`;
|
|
668
|
+
const writableFields = fields.slice(1).filter((f) => !f.computed);
|
|
669
|
+
const inputFields = [
|
|
665
670
|
{ name: pkField.name, type: pkField.type, nullable: false },
|
|
666
|
-
...
|
|
671
|
+
...writableFields.map((f) => ({ name: f.name, type: f.type, nullable: true }))
|
|
667
672
|
];
|
|
673
|
+
SchemaRegistry.registerInputType(inputName, inputFields, `Input for updating an existing ${typeName}.`);
|
|
668
674
|
const config2 = {
|
|
669
675
|
sql_source: `fn_update_${snake}`,
|
|
670
676
|
operation: "UPDATE"
|
|
@@ -675,7 +681,7 @@ function generateCrudOperations(typeName, fields, crud, sqlSource, cascade) {
|
|
|
675
681
|
typeName,
|
|
676
682
|
false,
|
|
677
683
|
true,
|
|
678
|
-
|
|
684
|
+
[{ name: "input", type: inputName, nullable: false }],
|
|
679
685
|
`Update an existing ${typeName}.`,
|
|
680
686
|
config2
|
|
681
687
|
);
|