UNPKG

@graphql-mesh/transport-rest

Version:
13 lines (12 loc) 421 B
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); }; } }