public static PureFieldDelegate Compile( IReadOnlyList <ResultConverterDefinition> resultConverters, PureFieldDelegate fieldResolver, bool skipMiddleware) => skipMiddleware || resultConverters.Count == 0 ? fieldResolver : CompileResultConverters(resultConverters, fieldResolver);
private static PureFieldDelegate CreatePureConverterMiddleware( ResultConverterDelegate convert, PureFieldDelegate next) => c => { var result = next(c); return(convert(c, result)); };
private static PureFieldDelegate CompileResultConverters( IReadOnlyList <ResultConverterDefinition> components, PureFieldDelegate first) { PureFieldDelegate next = first; for (var i = components.Count - 1; i >= 0; i--) { next = CreatePureConverterMiddleware(components[i].Converter, next); } return(next); }