-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
offline node creation : use clientMutationId instead of id #53
Comments
I recommend that you use the |
hi morrys, and thanks again for the help. i guess i'm a bit unsure about this part in the react-relay-offline documentation:
what i've done at the moment is for a mutation creating a new node: is this what the documentation means, or am i missing something? |
Perhaps the sample project clarifies the sentence better: Offline mutations do not roll back optimisticupdate because optimistic functions cannot be stored if the application is closed. Furthermore, the nodes created could be shared externally by the application and therefore refer to incorrect identifiers. If it is not possible to generate IDs in the browser at the moment I recommend preventing offline mutations that create new nodes. |
if an optimisticupdate in an offline scenario is not rolled back, how is data integrity ensured once the network request goes through? in the current case i have: i am adding a new record (a), add this record a linkedRecord to (b) and add to the connections of record (c) a new edge to record (b). for record (a) i can not generate a id on the client, but the server will identify the correct node for it and return that one (basically the combination of field values are a unique identifier in this case - but the id scheme on the backend would not allow this as id). just as a thought: wouldn't it be possible for the offline functionality to persist results of network queries and persist / replay mutations when the app is started offline to restore the store state? for that the library would need a list of mutation functions |
If it is not possible to guarantee the state of the store in the optimistic responses, it is possible to manage these conflicts within the callback functions (onComplete, onDiscard, finish) and use the APIs made available to the environment, see local-state-management or globally-invalidating-the-relay-store |
Hi Morrys,
this is a bit of a question:
If I understood the documentation correct the client creating a new node (offline mutation) needs to provide the node id.
Is it possible to use the relay clientMutationId and let the backend decide on the final id?
The text was updated successfully, but these errors were encountered: