@@ -515,6 +515,7 @@ pub enum __Type {
515515 // Mutation
516516 Mutation ( MutationType ) ,
517517 InsertInput ( InsertInputType ) ,
518+ InsertOnConflictInput ( InsertOnConflictType ) ,
518519 InsertResponse ( InsertResponseType ) ,
519520 UpdateInput ( UpdateInputType ) ,
520521 UpdateResponse ( UpdateResponseType ) ,
@@ -595,6 +596,7 @@ impl ___Type for __Type {
595596 Self :: Node ( x) => x. kind ( ) ,
596597 Self :: NodeInterface ( x) => x. kind ( ) ,
597598 Self :: InsertInput ( x) => x. kind ( ) ,
599+ Self :: InsertOnConflictInput ( x) => x. kind ( ) ,
598600 Self :: InsertResponse ( x) => x. kind ( ) ,
599601 Self :: UpdateInput ( x) => x. kind ( ) ,
600602 Self :: UpdateResponse ( x) => x. kind ( ) ,
@@ -630,6 +632,7 @@ impl ___Type for __Type {
630632 Self :: Node ( x) => x. name ( ) ,
631633 Self :: NodeInterface ( x) => x. name ( ) ,
632634 Self :: InsertInput ( x) => x. name ( ) ,
635+ Self :: InsertOnConflictInput ( x) => x. name ( ) ,
633636 Self :: InsertResponse ( x) => x. name ( ) ,
634637 Self :: UpdateInput ( x) => x. name ( ) ,
635638 Self :: UpdateResponse ( x) => x. name ( ) ,
@@ -665,6 +668,7 @@ impl ___Type for __Type {
665668 Self :: Node ( x) => x. description ( ) ,
666669 Self :: NodeInterface ( x) => x. description ( ) ,
667670 Self :: InsertInput ( x) => x. description ( ) ,
671+ Self :: InsertOnConflictInput ( x) => x. description ( ) ,
668672 Self :: InsertResponse ( x) => x. description ( ) ,
669673 Self :: UpdateInput ( x) => x. description ( ) ,
670674 Self :: UpdateResponse ( x) => x. description ( ) ,
@@ -701,6 +705,7 @@ impl ___Type for __Type {
701705 Self :: Node ( x) => x. fields ( _include_deprecated) ,
702706 Self :: NodeInterface ( x) => x. fields ( _include_deprecated) ,
703707 Self :: InsertInput ( x) => x. fields ( _include_deprecated) ,
708+ Self :: InsertOnConflictInput ( x) => x. fields ( _include_deprecated) ,
704709 Self :: InsertResponse ( x) => x. fields ( _include_deprecated) ,
705710 Self :: UpdateInput ( x) => x. fields ( _include_deprecated) ,
706711 Self :: UpdateResponse ( x) => x. fields ( _include_deprecated) ,
@@ -737,6 +742,7 @@ impl ___Type for __Type {
737742 Self :: Node ( x) => x. interfaces ( ) ,
738743 Self :: NodeInterface ( x) => x. interfaces ( ) ,
739744 Self :: InsertInput ( x) => x. interfaces ( ) ,
745+ Self :: InsertOnConflictInput ( x) => x. interfaces ( ) ,
740746 Self :: InsertResponse ( x) => x. interfaces ( ) ,
741747 Self :: UpdateInput ( x) => x. interfaces ( ) ,
742748 Self :: UpdateResponse ( x) => x. interfaces ( ) ,
@@ -782,6 +788,7 @@ impl ___Type for __Type {
782788 Self :: Node ( x) => x. enum_values ( _include_deprecated) ,
783789 Self :: NodeInterface ( x) => x. enum_values ( _include_deprecated) ,
784790 Self :: InsertInput ( x) => x. enum_values ( _include_deprecated) ,
791+ Self :: InsertOnConflictInput ( x) => x. enum_values ( ) ,
785792 Self :: InsertResponse ( x) => x. enum_values ( _include_deprecated) ,
786793 Self :: UpdateInput ( x) => x. enum_values ( _include_deprecated) ,
787794 Self :: UpdateResponse ( x) => x. enum_values ( _include_deprecated) ,
@@ -818,6 +825,7 @@ impl ___Type for __Type {
818825 Self :: Node ( x) => x. input_fields ( ) ,
819826 Self :: NodeInterface ( x) => x. input_fields ( ) ,
820827 Self :: InsertInput ( x) => x. input_fields ( ) ,
828+ Self :: InsertOnConflictInput ( x) => x. input_fields ( ) ,
821829 Self :: InsertResponse ( x) => x. input_fields ( ) ,
822830 Self :: UpdateInput ( x) => x. input_fields ( ) ,
823831 Self :: UpdateResponse ( x) => x. input_fields ( ) ,
@@ -964,6 +972,12 @@ pub struct InsertResponseType {
964972 pub schema : Arc < __Schema > ,
965973}
966974
975+ #[ derive( Clone , Debug , Eq , PartialEq , Hash ) ]
976+ pub struct InsertOnConflictType {
977+ pub table : Arc < Table > ,
978+ pub schema : Arc < __Schema > ,
979+ }
980+
967981#[ derive( Clone , Debug , Eq , PartialEq , Hash ) ]
968982pub struct UpdateResponseType {
969983 pub table : Arc < Table > ,
@@ -1429,14 +1443,16 @@ impl ___Type for MutationType {
14291443 sql_type: None ,
14301444 } ,
14311445 __InputValue {
1432- name_: "update " . to_string( ) ,
1446+ name_: "onConflict " . to_string( ) ,
14331447 type_: __Type:: NonNull ( NonNullType {
14341448 type_: Box :: new( __Type:: List ( ListType {
14351449 type_: Box :: new( __Type:: NonNull ( NonNullType {
1436- type_: Box :: new( __Type:: InsertInput ( InsertInputType {
1437- table: Arc :: clone( table) ,
1438- schema: Arc :: clone( & self . schema) ,
1439- } ) ) ,
1450+ type_: Box :: new( __Type:: InsertOnConflictInput (
1451+ InsertOnConflictType {
1452+ table: Arc :: clone( table) ,
1453+ schema: Arc :: clone( & self . schema) ,
1454+ } ,
1455+ ) ) ,
14401456 } ) ) ,
14411457 } ) ) ,
14421458 } ) ,
@@ -1677,6 +1693,8 @@ impl ___Type for EnumType {
16771693 EnumSource :: TableColumns ( table) => table
16781694 . columns
16791695 . iter ( )
1696+ // TODO: is this the right thing to filter on?
1697+ . filter ( |x| x. permissions . is_selectable )
16801698 . map ( |col| __EnumValue {
16811699 name : self . schema . graphql_column_field_name ( col) ,
16821700 description : None ,
@@ -3115,6 +3133,80 @@ impl ___Type for InsertInputType {
31153133 }
31163134}
31173135
3136+ impl ___Type for InsertOnConflictType {
3137+ fn kind ( & self ) -> __TypeKind {
3138+ __TypeKind:: INPUT_OBJECT
3139+ }
3140+
3141+ fn name ( & self ) -> Option < String > {
3142+ Some ( format ! (
3143+ "{}OnConflictInput" ,
3144+ self . schema. graphql_table_base_type_name( & self . table)
3145+ ) )
3146+ }
3147+
3148+ fn fields ( & self , _include_deprecated : bool ) -> Option < Vec < __Field > > {
3149+ None
3150+ }
3151+
3152+ fn input_fields ( & self ) -> Option < Vec < __InputValue > > {
3153+ Some ( vec ! [
3154+ __InputValue {
3155+ // TODO: Create a custom type for available constraints
3156+ name_: "constraint" . to_string( ) ,
3157+ // If triggers are involved, we can't detect if a field is non-null. Default
3158+ // all fields to non-null and let postgres errors handle it.
3159+ type_: __Type:: NonNull ( NonNullType {
3160+ type_: Box :: new( __Type:: List ( ListType {
3161+ type_: Box :: new( __Type:: NonNull ( NonNullType {
3162+ type_: Box :: new( __Type:: Enum ( EnumType {
3163+ enum_: EnumSource :: TableColumns ( Arc :: clone( & self . table) ) ,
3164+ schema: Arc :: clone( & self . schema) ,
3165+ } ) ) ,
3166+ } ) ) ,
3167+ } ) ) ,
3168+ } ) ,
3169+ description: Some (
3170+ "A unique constraint that may conflict with the inserted records" . to_string( ) ,
3171+ ) ,
3172+ default_value: None ,
3173+ sql_type: None ,
3174+ } ,
3175+ __InputValue {
3176+ name_: "updateFields" . to_string( ) ,
3177+ // If triggers are involved, we can't detect if a field is non-null. Default
3178+ // all fields to non-null and let postgres errors handle it.
3179+ type_: __Type:: NonNull ( NonNullType {
3180+ type_: Box :: new( __Type:: List ( ListType {
3181+ type_: Box :: new( __Type:: NonNull ( NonNullType {
3182+ type_: Box :: new( __Type:: Enum ( EnumType {
3183+ enum_: EnumSource :: TableColumns ( Arc :: clone( & self . table) ) ,
3184+ schema: Arc :: clone( & self . schema) ,
3185+ } ) ) ,
3186+ } ) ) ,
3187+ } ) ) ,
3188+ } ) ,
3189+ description: Some ( "Fields to be updated if conflict occurs" . to_string( ) ) ,
3190+ default_value: None ,
3191+ sql_type: None ,
3192+ } ,
3193+ __InputValue {
3194+ name_: "filter" . to_string( ) ,
3195+ type_: __Type:: FilterEntity ( FilterEntityType {
3196+ table: Arc :: clone( & self . table) ,
3197+ schema: self . schema. clone( ) ,
3198+ } ) ,
3199+ description: Some (
3200+ "Filters to apply to the results set when querying from the collection"
3201+ . to_string( ) ,
3202+ ) ,
3203+ default_value: None ,
3204+ sql_type: None ,
3205+ } ,
3206+ ] )
3207+ }
3208+ }
3209+
31183210impl ___Type for InsertResponseType {
31193211 fn kind ( & self ) -> __TypeKind {
31203212 __TypeKind:: OBJECT
@@ -4053,6 +4145,10 @@ impl __Schema {
40534145 enum_ : EnumSource :: TableColumns ( Arc :: clone ( table) ) ,
40544146 schema : Arc :: clone ( & schema_rc) ,
40554147 } ) ) ;
4148+ types_. push ( __Type:: InsertOnConflictType ( InsertOnConflictType {
4149+ table : Arc :: clone ( table) ,
4150+ schema : Arc :: clone ( & schema_rc) ,
4151+ } ) ) ;
40564152 }
40574153
40584154 if self . graphql_table_update_types_are_valid ( table) {
0 commit comments