core: easy require resolve hook

This commit is contained in:
undefined committed 2022-01-01 03:42:41 +08:00
1 parent 06faa233f8
commit 072f165f9e
3 files changed
+6 -2

No files matched your search

+2 -1
View File
@@ -40,7 +40,8 @@ export function registerResolver(
const wrappedFunc = async (arg, ctx, info) => {
const res = await func(arg, ctx, info);
if (typeof res !== 'object') return res;
if (handlers[value]) Object.assign(res, handlers[value]);
const node = value.includes('!') ? value.split('!')[0] : value;
if (handlers[node]) Object.assign(res, handlers[node]);
ctx.parent = res;
return res;
};