GraphQL有什么缺点吗? [英] Are there any disadvantages to GraphQL?
本文介绍了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屋!
查看全文