Skip to content

Commit f135094

Browse files
authored
Update resolvers.ts, handle error when "resolver" variable in addObject is undefined
I suggest this update to the addObject method: if the resolver is undefined, provide a clear message to the user.
1 parent e72b40d commit f135094

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/graphql-modules/src/module/resolvers.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,13 @@ function addObject({
258258
if (fields.hasOwnProperty(fieldName)) {
259259
const resolver = fields[fieldName];
260260

261+
if(typeof resolver === 'undefined'){
262+
throw new ResolverDuplicatedError(
263+
`Resolver not implement of "${typeName}.${fieldName}"`,
264+
useLocation({ dirname: config.dirname, id: config.id })
265+
);
266+
}
267+
261268
if (isResolveFn(resolver)) {
262269
if (container[typeName][fieldName]) {
263270
throw new ResolverDuplicatedError(

0 commit comments

Comments
 (0)