@graphql-mesh/transport-rest
Version:
17 lines (16 loc) • 598 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.processFlattenAnnotations = void 0;
function processFlattenAnnotations(field) {
if (!field.resolve || field.resolve.name === 'defaultFieldResolver') {
const fieldName = field.name;
field.resolve = function flattenDirectiveHandler(root) {
let result = root[fieldName];
if (!Array.isArray(root)) {
result = [result];
}
return result.flat(Infinity);
};
}
}
exports.processFlattenAnnotations = processFlattenAnnotations;
;