You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
When using additionalResolvers in a declarative way, it is easy to may a typo in a targetSource or targetMethod. At the moment, the error messages due to that are not user-friendly.
For example:
if I will specify a wrong targetSource name, the message will be "message": "Cannot read property 'api' of undefined".;
if I'll specify a wrong targetMethod -> "message": "Cannot read property 'type' of undefined".
Describe the solution you'd like:
It would be great to give more user-friendly error messages in that context, i.e.:
for an incorrect targetSource: additionalResolver error: unknown targetSource ${additionalResolver.targetSource};
for an incorrect targetMethod: additionalResolver error: targetMethod ${additionalResolver.targetMethod} does not exist on targetSource ${additionalResolver.targetSource}.
Example of an implementation
In packages/config/src/utils.ts
return{[additionalResolver.type]: {[additionalResolver.field]: {selectionSet: additionalResolver.requiredSelectionSet,resolve: async(root: any,args: any,context: any,info: any)=>{constresolverData={ root, args, context, info };constmethodArgs: any={};for(constargPathinadditionalResolver.args){set(methodArgs,argPath,stringInterpolator.parse(additionalResolver.args[argPath],resolverData));}// >>>>>>>>>>>>>>>// Basic validation of additionalResolver's parametersif(!(additionalResolver.targetSourceincontext))thrownewError(`additionalResolver error: unknown targetSource '${additionalResolver.targetSource}'`);if(!(additionalResolver.targetMethodincontext[additionalResolver.targetSource].api))thrownewError(`additionalResolver error: targetMethod ${additionalResolver.targetMethod} does not exist on targetSource ${additionalResolver.targetSource}`);// >>>>>>>>>>>>>>>constresult=awaitcontext[additionalResolver.targetSource].api[additionalResolver.targetMethod](methodArgs,{selectedFields: additionalResolver.resultSelectedFields,selectionSet: additionalResolver.resultSelectionSet,depth: additionalResolver.resultDepth,});returnadditionalResolver.returnData ? get(result,additionalResolver.returnData) : result;},},},};
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
When using additionalResolvers in a declarative way, it is easy to may a typo in a targetSource or targetMethod. At the moment, the error messages due to that are not user-friendly.
For example:
targetSource
name, the message will be "message": "Cannot read property 'api' of undefined".;targetMethod
-> "message": "Cannot read property 'type' of undefined".Describe the solution you'd like:
It would be great to give more user-friendly error messages in that context, i.e.:
targetSource
:additionalResolver error: unknown targetSource ${additionalResolver.targetSource}
;targetMethod
:additionalResolver error: targetMethod ${additionalResolver.targetMethod} does not exist on targetSource ${additionalResolver.targetSource}
.Example of an implementation
In
packages/config/src/utils.ts
The text was updated successfully, but these errors were encountered: