File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -39,18 +39,23 @@ export function processRequest (request, {uploadDir} = {}) {
39
39
} )
40
40
}
41
41
42
+ export function apolloUploadKoa ( options ) {
43
+ return async function ( ctx , next ) {
44
+ // Skip if there are no uploads
45
+ if ( ctx . request . is ( 'multipart/form-data' ) ) {
46
+ ctx . request . body = await processRequest ( ctx . req , options )
47
+ }
48
+ await next ( )
49
+ }
50
+ }
51
+
42
52
export function apolloUploadExpress ( options ) {
43
53
return ( request , response , next ) => {
54
+ // Skip if there are no uploads
55
+ if ( ! request . is ( 'multipart/form-data' ) ) return next ( )
44
56
processRequest ( request , options ) . then ( body => {
45
57
request . body = body
46
58
next ( )
47
59
} )
48
60
}
49
61
}
50
-
51
- export function apolloUploadKoa ( options ) {
52
- return async function ( ctx , next ) {
53
- ctx . request . body = await processRequest ( ctx . req , options )
54
- await next ( )
55
- }
56
- }
You can’t perform that action at this time.
0 commit comments