https://github.com/graphql/dataloader#batch-function
を応用すればいいだけ。
自分のjavascriptのレベルが低いときはスルーしてた
const users = [{
id:3,
name: "jone"
},{
id:6,
name: "paul"
},{
id:8,
name: "anna"
}];
const userIds =[6, 3, 8];
const mapped = userIds.map(
userid => users.find(e => e.id === userid) || null
);
console.log(mapped);
/*
[
{ id: 6, name: 'paul' },
{ id: 3, name: 'jone' },
{ id: 8, name: 'anna' }
]
*/