Error saving diagram JSON graphql

I’ve had this problem for a couple days and I don’t know how to solve it. The problem is: I tried to save my diagram data using diagram.model.toJson() and then transform the JSON into a string to store it in a database using a graphql mutation. I only get Error: applyIncrementalJson cannot change Model properties evey single time, I also tried to use toIncrementalJson but thats not what I need, I need the complete diagram information. I apreciate all kind of guidance or help, I’m using gojs for my degree proyect so I need to acomplish this to finish the prototype.

Use Model.appllyIncrementalJson to update the model from an external source of incremental updates produced by Model.toIncrementalJson.

But are you trying to update the GoJS model?

To be honest, I don’t know how to use correctly Model.appllyIncrementalJson, the documentation is so blurry and I can’t find a practical example

Well, it doesn’t look like you would want to call it.

But it seems I need to, how do I implement correctly applyIncrementalJson method? I need an example, I mean, what type of data or event I need to supply to the method to make it work?

From your description, you do not need to modify the model, so you do not need to call applyIncrementalJson.

https://gojs.net/latest/samples/stateChartIncremental.html

Actually I need to modify the model, the scenario is the next: I have a room with many users, in every room exists a view with a model and every user can modify it, so, I want to save just that, the diagram information for each user in the room

Are you talking about real-time collaboration? GoJS does not have that feature built-in. Although it is possible to implement.

Something like that, yes, but the core issue is that I can’t save the data of the diagram, the response is Error: applyIncrementalJson cannot change Model properties and I don’t know how to apply correctly the method applyIncrementalJson neither

If you have two models, and one changes and emits the result of Model.toIncrementalJson, then you can apply that JSON-formatted result string to the second model to get it to the same state.

Now you can also do the same thing in memory (or at least avoid standard JSON-serialization) by calling Model.toIncrementalData and Model.mergeNodeDataArray and GraphLinksModel.mergeLinkDataArray when dealing with models that have immutable data. An example is in our component for React: https://github.com/NorthwoodsSoftware/gojs-react/blob/master/src/components/Diagram.tsx

Thanks for the help, I solved the issue, was a GraphQL error in the mutation definition, with that fixed now I can save diagram information and the data changes. Error layer 8 (user error) thanks a lot for take your time for responding my questions.