0

我正在使用 Apollo 和 TypeScript 在 React 中启动一个 GraphQL 客户端,用于一个项目,其中 GraphQL 后端处于非常早期的阶段,只实现了一些功能。我使用 TypeScript 代码生成器从片段和查询中生成类型和钩子。这一切都很好,但我正在寻找的是如何处理需要将字段添加到尚未添加到后端的查询的场景?我寻找这个的原因是能够加快前端开发,而不必等待后端团队首先实现一个新领域。

Say that I have an entity called ToDo, and I want to implement the front-end part of a new feature that is showing a status per ToDo entity. The status field is not yet added to the backend, and since my models and hooks are generated directly from the graphql schema on the server, I will have to wait for the backend to add the new status column before I can start working with it.

What I would like, is to be able to add custom hardcoded fields to act as temporary placeholders for functionality that has not yet been implemented on the server. Then I could define the status field client-side, and assign it a hard-coded dummy value. When the status field has then been implemented by the backend team, I could just take out the dummy from the frontend, and it should start working.

What is generally considered the best way to handle such a case?

4

0 回答 0