Skip to content

Instantly share code, notes, and snippets.

@lastmjs
Created March 12, 2018 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lastmjs/3b1a54ea600b79f028582f98ee586b07 to your computer and use it in GitHub Desktop.
Save lastmjs/3b1a54ea600b79f028582f98ee586b07 to your computer and use it in GitHub Desktop.
export function prepareTopLevelResolvers(resolverObject: Query | Mutation) {
return Object.entries(resolverObject).reduce((result, entry) => {
const resolverName = entry[0];
const resolverFunction = entry[1];
return {
...result,
[resolverName]: async (parent, args, context, info) => {
return await resolverFunction(args, info);
}
};
}, {});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment