react sql格式化
When it comes to the data exchange between the frontend and the backend REST is the most common way to go. At least it was until GraphQL came in. When I heard the first time about GraphQL I though that was it. One endpoint and declarative way of getting backend data was a promise of faster and easier development process. It seemed that I didn’t need to disturb backend devs anymore and that getting the data is fully in my control.
当涉及到前端和后端REST之间的数据交换时,这是最常见的方法。 至少直到GraphQL出现为止。当我第一次听说GraphQL时,就是这样。 一种获取后端数据的端点和声明方式是对更快,更轻松的开发过程的承诺。 似乎我不再需要打扰后端开发人员,并且完全由我控制数据的获取。
But once I dived in a little bit there where few things that drawn me away:
但是,一旦我潜入一点,那里几乎没有什么吸引我的:
- Another query language 另一查询语言
- JSON like query language (not very readable) 类似于查询语言的JSON(不太可读)
- Complex mutations 复杂突变
- Efficient queries need good and intricate resolvers to be written 高效的查询需要编写出色而复杂的解析器
So yes, I didn’t write any serious app with GraphQL, but still, I think that being independent from the backend would be a huge benefit. And if I didn’t need to modify the backend code related to exposing frontend data each time the shape of that data changes or new data is added it would be a big relief.
因此,是的,我没有使用GraphQL编写任何严肃的应用程序,但我仍然认为,独立于后端将是巨大的好处。 而且,如果我不需要每次更改数据的形状或添加新数据时都需要修改与公开前端数据有关的后端代码,那将是一件很大的事情。
Of course GraphQL has its place and will help you especially if your app is one of those bigger ones and if it combines multiple data sources but for my side projects there must be something simpler but with similar advantages.
当然,GraphQL占有一席之地,它将为您提供帮助,特别是如果您的应用是其中的一个较大应用,并且如果它结合了多个数据源,但是对于我的副项目,则必须有一些更简单但具有类似优势的东西。
My typical side project looks like this:
我典型的辅助项目如下所示:
- there is a backend server (currently Kotlin + Spring / Micronaut) 有一个后端服务器(目前是Kotlin + Spring / Micronaut)
- backend is connected to the Postgres database 后端连接到Postgres数据库
backend is divided into querying and writing parts (simple form of CQS)
后端分为查询和编写部分( CQS的简单形式)
- backend uses REST to communicate 后端使用REST进行通信
frontend is in most cases built with React and Typescript and Axios +