import DataLoader from 'dataloader' ; import { accountFindOne } from 'app/vendor/account/accountFindOne' ; import { GraphQLResolveInfo } from 'graphql' ; export function accountDL ( context , info ) { return new DataLoader < string , any > ( async ( ids ) => { const results = [ await accountFindOne ( { info } , context ) ] ; return ids . map ( ( id ) => results . find ( ( x ) => x . id === id ) || new Error ( `Account: no result for ${ id }` ) ) ; } ) ; }