Could you guys show me how this could be done?
I am trying something like this:
Type Post {
id: ID!
name: string;
nameKebab: String @lambda
}
Function:
function nameKebab({parent: {name} }) {
console.log('working...');
return kebabCase(name);
}
self.addGraphQLResolvers({
"Post.nameKebab": nameKebab
});
function kebabCase(str) {
const result = str.replace(
/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,
match => '-' + match.toLowerCase()
)
return (str[0] === str[0].toUpperCase())
? result.substring(1)
: result
}
The log is not printing anything, and the type is empty after I create a new record…
Thanks,
Jonathan