Skip to content

Commit

Permalink
Simplify directiveResolvers wrapping with an async function.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn committed Mar 14, 2018
1 parent 1c6c770 commit 6344500
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/schemaGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,17 +703,7 @@ function attachDirectiveResolvers(
field.resolve = (...args: any[]) => {
const [source, , context, info] = args;
return resolver(
() => {
try {
const promise = originalResolver.call(field, ...args);
if (promise instanceof Promise) {
return promise;
}
return Promise.resolve(promise);
} catch (error) {
return Promise.reject(error);
}
},
async () => originalResolver.apply(field, args),
source,
directiveArgs,
context,
Expand Down

0 comments on commit 6344500

Please sign in to comment.