hackernews-node/node_modules/graphql-middleware/dist/middleware.js
/**
 *
 * @param schema
 * @param options
 * @param middlewares
 *
 * Generates middleware from middleware generators and applies middleware to
 * resolvers. Returns generated schema with all provided middleware.
 *
 */


Generates middleware from middleware generators and applies middleware to
resolvers. Returns generated schema with all provided middleware.
Generates middleware from middleware generators and applies middleware to resolvers . Returns generated schema with all provided middleware .
function applyMiddlewareWithOptions(schema, options) {
    var middlewares = [];
    for (var _i = 2; _i < arguments.length; _i++) {
        middlewares[_i - 2] = arguments[_i];
    }
    var normalisedMiddlewares = middlewares.map(function (middleware) {
        if (utils_1.isMiddlewareGenerator(middleware)) {
            return middleware.generate(schema);
        }
        else {
            return middleware;
        }
    });
    var schemaWithMiddlewareAndFragmentReplacements = normalisedMiddlewares.reduceRight(function (_a, middleware) {
        var currentSchema = _a.schema, currentFragmentReplacements = _a.fragmentReplacements;
        var _b = addMiddlewareToSchema(currentSchema, options, middleware), newSchema = _b.schema, newFragmentReplacements = _b.fragmentReplacements;
        return {
            schema: newSchema,
            fragmentReplacements: currentFragmentReplacements.concat(newFragmentReplacements),
        };
    }, { schema: schema, fragmentReplacements: [] });
    var schemaWithMiddleware = schemaWithMiddlewareAndFragmentReplacements.schema;
    schemaWithMiddleware.schema =
        schemaWithMiddlewareAndFragmentReplacements.schema;
    schemaWithMiddleware.fragmentReplacements =
        schemaWithMiddlewareAndFragmentReplacements.fragmentReplacements;
    return schemaWithMiddleware;
}
function applyMiddlewareWithOptions ( schema , options ) { var middlewares = [ ] ; for ( var _i = 2 ; _i < arguments . length ; _i ++ ) { middlewares [ _i - 2 ] = arguments [ _i ] ; } var normalisedMiddlewares = middlewares . map ( function ( middleware ) { if ( utils_1 . isMiddlewareGenerator ( middleware ) ) { return middleware . generate ( schema ) ; } else { return middleware ; } } ) ; var schemaWithMiddlewareAndFragmentReplacements = normalisedMiddlewares . reduceRight ( function ( _a , middleware ) { var currentSchema = _a . schema , currentFragmentReplacements = _a . fragmentReplacements ; var _b = addMiddlewareToSchema ( currentSchema , options , middleware ) , newSchema = _b . schema , newFragmentReplacements = _b . fragmentReplacements ; return { schema : newSchema , fragmentReplacements : currentFragmentReplacements . concat ( newFragmentReplacements ) , } ; } , { schema : schema , fragmentReplacements : [ ] } ) ; var schemaWithMiddleware = schemaWithMiddlewareAndFragmentReplacements . schema ; schemaWithMiddleware . schema = schemaWithMiddlewareAndFragmentReplacements . schema ; schemaWithMiddleware . fragmentReplacements = schemaWithMiddlewareAndFragmentReplacements . fragmentReplacements ; return schemaWithMiddleware ; }
@param schema
 @param options
 @param middlewares
@param schema @param options @param middlewares