GraphQL 有什么缺点吗? [英] Are there any disadvantages to GraphQL?

查看:40
本文介绍了GraphQL 有什么缺点吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有关于GraphQL的文章都会告诉你它有多棒,但它有什么缺点或不足吗?谢谢.

All the articles about GraphQL will tell you how wonderful it is, but are there any disadvantages or shortcomings to it? Thank you.

推荐答案

缺点:

  • 需要学习如何设置 GraphQL.生态系统仍在快速发展,因此您必须跟上.
  • 您需要从客户端发送查询,您可以只发送字符串,但如果您想要更舒适和缓存,您将使用客户端库 -> 额外代码在您的客户端
  • 您需要事先定义架构 => 额外工作,然后才能获得结果
  • 您的服务器上需要有一个 graphql 端点 => 新库您还不知道
  • Graphql 查询比简单地转到 REST 端点更多字节
  • 服务器需要做更多处理来解析查询并验证参数
  • You need to learn how to set up GraphQL. The ecosystem is still rapidly evolving so you have to keep up.
  • You need to send the queries from the client, you can just send strings but if you want more comfort and caching you'll use a client library -> extra code in your client
  • You need to define the schema beforehand => extra work before you get results
  • You need to have a graphql endpoint on your server => new libraries that you don't know yet
  • Graphql queries are more bytes than simply going to a REST endpoint
  • The server needs to do more processing to parse the query and verify the parameters

但是,这些都被这些反驳了:

But, those are more than countered by these:

  • GraphQL 不难学
  • 额外的代码只有几 KB
  • 通过定义架构,您将避免事后的更多工作修复错误和持久的升级
  • 有很多人改用 GraphQL,因此有一个丰富的生态系统正在开发中,具有出色的工具
  • 在生产中使用持久查询(用简单的 ID 和参数替换 GraphQL 查询)时,实际上发送的字节数比 REST 少
  • 对传入查询的额外处理可以忽略不计
  • 提供API 和后端的干净解耦可以加快后端改进的迭代
  • GraphQL is not that hard to learn
  • The extra code is only a few KB
  • By defining a schema, you will prevent much more work afterwards fixing bugs and enduring hairy upgrades
  • There are a lot of people switching to GraphQL so there is a rich ecosystem developing, with excellent tooling
  • When using persistent queries in production (replacing GraphQL queries with simply an ID and parameters), you actually send less bytes than with REST
  • The extra processing for incoming queries is negligible
  • Providing a clean decoupling of API and backend allows for much faster iteration on backend improvenments

这篇关于GraphQL 有什么缺点吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆