News for hackers. Stuff that matters.
Re:REST vs. GraphQL – A search for evidence on which is better by zachrip on Tuesday December 15, 2020 @01:20PM (#25433157)
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.
Re:REST vs. GraphQL – A search for evidence on which is better by valeness on Tuesday December 15, 2020 @02:43PM (#25434155)
Wouldn't it be more resource efficient to traverse the graph ahead of time and prefetch all related resources with a single query?
Re:REST vs. GraphQL – A search for evidence on which is better by zachrip on Tuesday December 15, 2020 @03:21PM (#25434707)
This is more or less what dataloader accomplishes. Generally speaking when creating a gql service, graph traversal is not app code but library code.
Re:REST vs. GraphQL – A search for evidence on which is better by zanellato19 on Tuesday December 15, 2020 @03:45PM (#25435012)
Dataloader 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.
Re:REST vs. GraphQL – A search for evidence on which is better by Aeolun on Wednesday December 16, 2020 @07:32AM (#25441788)
Not more than you’re already twisting it using resolvers? I’ll admit it will look like magic though.