archive/src-concept/generate/middleware.js
function resolverMiddleware (resolver) {
  return function (req, res, next) {
    try {
      const { source, args, context, info } = req
      const ctx = { req, res, next }
      const value = resolver.call(ctx, source, args, context, info)

      return Promise.resolve(value)
        .then(result => {
          req.result = result
          return next()
        })
        .catch(next)
    } catch (err) {
      return next(err)
    }
  }
}
function resolverMiddleware (resolver) {
  return function (req, res, next) {
    try {
      const { source, args, context, info } = req
      const ctx = { req, res, next }
      const value = resolver.call(ctx, source, args, context, info)

      return Promise.resolve(value)
        .then(result => {
          req.result = result
          return next()
        })
        .catch(next)
    } catch (err) {
      return next(err)
    }
  }
}
function resolverMiddleware ( resolver ) { return function ( req , res , next ) { try { const { source , args , context , info } = req const ctx = { req , res , next } const value = resolver . call ( ctx , source , args , context , info ) return Promise . resolve ( value ) . then ( result => { req . result = result return next ( ) } ) . catch ( next ) } catch ( err ) { return next ( err ) } } }
Wraps the resolver function in middleware so that it can be
added to a middleware queue and processed the same way as
other middleware
@param resolver
@returns {Function}
Wraps the resolver function in middleware so that it can be added to a middleware queue and processed the same way as other middleware