@@ -777,24 +777,16 @@ class RequestHandler extends APIHandlerBase {
777777
778778 let entity : any ;
779779
780- try {
781- if ( operation === 'upsert' ) {
782- entity = await this . runUpsert (
783- typeInfo ,
784- type ,
785- prisma ,
786- modelMeta ,
787- attributes ,
788- relationships ,
789- matchFields
790- ) ;
791- } else if ( operation === 'create' ) {
792- entity = await this . runCreate ( typeInfo , type , prisma , attributes , relationships ) ;
793- } else {
794- return this . makeError ( 'invalidPayload' ) ;
795- }
796- } catch ( e ) {
797- return e as any ;
780+ if ( operation === 'upsert' ) {
781+ entity = await this . runUpsert ( typeInfo , type , prisma , modelMeta , attributes , relationships , matchFields ) ;
782+ } else if ( operation === 'create' ) {
783+ entity = await this . runCreate ( typeInfo , type , prisma , attributes , relationships ) ;
784+ } else {
785+ return this . makeError ( 'invalidPayload' ) ;
786+ }
787+
788+ if ( entity . status ) {
789+ return entity ;
798790 }
799791
800792 return {
@@ -817,7 +809,7 @@ class RequestHandler extends APIHandlerBase {
817809 if (
818810 ! uniqueFields . some ( ( uniqueCombination ) => uniqueCombination . every ( ( field ) => matchFields . includes ( field ) ) )
819811 ) {
820- throw this . makeError ( 'invalidPayload' , 'Match fields must be unique fields' , 400 ) ;
812+ return this . makeError ( 'invalidPayload' , 'Match fields must be unique fields' , 400 ) ;
821813 }
822814
823815 const upsertPayload : any = { } ;
@@ -831,12 +823,12 @@ class RequestHandler extends APIHandlerBase {
831823 if ( relationships ) {
832824 for ( const [ key , data ] of Object . entries < any > ( relationships ) ) {
833825 if ( ! data ?. data ) {
834- throw this . makeError ( 'invalidRelationData' ) ;
826+ return this . makeError ( 'invalidRelationData' ) ;
835827 }
836828
837829 const relationInfo = typeInfo . relationships [ key ] ;
838830 if ( ! relationInfo ) {
839- throw this . makeUnsupportedRelationshipError ( type , key , 400 ) ;
831+ return this . makeUnsupportedRelationshipError ( type , key , 400 ) ;
840832 }
841833
842834 if ( relationInfo . isCollection ) {
@@ -852,7 +844,7 @@ class RequestHandler extends APIHandlerBase {
852844 } ;
853845 } else {
854846 if ( typeof data . data !== 'object' ) {
855- throw this . makeError ( 'invalidRelationData' ) ;
847+ return this . makeError ( 'invalidRelationData' ) ;
856848 }
857849 upsertPayload . create [ key ] = {
858850 connect : this . makeIdConnect ( relationInfo . idFields , data . data . id ) ,
@@ -883,12 +875,12 @@ class RequestHandler extends APIHandlerBase {
883875 if ( relationships ) {
884876 for ( const [ key , data ] of Object . entries < any > ( relationships ) ) {
885877 if ( ! data ?. data ) {
886- throw this . makeError ( 'invalidRelationData' ) ;
878+ return this . makeError ( 'invalidRelationData' ) ;
887879 }
888880
889881 const relationInfo = typeInfo . relationships [ key ] ;
890882 if ( ! relationInfo ) {
891- throw this . makeUnsupportedRelationshipError ( type , key , 400 ) ;
883+ return this . makeUnsupportedRelationshipError ( type , key , 400 ) ;
892884 }
893885
894886 if ( relationInfo . isCollection ) {
@@ -899,7 +891,7 @@ class RequestHandler extends APIHandlerBase {
899891 } ;
900892 } else {
901893 if ( typeof data . data !== 'object' ) {
902- throw this . makeError ( 'invalidRelationData' ) ;
894+ return this . makeError ( 'invalidRelationData' ) ;
903895 }
904896 createPayload . data [ key ] = {
905897 connect : this . makeIdConnect ( relationInfo . idFields , data . data . id ) ,
0 commit comments