Correct me if I am mistaken, but I believe that you are combining two problems: you are discussing the problem of storing a local state, but in fact you are concerned about the problem of conflicting changes made by two people (for example, another person is editing the same article that the current one is editing user). The reason, in my opinion, is that you are talking about a change in the requisites of the relay, which will happen only if your application will actively receive updates from the server, and there are such updates to receive.
This seems to be a kind of anti-pattern, because the data in the view does not come directly from the repeater. Synchronization between local state and relay can be a source of errors
The Relay application will not constantly synchronize with the server if you do not. Relay request and details that are passed to the component are not updated constantly. If there is a possibility of a conflict, you need to solve this problem, and this is not a relay problem, and where you store the local state will not solve this problem.
The easiest way to handle conflicts:
- Use option 2 for local state
- Provide each article with an automatically increasing version of the # that you get when you download the article for editing.
- Require mutations to edit an article to indicate the base version # of which it runs. The server must reject any mutation that has a base that is not the current version. Inform the user that there are conflicting changes, they do not work in the latest version, and you cannot allow them to be saved.
I worked on complex Relay applications, and we always relied on # 2. The Local React state is excellent, and the controlled inputs are excellent. This is not an anti-pattern, relay, or other.
source share