ConrabOpto / mst-query

Query library for mobx-state-tree
MIT License
110 stars 7 forks source link

xxx property missing from xxxModel model #22

Closed benjaminkwokhuen closed 2 years ago

benjaminkwokhuen commented 2 years ago

After getting the result from the server, if the data does not have a property define in the model, mst-query will throw an error xxx property missing from xxxModel model

In MST, if a property is not defined in the model, it will ignore it. I would like to have that behavior.

k-ode commented 2 years ago

I'm not opposed to this change, but I'm wonder why you want this? I always found this behavior in mobx-state-tree to be confusing. I rather just massage the incoming data if I need to remove some properties.

benjaminkwokhuen commented 2 years ago

Image you have a deeply nested structure that the backend api returns. While, like you said, you can massage the incoming data to remove some properties, but sometimes the function can be quite complicated to write (e.g. a deeply nested structure that contains fields you partially need), which in turns increase the complexity.

I personally like the default behavior of MST, in which data that is not defined in the schema will be automatically omitted.