3 ms·
The solution for this is to use something like dataloader btw. It essentially waits for all these queries (I believe it uses queueMicrotask under the hood) and
by zachrip 6y ago
The solution for this is to use something like dataloader btw. It essentially waits for all these queries (I believe it uses queueMicrotask under the hood) and batches them. Not unlike other db batching proxies.
- valeness 6y agoWouldn't it be more resource efficient to traverse the graph ahead of time and prefetch all related resources with a single query?
- zachrip 6y agoThis is more or less what dataloader accomplishes. Generally speaking when creating a gql service, graph traversal is not app code but library code.
- zanellato19 6y agoDataloader avoids the N+1 but I wouldn't call it a good solution, you have to twist your app code to make it work. Its an inelegant solution, imo.
- Aeolun 6y agoNot more than you’re already twisting it using resolvers? I’ll admit it will look like magic though.