archive/src/generate/backing.js
function resolverMiddleware (resolver) {
  return function (req, res, next) {
    try {
      const { source, args, context, info } = req
      const nonCircularReq = _.omit(req, [ 'context' ])
      const ctx = _.assign({}, context, { req: nonCircularReq, res, next })
      const value = resolver(source, args, ctx, info)

      // return a resolved promise
      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 nonCircularReq = _.omit(req, [ 'context' ])
      const ctx = _.assign({}, context, { req: nonCircularReq, res, next })
      const value = resolver(source, args, ctx, info)

      // return a resolved promise
      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 nonCircularReq = _ . omit ( req , [ 'context' ] ) const ctx = _ . assign ( { } , context , { req : nonCircularReq , res , next } ) const value = resolver ( source , args , ctx , info ) // return a resolved promise return Promise . resolve ( value ) . then ( result => { req . result = result return next ( ) } ) . catch ( next ) } catch ( err ) { return next ( err ) } } }
Creates a middleware function from the field resolve
@param resolver
@returns {Function}
Creates a middleware function from the field resolve