Unreadable error with resolversComposition when resolver is not defined
Closed this issue · 1 comments
Hello,
I've used resolversComposition on graphql-modules with 1 directive @auth:
type Mutation {
createPost(data: createPostInput): createPostOutput @auth
updatePost(_id: ID!, data: updatePostInput): updatePostOutput @auth
}
and got the following error when starting the graphQL server:
TypeError: Cannot use 'in' operator to search for 'subscribe' in undefined
at resolveRelevantMappings (node_modules/graphql-toolkit/src/utils/resolvers-composition.ts:28:13)
at Object.keys.map.resolverPath (node_modules/graphql-toolkit/src/utils/resolvers-composition.ts:62:13)
hard to figure it out with this message, but it was simply because one resolver (updatePost) was not defined.
it would be nice to throw a more explicit Error in resolvers-composition.ts function resolveRelevantMappings, or maybe to check if the resolver exists and display a warning, around this code:
if ('subscribe' in resolvers[typeName][fieldName]) {
paths.push(path + '.subscribe');
}
If you wish, and according your feedback, I can submit a PR.
Fixed in 0.3.1!