@graphql-mesh/transport-rest
Version:
13 lines (12 loc) • 421 B
JavaScript
export 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);
};
}
}