The concept you are refering to is called batching. There are several libraries out there that offer this. For example:
-
Dataloader: generic utility maintained by Facebook that provides “a consistent API over various backends and reduce requests to those backends via batching and caching”
-
join-monster: “A GraphQL-to-SQL query execution layer for batch data fetching.”