function splitResult(mergedResult, numResults) {
    var splitResults = [];
    for (var i = 0; i < numResults; i++) {
        splitResults.push({});
    }
    var data = mergedResult.data;
    if (data) {
        Object.keys(data).forEach(function (prefixedKey) {
            var _a;
            var _b = parseKey(prefixedKey), index = _b.index, originalKey = _b.originalKey;
            if (!splitResults[index].data) {
                splitResults[index].data = (_a = {}, _a[originalKey] = data[prefixedKey], _a);
            }
            else {
                splitResults[index].data[originalKey] = data[prefixedKey];
            }
        });
    }
    var errors = mergedResult.errors;
    if (errors) {
        var newErrors_1 = Object.create(null);
        errors.forEach(function (error) {
            if (error.path) {
                var parsedKey = parseKey(error.path[0]);
                if (parsedKey) {
                    var index = parsedKey.index, originalKey = parsedKey.originalKey;
                    var newError = utils.relocatedError(error, tslib.__spreadArray([originalKey], tslib.__read(error.path.slice(1))));
                    if (!newErrors_1[index]) {
                        newErrors_1[index] = [newError];
                    }
                    else {
                        newErrors_1[index].push(newError);
                    }
                    return;
                }
            }
            splitResults.forEach(function (_splitResult, index) {
                if (!newErrors_1[index]) {
                    newErrors_1[index] = [error];
                }
                else {
                    newErrors_1[index].push(error);
                }
            });
        });
        Object.keys(newErrors_1).forEach(function (index) {
            splitResults[index].errors = newErrors_1[index];
        });
    }
    return splitResults;
}
/**
 * Split and transform result of the query produced by the `merge` function
 */
Split and transform result of the query produced by the `merge` function
Split and transform result of the query produced by the ` merge ` function
function splitResult(mergedResult, numResults) {
    var splitResults = [];
    for (var i = 0; i < numResults; i++) {
        splitResults.push({});
    }
    var data = mergedResult.data;
    if (data) {
        Object.keys(data).forEach(function (prefixedKey) {
            var _a;
            var _b = parseKey(prefixedKey), index = _b.index, originalKey = _b.originalKey;
            if (!splitResults[index].data) {
                splitResults[index].data = (_a = {}, _a[originalKey] = data[prefixedKey], _a);
            }
            else {
                splitResults[index].data[originalKey] = data[prefixedKey];
            }
        });
    }
    var errors = mergedResult.errors;
    if (errors) {
        var newErrors_1 = Object.create(null);
        errors.forEach(function (error) {
            if (error.path) {
                var parsedKey = parseKey(error.path[0]);
                if (parsedKey) {
                    var index = parsedKey.index, originalKey = parsedKey.originalKey;
                    var newError = utils.relocatedError(error, tslib.__spreadArray([originalKey], tslib.__read(error.path.slice(1))));
                    if (!newErrors_1[index]) {
                        newErrors_1[index] = [newError];
                    }
                    else {
                        newErrors_1[index].push(newError);
                    }
                    return;
                }
            }
            splitResults.forEach(function (_splitResult, index) {
                if (!newErrors_1[index]) {
                    newErrors_1[index] = [error];
                }
                else {
                    newErrors_1[index].push(error);
                }
            });
        });
        Object.keys(newErrors_1).forEach(function (index) {
            splitResults[index].errors = newErrors_1[index];
        });
    }
    return splitResults;
}
function splitResult ( mergedResult , numResults ) { var splitResults = [ ] ; for ( var i = 0 ; i < numResults ; i ++ ) { splitResults . push ( { } ) ; } var data = mergedResult . data ; if ( data ) { Object . keys ( data ) . forEach ( function ( prefixedKey ) { var _a ; var _b = parseKey ( prefixedKey ) , index = _b . index , originalKey = _b . originalKey ; if ( ! splitResults [ index ] . data ) { splitResults [ index ] . data = ( _a = { } , _a [ originalKey ] = data [ prefixedKey ] , _a ) ; } else { splitResults [ index ] . data [ originalKey ] = data [ prefixedKey ] ; } } ) ; } var errors = mergedResult . errors ; if ( errors ) { var newErrors_1 = Object . create ( null ) ; errors . forEach ( function ( error ) { if ( error . path ) { var parsedKey = parseKey ( error . path [ 0 ] ) ; if ( parsedKey ) { var index = parsedKey . index , originalKey = parsedKey . originalKey ; var newError = utils . relocatedError ( error , tslib . __spreadArray ( [ originalKey ] , tslib . __read ( error . path . slice ( 1 ) ) ) ) ; if ( ! newErrors_1 [ index ] ) { newErrors_1 [ index ] = [ newError ] ; } else { newErrors_1 [ index ] . push ( newError ) ; } return ; } } splitResults . forEach ( function ( _splitResult , index ) { if ( ! newErrors_1 [ index ] ) { newErrors_1 [ index ] = [ error ] ; } else { newErrors_1 [ index ] . push ( error ) ; } } ) ; } ) ; Object . keys ( newErrors_1 ) . forEach ( function ( index ) { splitResults [ index ] . errors = newErrors_1 [ index ] ; } ) ; } return splitResults ; }
Split and transform result of the query produced by the `merge` function
Split and transform result of the query produced by the ` merge ` function