@@ -122,45 +122,53 @@ schemaBuilder.mutationFields((t) => ({
122122 title : data . title
123123 } ) ;
124124
125- await tx . insert ( schema . committee ) . values (
126- data . committees . map ( ( committee ) => ( {
127- id : committee . id ,
128- name : committee . name ,
129- abbreviation : committee . abbreviation ,
130- conferenceId : data . id
131- } ) )
132- ) ;
125+ if ( data . committees . length > 0 ) {
126+ await tx . insert ( schema . committee ) . values (
127+ data . committees . map ( ( committee ) => ( {
128+ id : committee . id ,
129+ name : committee . name ,
130+ abbreviation : committee . abbreviation ,
131+ conferenceId : data . id
132+ } ) )
133+ ) ;
134+ }
133135
134- await tx . insert ( schema . representation ) . values (
135- data . representations . map ( ( representation ) => ( {
136- id : representation . id ,
137- name : representation . name ,
138- alpha2Code : representation . alpha2Code ,
139- alpha3Code : representation . alpha3Code ,
140- type : representation . representationType ,
141- faIcon : representation . faIcon ,
142- regionalGroup : representation . regionalGroup ,
143- conferenceId : data . id
144- } ) )
145- ) ;
136+ if ( data . representations . length > 0 ) {
137+ await tx . insert ( schema . representation ) . values (
138+ data . representations . map ( ( representation ) => ( {
139+ id : representation . id ,
140+ name : representation . name ,
141+ alpha2Code : representation . alpha2Code ,
142+ alpha3Code : representation . alpha3Code ,
143+ type : representation . representationType ,
144+ faIcon : representation . faIcon ,
145+ regionalGroup : representation . regionalGroup ,
146+ conferenceId : data . id
147+ } ) )
148+ ) ;
149+ }
146150
147- await tx . insert ( schema . conferenceMember ) . values (
148- data . conferenceMembers . map ( ( member ) => ( {
149- id : member . id ,
150- conferenceId : data . id ,
151- representationId : member . representationId
152- } ) )
153- ) ;
151+ if ( data . conferenceMembers . length > 0 ) {
152+ await tx . insert ( schema . conferenceMember ) . values (
153+ data . conferenceMembers . map ( ( member ) => ( {
154+ id : member . id ,
155+ conferenceId : data . id ,
156+ representationId : member . representationId
157+ } ) )
158+ ) ;
159+ }
154160
155- await tx . insert ( schema . committeeMember ) . values (
156- data . committeeMembers . map ( ( member ) => ( {
157- id : member . id ,
158- committeeId : member . committeeId ,
159- representationId : member . representationId
160- } ) )
161- ) ;
161+ if ( data . committeeMembers . length > 0 ) {
162+ await tx . insert ( schema . committeeMember ) . values (
163+ data . committeeMembers . map ( ( member ) => ( {
164+ id : member . id ,
165+ committeeId : member . committeeId ,
166+ representationId : member . representationId
167+ } ) )
168+ ) ;
169+ }
162170
163- if ( data . conferenceUsers . length !== 0 ) {
171+ if ( data . conferenceUsers . length > 0 ) {
164172 await tx . insert ( schema . conferenceUser ) . values (
165173 data . conferenceUsers . map ( ( user ) => ( {
166174 id : user . id ?? undefined ,
0 commit comments