@apollographql/graphql-upload-8-fork
Version:
Fork of graphql-upload@8 that works with graphql@15 for compatibility with apollo-server@2
28 lines (22 loc) • 615 B
JavaScript
exports.__esModule = true
exports.graphqlUploadKoa = void 0
var _processRequest = require('./processRequest')
const graphqlUploadKoa = ({
processRequest = _processRequest.processRequest,
...processRequestOptions
} = {}) => async (ctx, next) => {
if (!ctx.request.is('multipart/form-data')) return next()
const finished = new Promise(resolve => ctx.req.on('end', resolve))
try {
ctx.request.body = await processRequest(
ctx.req,
ctx.res,
processRequestOptions
)
await next()
} finally {
await finished
}
}
exports.graphqlUploadKoa = graphqlUploadKoa