常见问题
前端

前端

¥Frontend

GraphQL 会取代 Redux 或其他状态管理库吗?

¥Does GraphQL replace Redux or other state management libraries?

不,GraphQL 不是状态管理库 - 但它可以减少对它的需要。

¥No, GraphQL isn’t a state management library - but it can reduce the need for one.

像 Redux 这样的状态管理库的一个好处是,它们可以将 API 响应处理成你的应用可以理解的格式。使用 GraphQL,你可以控制 你请求哪些数据,并且结果通常由图形设计以客户端友好的方式格式化。因此,此好处已内置。许多 客户端库 也可用于管理状态并具有内置缓存等功能。你可能仍决定实现状态管理库,但使用它来格式化响应数据通常不是必要的。

¥One benefit of state management libraries like Redux is that they can manipulate API responses into a format that your application understands. With GraphQL, you have control over what data you request and typically results are formatted in a client-friendly way by the graph design. So this benefit is already built-in. Many client libraries can also be used to manage state and have features like caching built-in. You may still decide to implement a state management library, but using it to format response data is generally not necessary.