"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.graphQLResultHasError = graphQLResultHasError;
exports.getGraphQLErrorsFromResult = getGraphQLErrorsFromResult;
const arrays_js_1 = require("./arrays.cjs");
const incrementalResult_js_1 = require("./incrementalResult.cjs");
function graphQLResultHasError(result) {
    const errors = getGraphQLErrorsFromResult(result);
    return (0, arrays_js_1.isNonEmptyArray)(errors);
}
function getGraphQLErrorsFromResult(result) {
    const graphQLErrors = (0, arrays_js_1.isNonEmptyArray)(result.errors) ? result.errors.slice(0) : [];
    if ((0, incrementalResult_js_1.isExecutionPatchIncrementalResult)(result) &&
        (0, arrays_js_1.isNonEmptyArray)(result.incremental)) {
        result.incremental.forEach((incrementalResult) => {
            if (incrementalResult.errors) {
                graphQLErrors.push(...incrementalResult.errors);
            }
        });
    }
    return graphQLErrors;
}
//# sourceMappingURL=errorHandling.cjs.map
