@@ -597,21 +597,32 @@ export function getResolver<TSource, TContext, TArgs> ({
597
597
let data
598
598
// tslint:disable-next-line:no-conditional-assignment
599
599
while ( data = this . read ( ) ) {
600
- filePassThrough . write ( data )
600
+ const canReadNext = filePassThrough . write ( data )
601
+ if ( ! canReadNext ) {
602
+ this . pause ( )
603
+ filePassThrough . once ( 'drain' , ( ) => this . resume ( ) )
604
+ }
601
605
}
602
606
} )
603
607
608
+ originalFileStream . on ( 'error' , ( ) => {
609
+ uploadLog ( 'Encountered an error while uploading the file %s' , uploadingFile . filename )
610
+ } )
611
+
604
612
originalFileStream . on ( 'end' , ( ) => {
605
- uploadLog ( ` Upload for received file ${ uploadingFile . filename } completed` )
613
+ uploadLog ( ' Upload for received file %s completed' , uploadingFile . filename )
606
614
filePassThrough . end ( )
607
615
} )
608
616
609
- uploadLog ( ` Queuing upload for received file ${ uploadingFile . filename } ` )
617
+ uploadLog ( ' Queuing upload for received file %s' , uploadingFile . filename )
610
618
611
619
form . append ( fieldName , filePassThrough , {
612
620
filename : uploadingFile . filename ,
613
621
contentType : uploadingFile . mimetype
614
622
} )
623
+ } else if ( typeof fieldValue !== 'string' ) {
624
+ // handle all other primitives that aren't strings as strings the way the web server would expect it
625
+ form . append ( fieldName , JSON . stringify ( fieldValue ) )
615
626
} else {
616
627
form . append ( fieldName , fieldValue )
617
628
}
0 commit comments