Just thought I would add, as far as typescript, you need to do this:
async function customFunction({ args, dql, authHeader }: any) {
...
...
(self as any).addGraphQLResolvers({
"Mutation.customFunction": customFunction
});
Of course it really depends on your rules enabled in tsconfig…
J