@@ -719,21 +719,10 @@ class RequestHandler extends APIHandlerBase {
719719 const parsed = this . createUpdatePayloadSchema . parse ( body ) ;
720720 const attributes : any = parsed . data . attributes ;
721721
722- // Map in the compound id relationships as attributes, as they are expected by the zod schema
723- if ( parsed . data . relationships ) {
724- for ( const [ key , data ] of Object . entries < any > ( parsed . data . relationships ) ) {
725- const typeInfo = this . typeMap [ key ] ;
726- if ( typeInfo && typeInfo . idFields . length > 1 ) {
727- typeInfo . idFields . forEach ( ( field , index ) => {
728- attributes [ field . name ] = this . coerce ( field . type , data . data . id . split ( this . idDivider ) [ index ] ) ;
729- } ) ;
730- }
731- }
732- }
733-
734722 if ( attributes ) {
735- const schemaName = `${ upperCaseFirst ( type ) } ${ upperCaseFirst ( mode ) } Schema` ;
736- // zod-parse attributes if a schema is provided
723+ // use the zod schema (that only contains non-relation fields) to validate the payload,
724+ // if available
725+ const schemaName = `${ upperCaseFirst ( type ) } ${ upperCaseFirst ( mode ) } ScalarSchema` ;
737726 const payloadSchema = zodSchemas ?. models ?. [ schemaName ] ;
738727 if ( payloadSchema ) {
739728 const parsed = payloadSchema . safeParse ( attributes ) ;
@@ -769,18 +758,6 @@ class RequestHandler extends APIHandlerBase {
769758
770759 const { error, attributes, relationships } = this . processRequestBody ( type , requestBody , zodSchemas , 'create' ) ;
771760
772- if ( relationships ) {
773- // Remove attributes that are present in compound id relationships, as they are not expected by Prisma
774- for ( const [ key ] of Object . entries < any > ( relationships ) ) {
775- const typeInfo = this . typeMap [ key ] ;
776- if ( typeInfo && typeInfo . idFields . length > 1 ) {
777- typeInfo . idFields . forEach ( ( field ) => {
778- delete attributes [ field . name ] ;
779- } ) ;
780- }
781- }
782- }
783-
784761 if ( error ) {
785762 return error ;
786763 }
0 commit comments