所以在我看来,GraphQL 更应该叫 TreeQL,当然在图论里,Tree 就是 Graph 也没毛病啦。需要注意的是,这也会引出 “N + 1 problem” 的话题——naive 的 GraphQL 服务端实现会让这段 query 变得异常慢! 怎么解决这个棘手的问题?心急的小伙伴请跳转到 6.1 N+1 问题! 4. GraphQL 能做到修改数据吗? 看了上...
所以在我看来,GraphQL 更应该叫 TreeQL,当然在图论里,Tree 就是 Graph 也没毛病啦。需要注意的是,这也会引出 “N + 1 problem” 的话题——naive 的 GraphQL 服务端实现会让这段 query 变得异常慢! 怎么解决这个棘手的问题?心急的小伙伴请跳转到6.1 N+1 问题! 4. GraphQL 能做到修改数据吗? 看了上面...
所以在我看来,GraphQL 更应该叫 TreeQL,当然在图论里,Tree 就是 Graph 也没毛病啦。需要注意的是,这也会引出 “N + 1 problem” 的话题——naive 的 GraphQL 服务端实现会让这段 query 变得异常慢! 怎么解决这个棘手的问题?心急的小伙伴请跳转到6.1 N+1 问题! 4. GraphQL 能做到修改数据吗? 看了上面...
目前GraphQL通用的解决方案是Facebook提供的Dataloader, 他的核心思想是Batch Query和Cached. 每种语言都有自己的DataLoader的实现, 去Github都能找到 Laravel N+1的解决方法 目前我们采用的是PHP的Laravel GraphQL框架. 这个框架有两种解决N+1的问题 DataLoader, 这个有个现成的Laravel的Demo GraphQL\Deferred, laravel...
需要注意的是,这也会引出 "N + 1 problem" 的话题——naive 的 GraphQL 服务端实现会让这段 query 变得异常慢! 怎么解决这个棘手的问题?心急的小伙伴请跳转到 6.1 N+1 问题! 4. GraphQL 能做到修改数据吗? 看了上面的 query 的例子,你肯定很好奇,graphql 这种看上去好像只为查询而存在的语言,是不是...
它就像是一颗无限向下延伸的树。所以在我看来,GraphQL 更应该叫 TreeQL,当然在图论里,Tree 就是 Graph 也没毛病啦。需要注意的是,这也会引出 “N + 1 problem” 的话题——naive 的 GraphQL 服务端实现会让这段 query 变得异常慢! 怎么解决这个棘手的问题?心急的小伙伴请跳转到6.1 N+1 问题!
Solving the N+1 Problem for GraphQL through Batching – Shopify Engineering How Facebook organizes their GraphQL code How to structure GraphQL server code GraphQL as an API Gateway to Microservices GraphQL at massive scale: GraphQL as the glue in a microservice architecture ...
GraphQL APIs can solve challenges like over fetching and under fetching (also called the N+1 problem). But as with any API, a poorly designed GraphQL API can result in some horrendous N+1 issues. Users have control over the response of a GraphQL request by modifying the query they send...
Underfetching and the n+1 problem Another issue is underfetching and the n+1-requests problem. Underfetching generally means that a specific endpoint doesn’t provide enough of the required information. The client will have to make additional requests to fetch everything it needs. This can escal...
Now that we have seen the problem, let's solve it. How to solve the N+1 problem? The most common way to solve the N+1 problem is to use DataLoaders . The DataLoader allows you to batch and cache the results of your queries and reuse them when necessary. Mercurius offers you two ...